From 8c638acfc79f9151bd1d30506223693fdc443707 Mon Sep 17 00:00:00 2001 From: ISA Date: Fri, 14 Mar 2025 08:49:28 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20Dynamische=20Einheit=20in=20Redux=20f?= =?UTF-8?q?=C3=BCr=20Schleifen-=20und=20Isolationswiderstand=20hinzugef?= =?UTF-8?q?=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Redux-Slice erweitert um `unit`-State (kOhm/MOhm) - `setSelectedSlotType` aktualisiert die Einheit basierend auf der Auswahl - Dropdown in `LoopChartActionBar.tsx` angepasst, um Einheit zu setzen - Y-Achse und Tooltip in `LoopMeasurementChart.tsx` zeigen dynamisch die Einheit aus Redux - Initialwert von `bisDatum` auf das heutige Datum gesetzt --- .../LoopMeasurementChart.tsx | 19 +++++++++++-------- redux/slices/kabelueberwachungChartSlice.ts | 5 ++++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart.tsx b/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart.tsx index c24a8f0..30ec783 100644 --- a/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart.tsx +++ b/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart.tsx @@ -15,7 +15,7 @@ import { } from "recharts"; import { setBrushRange } from "../../../../../../redux/slices/brushSlice"; -const CustomTooltip = ({ active, payload, label }: any) => { +const CustomTooltip = ({ active, payload, label, unit }: any) => { if (active && payload && payload.length) { const messwertMax = payload.find( (p: any) => p.dataKey === "messwertMaximum" @@ -40,12 +40,12 @@ const CustomTooltip = ({ active, payload, label }: any) => { {new Date(label).toLocaleString()} {messwertMax && (
- Messwert Maximum: {messwertMax.value.toFixed(2)} kOhm + Messwert Maximum: {messwertMax.value.toFixed(2)} {unit}
)} {messwert && (
- Messwert: {messwert.value.toFixed(2)} kOhm + Messwert: {messwert.value.toFixed(2)} {unit}
)} {messwertDurchschnitt && ( @@ -53,12 +53,12 @@ const CustomTooltip = ({ active, payload, label }: any) => { style={{ color: "#00AEEF" }} >{`Messwert Durchschnitt: ${messwertDurchschnitt.value.toFixed( 2 - )} kOhm`} + )} ${unit}`} )} {messwertMin && (
{`Messwert Minimum: ${messwertMin.value.toFixed(2)} kOhm`}
+ >{`Messwert Minimum: ${messwertMin.value.toFixed(2)} ${unit}`} )} ); @@ -68,6 +68,9 @@ const CustomTooltip = ({ active, payload, label }: any) => { const LoopMeasurementChart = () => { const dispatch = useDispatch(); + const unit = useSelector( + (state: RootState) => state.kabelueberwachungChart.unit + ); const brushRange = useSelector((state: RootState) => state.brush); const { @@ -156,11 +159,11 @@ const LoopMeasurementChart = () => { tickFormatter={(zeit) => new Date(zeit).toLocaleDateString()} /> `${wert.toFixed(2)} kOhm`} + tickFormatter={(wert) => `${wert.toFixed(0)} `} /> - } /> + } /> ) => { state.selectedSlotType = action.payload; + state.unit = action.payload === "schleifenwiderstand" ? "kOhm" : "MOhm"; // 🆕 Einheit setzen }, // Aktion zum Öffnen oder Schließen des Charts setChartOpen: (state, action: PayloadAction) => {