UNPKG

isomorphic-svg-charts

Version:

A lightweight, environment-agnostic SVG charting library that works both in the browser and server-side, with no dependencies and no DOM reliance.

69 lines (68 loc) 2.02 kB
type Component<T extends string, Key extends string | symbol | number> = { dataKey: Key; stroke?: string; fill?: string; borderRadius?: number; type: T; style?: 'solid' | 'dashed'; stackId?: string; }; type Bar<K extends string> = Component<"bar", K>; type Line<K extends string> = Component<"line", K>; type Area<K extends string> = Component<"area", K>; export declare class CartesianChart<K extends string, D extends Record<K, string | number>> { data: D[]; height: number; width: number; padding: number; private _xAxis?; private _yAxis?; private grid?; private centerDataPoints; private backgroundColor?; private textColor; private stackOffset; maxYValue: number; minYValue: number; components: Component<string, K>[]; constructor({ data, apsectRatio, padding, backgroundColor, textColor, stackOffset, }: { data: Record<K, string | number>[] & D[]; apsectRatio?: number; padding?: number; backgroundColor?: string; textColor?: string; stackOffset?: "none" | "expand"; }); bar(config: Omit<Bar<K>, "type">): this; area(config: Omit<Area<K>, "type">): this; line(config: Omit<Line<K>, "type">): this; private renderHighlights; private renderBars; private renderLines; private renderAreas; private renderComponents; private calculateHeightScale; xAxis({ dataKey, ...config }: { height: number; numTicks?: number; centerLabels?: boolean; stroke?: string; dataKey?: undefined; } | { height: number; numTicks?: undefined; centerLabels?: boolean; stroke?: string; dataKey: K; }): this; yAxis(config: { width: number; numTicks?: number; stroke?: string; tickFormatter?: (value: number, total: number) => string; }): this; cartesianGrid(): this; private getPlotArea; toString(): string; } export {};