From 14ba25bc5792ad4090f82ada2beb3389a0f14ca9 Mon Sep 17 00:00:00 2001 From: Ismail Ali Date: Sun, 30 Mar 2025 22:16:02 +0200 Subject: [PATCH] fix: Legendenbeschriftungen im LoopMeasurementChart benutzerfreundlich umbenannt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Interne Datenkeys wie 'messwert' oder 'messwertMinimum' werden jetzt als 'Messwert', 'Minimum' usw. angezeigt - Neue Mapping-Tabelle für sprechende Labels in der Legende eingeführt --- .../LoopMeasurementChart.tsx | 48 ++++++------------- config/webVersion.ts | 2 +- 2 files changed, 15 insertions(+), 35 deletions(-) diff --git a/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart.tsx b/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart.tsx index 0062e5e..5775ff4 100644 --- a/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart.tsx +++ b/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart.tsx @@ -48,7 +48,6 @@ const LoopMeasurementChart = () => { [loopMeasurementCurveChartData, selectedMode] ); - // Initialisierung des Brush-Bereichs nur beim ersten Laden der Daten useEffect(() => { if (brushRange.endIndex === 0 && formatierteDaten.length) { dispatch( @@ -62,7 +61,7 @@ const LoopMeasurementChart = () => { const handleBrushChange = useCallback( ({ startIndex, endIndex }: { startIndex?: number; endIndex?: number }) => { - if (startIndex === undefined || endIndex === undefined) return; // Verhindert Fehler + if (startIndex === undefined || endIndex === undefined) return; dispatch( setBrushRange({ @@ -85,28 +84,15 @@ const LoopMeasurementChart = () => { [dispatch, formatierteDaten] ); - //-------------------------------------------------------------------------------- useEffect(() => { if (formatierteDaten.length) { - console.log("🔍 Redux vonDatum:", vonDatum); - console.log("🔍 Redux bisDatum:", bisDatum); - - //console.log("🔍 Verfügbare Zeitpunkte in formatierteDaten:"); - /* formatierteDaten.forEach((d, index) => { - console.log( - `${index}: ${new Date(d.zeit).toISOString().split("T")[0]}` - ); - }); - */ const startIndex = formatierteDaten.findIndex( (d) => new Date(d.zeit).toISOString().split("T")[0] === vonDatum ); - //console.log("startIndex in Brush ", startIndex); const endIndex = formatierteDaten.findIndex( (d) => new Date(d.zeit).toISOString().split("T")[0] === bisDatum ); - //console.log("endIndex in Brush ", endIndex); if (startIndex !== -1 && endIndex !== -1) { dispatch( @@ -120,18 +106,13 @@ const LoopMeasurementChart = () => { } } }, [vonDatum, bisDatum, formatierteDaten, dispatch]); - //---------------------------------------------------------------- + useEffect(() => { if (formatierteDaten.length > 0) { - console.log( - "📊 Brush wird nach Modus-Wechsel aktualisiert:", - selectedMode - ); - dispatch( setBrushRange({ startIndex: 0, - endIndex: formatierteDaten.length - 1, // Stellt sicher, dass der Brush-Bereich korrekt gesetzt wird + endIndex: formatierteDaten.length - 1, startDate: new Date(formatierteDaten[0].zeit) .toISOString() .split("T")[0], @@ -143,20 +124,22 @@ const LoopMeasurementChart = () => { } }, [selectedMode, formatierteDaten, dispatch]); - //-------------------------------------------------------------------------------- + const legendLabelMap: Record = { + messwertMinimum: "Minimum", + messwert: "Messwert", + messwertMaximum: "Maximum", + messwertDurchschnitt: "Durchschnitt", + }; return (
- + { const date = new Date(zeit); @@ -176,7 +159,7 @@ const LoopMeasurementChart = () => { {`${date.getDate()}.${date.getMonth() + 1}`} ); - }} // Dreht die Labels für bessere Übersicht + }} /> { align="center" content={({ payload }) => { if (!payload) return null; - - // Reihenfolge der Legende anpassen const orderedPayload = [...payload].sort((a, b) => { const order = [ "messwertMinimum", @@ -201,7 +182,6 @@ const LoopMeasurementChart = () => { ]; return order.indexOf(a.value) - order.indexOf(b.value); }); - return (
{ key={index} style={{ margin: "0 10px", color: entry.color }} > - ⬤ {entry.value} + ⬤ {legendLabelMap[entry.value] ?? entry.value} ))}
@@ -253,7 +233,7 @@ const LoopMeasurementChart = () => { onChange={handleBrushChange} startIndex={brushRange.startIndex} endIndex={brushRange.endIndex || formatierteDaten.length - 1} - tickFormatter={(zeit) => new Date(zeit).toLocaleDateString()} // Datum statt Zahl + tickFormatter={(zeit) => new Date(zeit).toLocaleDateString()} />
diff --git a/config/webVersion.ts b/config/webVersion.ts index 51d8ef6..da321a5 100644 --- a/config/webVersion.ts +++ b/config/webVersion.ts @@ -6,5 +6,5 @@ 2: Patch oder Hotfix (Bugfixes oder kleine Änderungen). */ -const webVersion = "1.6.188"; +const webVersion = "1.6.189"; export default webVersion;