'use client'; import { type ComponentRenderProps } from '@json-render/react'; import { useData } from '@json-render/react'; import { getByPath } from '@json-render/core'; export function Chart({ element }: ComponentRenderProps) { const { title, dataPath } = element.props as { title?: string | null; dataPath: string }; const { data } = useData(); const chartData = getByPath(data, dataPath) as Array<{ label: string; value: number }> | undefined; if (!chartData || !Array.isArray(chartData)) { return
No data
; } const maxValue = Math.max(...chartData.map((d) => d.value)); return (
{title &&

{title}

}
{chartData.map((d, i) => (
{d.label}
))}
); }