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) <noreply@anthropic.com>
This commit is contained in:
2026-06-28 16:03:03 +02:00
parent d711c14b59
commit 8873ffe9d3
2 changed files with 7 additions and 5 deletions
+5 -3
View File
@@ -91,9 +91,11 @@ export default function BarChart({
// markierte Balken (z.B. Ladetage) bekommen eine eigene Farbe // markierte Balken (z.B. Ladetage) bekommen eine eigene Farbe
data: data:
highlight && highlight.size highlight && highlight.size
? data.map(([x, y]) => ? data.map((p) => {
highlight.has(x) ? { x, y, color: highlightColor } : { x, y } 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, : data,
color, color,
}, },
+2 -2
View File
@@ -177,8 +177,8 @@ function ChartCard({ range, every, title, color, selector }: ChartCardProps) {
} }
} }
// Gesamtverbrauch des angezeigten Zeitraums // Gesamtverbrauch des angezeigten Zeitraums (robust ohne Element-Destrukturierung)
const total = data.reduce((sum, [, v]) => sum + v, 0); const total = data.reduce((sum, p) => sum + (Array.isArray(p) ? Number(p[1]) || 0 : 0), 0);
const totalLabel = range === '365d' ? `Gesamtverbrauch ${value}` : 'Gesamtverbrauch'; const totalLabel = range === '365d' ? `Gesamtverbrauch ${value}` : 'Gesamtverbrauch';
return ( return (