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