import { BarChart as RechartsBarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend, } from 'recharts' import { ChartContainer, ChartTooltipContent, type Series, getSeriesColor } from './chart_container' interface BarChartProps { data: Record[] xKey: string yKey?: string series?: Series[] horizontal?: boolean showGrid?: boolean showLegend?: boolean height?: number | string className?: string xAxisFormatter?: (value: unknown) => string yAxisFormatter?: (value: unknown) => string valueFormatter?: (value: number) => string } function BarChartComponent({ data, xKey, yKey, series, horizontal = false, showGrid = true, showLegend = false, height = 300, className, xAxisFormatter, yAxisFormatter, valueFormatter = (v) => v.toLocaleString(), }: BarChartProps) { const bars = series ? series.map((s, i) => ({ dataKey: s.key, name: s.name, fill: getSeriesColor(i, s.color) })) : yKey ? [{ dataKey: yKey, name: yKey, fill: getSeriesColor(0) }] : [] return ( {showGrid && } {horizontal ? ( <> ) : ( <> )} } cursor={{ fill: 'hsl(var(--muted) / 0.3)' }} /> {showLegend && } {bars.map((bar) => )} ) } export const BarChart = BarChartComponent export type { BarChartProps }