diff --git a/components/BarChart.tsx b/components/BarChart.tsx index a3a658c..8f062d8 100644 --- a/components/BarChart.tsx +++ b/components/BarChart.tsx @@ -91,9 +91,11 @@ export default function BarChart({ // markierte Balken (z.B. Ladetage) bekommen eine eigene Farbe data: highlight && highlight.size - ? data.map(([x, y]) => - highlight.has(x) ? { x, y, color: highlightColor } : { x, y } - ) + ? data.map((p) => { + const x = Array.isArray(p) ? p[0] : 0; + const y = Array.isArray(p) ? p[1] : 0; + return highlight.has(x) ? { x, y, color: highlightColor } : { x, y }; + }) : data, color, }, diff --git a/components/VerbrauchCharts.tsx b/components/VerbrauchCharts.tsx index d842591..ce2cc5e 100644 --- a/components/VerbrauchCharts.tsx +++ b/components/VerbrauchCharts.tsx @@ -177,8 +177,8 @@ function ChartCard({ range, every, title, color, selector }: ChartCardProps) { } } - // Gesamtverbrauch des angezeigten Zeitraums - const total = data.reduce((sum, [, v]) => sum + v, 0); + // Gesamtverbrauch des angezeigten Zeitraums (robust ohne Element-Destrukturierung) + const total = data.reduce((sum, p) => sum + (Array.isArray(p) ? Number(p[1]) || 0 : 0), 0); const totalLabel = range === '365d' ? `Gesamtverbrauch ${value}` : 'Gesamtverbrauch'; return (