'use client'; import React from 'react'; import { DashboardElement, QueryResult } from '../types'; import { BarChartComponent } from './BarChartComponent'; import { PieChartComponent } from './PieChartComponent'; import { LineChartComponent } from './LineChartComponent'; import { AreaChartComponent } from './AreaChartComponent'; import { StackedBarChartComponent } from './StackedBarChartComponent'; import { DonutChartComponent } from './DonutChartComponent'; import { ComboChartComponent } from './ComboChartComponent'; interface ChartRendererProps { element: DashboardElement; data?: QueryResult; width?: number; height?: number; } /** * 차트 렌더러 컴포넌트 (단순 버전) * - 데이터를 받아서 차트에 그대로 전달 * - 복잡한 변환 로직 제거 */ export function ChartRenderer({ element, data, width = 250, height = 200 }: ChartRendererProps) { // console.log('🎬 ChartRenderer:', { // elementId: element.id, // hasData: !!data, // dataRows: data?.rows?.length, // xAxis: element.chartConfig?.xAxis, // yAxis: element.chartConfig?.yAxis // }); // 데이터나 설정이 없으면 메시지 표시 if (!data || !element.chartConfig?.xAxis || !element.chartConfig?.yAxis) { return (
📊
데이터를 설정해주세요
⚙️ 버튼을 클릭하여 설정
); } // 데이터가 비어있으면 if (!data.rows || data.rows.length === 0) { return (
⚠️
데이터가 없습니다
); } // 데이터를 그대로 전달 (변환 없음!) const chartData = data.rows; // console.log('📊 Chart Data:', { // dataLength: chartData.length, // firstRow: chartData[0], // columns: Object.keys(chartData[0] || {}) // }); // 차트 공통 props const chartProps = { data: chartData, config: element.chartConfig, width: width - 20, height: height - 60, }; // 차트 타입에 따른 렌더링 switch (element.subtype) { case 'bar': return ; case 'pie': return ; case 'line': return ; case 'area': return ; case 'stacked-bar': return ; case 'donut': return ; case 'combo': return ; default: return (
지원하지 않는 차트 타입
); } }