feat: Chart-Bereich mit Kalender synchronisiert

- Chart-Ansicht wird jetzt basierend auf `vonDatum` und `bisDatum` eingeschränkt.
- `startIndex` und `endIndex` werden aus den Datumswerten berechnet und im Redux-Store aktualisiert.
- `Brush`-Grenzen werden automatisch angepasst, um den sichtbaren Bereich zu begrenzen.
- Sicherstellung, dass `bisDatum` nicht kleiner als `vonDatum` wird.
This commit is contained in:
ISA
2025-03-13 07:29:31 +01:00
parent 8ca3318181
commit 9a0d621143
2 changed files with 63 additions and 3 deletions

View File

@@ -123,6 +123,27 @@ const LoopMeasurementChart = () => {
},
[dispatch, formatierteDaten]
);
useEffect(() => {
if (formatierteDaten.length) {
const startIndex = formatierteDaten.findIndex(
(d) => new Date(d.zeit).toISOString().split("T")[0] === vonDatum
);
const endIndex = formatierteDaten.findIndex(
(d) => new Date(d.zeit).toISOString().split("T")[0] === bisDatum
);
if (startIndex !== -1 && endIndex !== -1) {
dispatch(
setBrushRange({
startIndex,
endIndex,
startDate: vonDatum,
endDate: bisDatum,
})
);
}
}
}, [vonDatum, bisDatum, formatierteDaten, dispatch]);
return (
<div style={{ width: "100%", height: isFullScreen ? "90%" : "400px" }}>