'use client'; import { BarChart as RechartsBarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer, } from 'recharts'; import type { WidgetConfig, ChartData, ChartWidgetConfig } from '@/lib/pipeline-types'; import { WidgetWrapper } from './WidgetWrapper'; interface BarChartWidgetProps { config: WidgetConfig; data: ChartData | null; loading: boolean; error?: string; onRefresh?: () => void; } // Default colors for series const DEFAULT_COLORS = [ '#3b82f6', // blue '#22c55e', // green '#ef4444', // red '#eab308', // yellow '#8b5cf6', // purple '#ec4899', // pink '#06b6d4', // cyan ]; /** * Bar chart widget using Recharts. */ export function BarChartWidget({ config, data, loading, error, onRefresh, }: BarChartWidgetProps) { const chartConfig = config.config as unknown as ChartWidgetConfig; const chartData = data?.data || []; return ( {chartData.length === 0 ? (
No data available
) : ( {chartConfig.show_grid !== false && ( )} {chartConfig.show_legend !== false && } {chartConfig.series?.map((series, index) => ( ))} )}
); }