import { LineChart as RechartsLineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, Brush, ReferenceLine, } from 'recharts' import { ChartContainer, ChartTooltipContent, type Series, getSeriesColor } from './chart_container' type CurveType = 'linear' | 'monotone' | 'step' | 'stepBefore' | 'stepAfter' interface LineChartProps { data: Record[] xKey: string yKey?: string series?: Series[] curveType?: CurveType showGrid?: boolean showLegend?: boolean showDots?: boolean zoomable?: boolean height?: number | string className?: string xAxisFormatter?: (value: unknown) => string yAxisFormatter?: (value: unknown) => string valueFormatter?: (value: number) => string referenceLines?: Array<{ y: number; label?: string; color?: string }> } function LineChartComponent({ data, xKey, yKey, series, curveType = 'monotone', showGrid = true, showLegend = false, showDots = true, zoomable = false, height = 300, className, xAxisFormatter, yAxisFormatter, valueFormatter = (v) => v.toLocaleString(), referenceLines = [], }: LineChartProps) { const lines = series ? series.map((s, i) => ({ dataKey: s.key, name: s.name, stroke: getSeriesColor(i, s.color) })) : yKey ? [{ dataKey: yKey, name: yKey, stroke: getSeriesColor(0) }] : [] return ( {showGrid && } } cursor={{ stroke: 'hsl(var(--muted-foreground))', strokeDasharray: '3 3' }} /> {showLegend && } {referenceLines.map((ref, i) => ( ))} {lines.map((line) => ( ))} {zoomable && } ) } export const LineChart = LineChartComponent export type { LineChartProps, CurveType }