import { ChatContext } from '@/app/chat-context'; import { ChartData } from '@/types/chat'; import { Chart } from '@berryv/g2-react'; import { useContext, useMemo } from 'react'; export default function LineChart({ chart }: { chart: ChartData }) { const { mode } = useContext(ChatContext); // Process data to ensure numeric values for proper y-axis ordering const processedChart = useMemo(() => { const processedValues = chart.values.map(item => ({ ...item, value: typeof item.value === 'string' ? parseFloat(item.value) || 0 : item.value, })); return { ...chart, values: processedValues, }; }, [chart]); return (
{chart.chart_name}
{chart.chart_desc}
); }