From 8873ffe9d31ab65d3ec79759fadf177891c63689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reinhard=20X=2E=20F=C3=BCrst?= Date: Sun, 28 Jun 2026 16:03:03 +0200 Subject: [PATCH] Crash endgueltig ausschliessen: keine Element-Destrukturierung mehr Summenzeile (VerbrauchCharts) und Balken-Einfaerbung (BarChart) greifen die Werte jetzt per Index mit Array.isArray-Guard ab, statt Elemente per [x,y] zu destrukturieren. Damit kann "(destructured parameter) is not iterable" auch bei unerwarteten Datenelementen nicht mehr auftreten. Co-Authored-By: Claude Opus 4.8 (1M context) --- components/BarChart.tsx | 8 +++++--- components/VerbrauchCharts.tsx | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) 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 (