diff --git a/components/VerbrauchCharts.tsx b/components/VerbrauchCharts.tsx index fe07d1f..d842591 100644 --- a/components/VerbrauchCharts.tsx +++ b/components/VerbrauchCharts.tsx @@ -110,7 +110,18 @@ function ChartCard({ range, every, title, color, selector }: ChartCardProps) { if (!res.ok) throw new Error(`HTTP ${res.status}`); const json = await res.json(); if (json.success) { - setData(json.data); + // nur valide [number, number]-Tupel uebernehmen (robust gegen + // unerwartete Elemente, damit die Darstellung nie crasht) + const clean: VerbrauchPoint[] = Array.isArray(json.data) + ? (json.data as unknown[]).filter( + (p): p is VerbrauchPoint => + Array.isArray(p) && + p.length >= 2 && + typeof p[0] === 'number' && + typeof p[1] === 'number' + ) + : []; + setData(clean); } else { setError(json.error || 'Fehler beim Laden der Daten.'); }