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:
@@ -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,
|
||||
},
|
||||
|
||||
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user