/** * Bar Chart Component * Displays categorical data as bars */ import { BarChart as RechartsBarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer, Cell, } from 'recharts'; interface BarChartProps { data: any[]; xKey: string; yKey: string | string[]; title?: string; colors?: string[]; height?: number; showGrid?: boolean; showLegend?: boolean; stacked?: boolean; horizontal?: boolean; formatter?: (value: number) => string; } const DEFAULT_COLORS = ['#10b981', '#3b82f6', '#8b5cf6', '#f59e0b', '#ef4444', '#06b6d4']; export default function BarChart({ data, xKey, yKey, title, colors = DEFAULT_COLORS, height = 300, showGrid = true, showLegend = true, stacked = false, horizontal = false, formatter = (value) => value.toLocaleString(), }: BarChartProps) { const yKeys = Array.isArray(yKey) ? yKey : [yKey]; const layout = horizontal ? 'vertical' : 'horizontal'; return (