--- import charts from '@data/charts.json'; import { chartStyle, chartConfig, type ChartData } from '@shared/lib/chart-script'; import CaptureScript from '../components/CaptureScript.astro'; interface Props { chartId: string; id?: string; size?: 'sm' | 'lg'; class?: string; height?: number; label: string; } const { chartId, id = chartId, size, class: classProp, height: heightProp, label } = Astro.props; const chartsData = charts as Record; let data = chartsData[chartId]; let className = classProp; if (data?.extend) { data = { ...chartsData[data.extend], ...chartsData[chartId] }; } let height = heightProp ?? data?.height ?? 10; if (size === 'sm') { className = `${classProp ?? ''} chart-sm`.trim(); height = 2.5; } else if (size === 'lg') { className = `${classProp ?? ''} chart-lg`.trim(); height = 15; } // The :root custom-property block stays a plain string rendered via set:html — it's // inert CSS text (no injection surface), not executable code. const style = data ? chartStyle({ id, data }) : ''; const { config, xFormatterExpr } = data ? chartConfig({ id, data, height }) : { config: undefined, xFormatterExpr: undefined }; const chartKey = `chart-${id}`; const elementId = `chart-${id}`; --- { data && (