'use client'; import React from 'react'; import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts'; import { ChartConfig } from '../types'; interface BarChartComponentProps { data: any[]; config: ChartConfig; width?: number; height?: number; } /** * 바 차트 컴포넌트 * - Recharts BarChart 사용 * - 설정 가능한 색상, 축, 범례 */ export function BarChartComponent({ data, config, width = 250, height = 200 }: BarChartComponentProps) { const { xAxis = 'x', yAxis = 'y', colors = ['#3B82F6', '#EF4444', '#10B981', '#F59E0B'], title, showLegend = true } = config; // Y축에 해당하는 모든 키 찾기 (그룹핑된 데이터의 경우) const yKeys = data.length > 0 ? Object.keys(data[0]).filter(key => key !== xAxis && typeof data[0][key] === 'number') : [yAxis]; return (