"use client"; import type { ComponentRenderProps } from "./types"; import { baseClass, getCustomClass } from "./utils"; interface DataPoint { label: string; value: number; } export function LineGraph({ element }: ComponentRenderProps) { const { props } = element; const customClass = getCustomClass(props); const data = (props.data as DataPoint[]) || []; const title = props.title as string | undefined; const maxValue = Math.max(...data.map((d) => d.value), 1); const minValue = Math.min(...data.map((d) => d.value), 0); const range = maxValue - minValue || 1; // Calculate points for the SVG path const points = data.map((d, i) => { const x = data.length > 1 ? (i / (data.length - 1)) * 100 : 50; const y = 100 - ((d.value - minValue) / range) * 100; return { x, y, ...d }; }); const pathD = points.length > 0 ? `M ${points.map((p) => `${p.x} ${p.y}`).join(" L ")}` : ""; return (