diff --git a/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/CustomTooltip.tsx b/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/CustomTooltip.tsx new file mode 100644 index 0000000..5109a70 --- /dev/null +++ b/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/CustomTooltip.tsx @@ -0,0 +1,63 @@ +"use client"; + +import React from "react"; + +interface CustomTooltipProps { + active?: boolean; + payload?: any[]; + label?: string; + unit?: string; +} + +const CustomTooltip: React.FC = ({ + active, + payload, + label, + unit, +}) => { + if (active && payload && payload.length) { + const messwertMax = payload.find((p) => p.dataKey === "messwertMaximum"); + const messwert = payload.find((p) => p.dataKey === "messwert"); + const messwertMin = payload.find((p) => p.dataKey === "messwertMinimum"); + const messwertDurchschnitt = payload.find( + (p) => p.dataKey === "messwertDurchschnitt" + ); + + return ( +
+ {new Date(label as string).toLocaleString()} + {messwertMax && ( +
+ Messwert Maximum: {messwertMax.value.toFixed(2)} {unit} +
+ )} + {messwert && ( +
+ Messwert: {messwert.value.toFixed(2)} {unit} +
+ )} + {messwertDurchschnitt && ( +
+ Messwert Durchschnitt: {messwertDurchschnitt.value.toFixed(2)}{" "} + {unit} +
+ )} + {messwertMin && ( +
+ Messwert Minimum: {messwertMin.value.toFixed(2)} {unit} +
+ )} +
+ ); + } + return null; +}; + +export default CustomTooltip; diff --git a/components/main/kabelueberwachung/kue705FO/Charts/DateRangePicker.tsx b/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/DateRangePicker.tsx similarity index 94% rename from components/main/kabelueberwachung/kue705FO/Charts/DateRangePicker.tsx rename to components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/DateRangePicker.tsx index e5da1f6..90c876e 100644 --- a/components/main/kabelueberwachung/kue705FO/Charts/DateRangePicker.tsx +++ b/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/DateRangePicker.tsx @@ -1,11 +1,11 @@ import React from "react"; import DatePicker from "react-datepicker"; import { useSelector, useDispatch } from "react-redux"; -import { RootState } from "../../../../../redux/store"; +import { RootState } from "../../../../../../redux/store"; import { setVonDatum, setBisDatum, -} from "../../../../../redux/slices/kabelueberwachungChartSlice"; +} from "../../../../../../redux/slices/kabelueberwachungChartSlice"; import "react-datepicker/dist/react-datepicker.css"; // ✅ Props definieren diff --git a/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopChartActionBar.tsx b/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopChartActionBar.tsx index 1402d9f..8d2d3a7 100644 --- a/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopChartActionBar.tsx +++ b/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopChartActionBar.tsx @@ -1,6 +1,6 @@ "use client"; // components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopChartActionBar.tsx import React, { useEffect, useMemo } from "react"; -import DateRangePicker from "../DateRangePicker"; +import DateRangePicker from "./DateRangePicker"; import { useDispatch, useSelector } from "react-redux"; import { RootState } from "../../../../../../redux/store"; import { diff --git a/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart copy 2.tsx b/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart copy 2.tsx deleted file mode 100644 index f9a1663..0000000 --- a/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart copy 2.tsx +++ /dev/null @@ -1,203 +0,0 @@ -"use client"; -import React, { useState } from "react"; -import { useSelector, useDispatch } from "react-redux"; -import { RootState } from "../../../../../../redux/store"; -import { - setVonDatum, - setBisDatum, -} from "../../../../../../redux/slices/kabelueberwachungChartSlice"; -import { - ComposedChart, - XAxis, - YAxis, - CartesianGrid, - Tooltip, - Legend, - ResponsiveContainer, - Line, - Brush, - Area, -} from "recharts"; - -// Benutzerdefinierter Tooltip für die richtige Anordnung der Werte -const CustomTooltip = ({ active, payload, label }: any) => { - if (active && payload && payload.length) { - const messwertMax = payload.find( - (p: any) => p.dataKey === "messwertMaximum" - ); - const messwert = payload.find((p: any) => p.dataKey === "messwert"); - const messwertMin = payload.find( - (p: any) => p.dataKey === "messwertMinimum" - ); - const messwertDurchschnitt = payload.find( - (p: any) => p.dataKey === "messwertDurchschnitt" - ); - - return ( -
- {new Date(label).toLocaleString()} -
- {messwertMax - ? `Messwert Maximum: ${messwertMax.value.toFixed(2)} kOhm` - : ""} -
-
- {messwert ? `Messwert: ${messwert.value.toFixed(2)} kOhm` : ""} - {messwertDurchschnitt - ? `Messwert Durchschnitt: ${messwertDurchschnitt.value.toFixed( - 2 - )} kOhm` - : ""} -
-
- {messwertMin - ? `Messwert Minimum: ${messwertMin.value.toFixed(2)} kOhm` - : ""} -
-
- ); - } - return null; -}; - -const LoopMeasurementChart = () => { - const littwinBlue = getComputedStyle( - document.documentElement - ).getPropertyValue("--littwin-blue"); - const dispatch = useDispatch(); - const istVollbild = useSelector( - (state: RootState) => state.kabelueberwachungChart.isFullScreen - ); - const { loopMeasurementCurveChartData, vonDatum, bisDatum } = useSelector( - (state: RootState) => state.kabelueberwachungChart - ); - const ausgewaehlterModus = useSelector( - (state: RootState) => state.kabelueberwachungChart.selectedMode - ); - - // Konvertiere Daten für den Chart & kehre Reihenfolge um - const formatierteDaten = loopMeasurementCurveChartData - .map((eintrag) => ({ - zeit: new Date(eintrag.t).getTime(), // Zeitstempel - messwertMinimum: eintrag.i, // Minimum (Tiefstwert) - messwertMaximum: eintrag.a, // Maximum (Höchstwert) - messwert: eintrag.m ?? null, // Aktueller Messwert - messwertDurchschnitt: - ausgewaehlterModus === "DIA1" || ausgewaehlterModus === "DIA2" - ? eintrag.g ?? null - : null, // Durchschnittswert nur in DIA1 & DIA2 - })) - .reverse(); // Hier wird die Reihenfolge umgekehrt - - // Berechnung des minimalen Werts für Y-Achse - const minMesswert = Math.min( - ...loopMeasurementCurveChartData.map((entry) => entry.i) - ); - - const [zoomedXDomain, setZoomedXDomain] = useState([ - new Date(vonDatum).getTime(), - new Date(bisDatum).getTime(), - ]); - - const handleZoom = (domain: any) => { - setZoomedXDomain(domain); - }; - - return ( -
- - - - new Date(zeit).toLocaleDateString()} - /> - `${wert.toFixed(2)} kOhm`} - /> - } /> - - {/* Manuell definierte Legende mit der richtigen Reihenfolge */} - - - {/* Messwert Minimum als Linie */} - - - {/* Messwert Maximum als Linie */} - - - {/* Messwert Durchschnitt (nur in DIA1 & DIA2) */} - {(ausgewaehlterModus === "DIA1" || ausgewaehlterModus === "DIA2") && ( - - )} - - {/* Messwert als Punktdiagramm */} - {ausgewaehlterModus === "DIA0" && ( - - )} - - - -
- ); -}; - -export default LoopMeasurementChart; diff --git a/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart copy 3.tsx b/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart copy 3.tsx deleted file mode 100644 index 76b7d18..0000000 --- a/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart copy 3.tsx +++ /dev/null @@ -1,189 +0,0 @@ -"use client"; -import React from "react"; -import { useSelector, useDispatch } from "react-redux"; -import { RootState } from "../../../../../../redux/store"; -import { - setVonDatum, - setBisDatum, -} from "../../../../../../redux/slices/kabelueberwachungChartSlice"; -import { - ComposedChart, - XAxis, - YAxis, - CartesianGrid, - Tooltip, - Legend, - ResponsiveContainer, - Line, -} from "recharts"; - -// 📌 Benutzerdefinierter Tooltip für die richtige Anordnung der Werte -const CustomTooltip = ({ active, payload, label }: any) => { - if (active && payload && payload.length) { - const messwertMax = payload.find( - (p: any) => p.dataKey === "messwertMaximum" - ); - const messwert = payload.find((p: any) => p.dataKey === "messwert"); - const messwertMin = payload.find( - (p: any) => p.dataKey === "messwertMinimum" - ); - const messwertDurchschnitt = payload.find( - (p: any) => p.dataKey === "messwertDurchschnitt" - ); - - return ( -
- {new Date(label).toLocaleString()} -
- {messwertMax - ? `Messwert Maximum: ${messwertMax.value.toFixed(2)} kOhm` - : ""} -
-
- {messwert ? `Messwert: ${messwert.value.toFixed(2)} kOhm` : ""} - {messwertDurchschnitt - ? `Messwert Durchschnitt: ${messwertDurchschnitt.value.toFixed( - 2 - )} kOhm` - : ""} -
-
- {messwertMin - ? `Messwert Minimum: ${messwertMin.value.toFixed(2)} kOhm` - : ""} -
-
- ); - } - return null; -}; - -const LoopMeasurementChart = () => { - const littwinBlue = getComputedStyle( - document.documentElement - ).getPropertyValue("--littwin-blue"); - const dispatch = useDispatch(); - const istVollbild = useSelector( - (state: RootState) => state.kabelueberwachungChart.isFullScreen - ); - const { loopMeasurementCurveChartData, vonDatum, bisDatum } = useSelector( - (state: RootState) => state.kabelueberwachungChart - ); - const ausgewaehlterModus = useSelector( - (state: RootState) => state.kabelueberwachungChart.selectedMode - ); - - // 📌 Konvertiere Daten für den Chart & kehre Reihenfolge um - const formatierteDaten = loopMeasurementCurveChartData - .map((eintrag) => ({ - zeit: new Date(eintrag.t).getTime(), // Zeitstempel - messwertMinimum: eintrag.i, // Minimum (Tiefstwert) - messwertMaximum: eintrag.a, // Maximum (Höchstwert) - messwert: eintrag.m ?? null, // Aktueller Messwert - messwertDurchschnitt: - ausgewaehlterModus === "DIA1" || ausgewaehlterModus === "DIA2" - ? eintrag.g ?? null - : null, // Durchschnittswert nur in DIA1 & DIA2 - })) - .reverse(); // 🔄 Hier wird die Reihenfolge umgekehrt - - // Berechnung des minimalen Werts für Y-Achse - const minMesswert = Math.min( - ...loopMeasurementCurveChartData.map((entry) => entry.i) - ); - - return ( -
- - - - new Date(zeit).toLocaleDateString()} - /> - `${wert.toFixed(2)} kOhm`} - /> - } /> - - {/* 📌 Manuell definierte Legende mit der richtigen Reihenfolge */} - - - {/* Messwert Minimum als Linie */} - - - {/* Messwert Maximum als Linie */} - - - {/* Messwert Durchschnitt (nur in DIA1 & DIA2) */} - {(ausgewaehlterModus === "DIA1" || ausgewaehlterModus === "DIA2") && ( - - )} - - {/* Messwert als Punktdiagramm */} - {ausgewaehlterModus === "DIA0" && ( - - )} - - -
- ); -}; - -export default LoopMeasurementChart; diff --git a/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart copy.tsx b/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart copy.tsx deleted file mode 100644 index 58ef243..0000000 --- a/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart copy.tsx +++ /dev/null @@ -1,188 +0,0 @@ -"use client"; // components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart.tsx -import React, { useEffect, useRef, useState } from "react"; -import { useSelector, useDispatch } from "react-redux"; -import { RootState } from "../../../../../../redux/store"; -import Chart from "chart.js/auto"; -import "chartjs-adapter-moment"; -import { - setVonDatum, - setBisDatum, -} from "../../../../../../redux/slices/kabelueberwachungChartSlice"; - -const LoopMeasurementChart = () => { - const dispatch = useDispatch(); - const isFullScreen = useSelector( - (state: RootState) => state.kabelueberwachungChart.isFullScreen - ); - const { loopMeasurementCurveChartData, vonDatum, bisDatum } = useSelector( - (state: RootState) => state.kabelueberwachungChart - ); - const selectedMode = useSelector( - (state: RootState) => state.kabelueberwachungChart.selectedMode - ); - - const chartRef = useRef(null); - const chartInstance = useRef(null); - const [zoomPlugin, setZoomPlugin] = useState(null); - - useEffect(() => { - if (typeof window !== "undefined") { - import("chartjs-plugin-zoom").then((mod) => { - setZoomPlugin(mod.default); - Chart.register(mod.default); - }); - } - }, []); - - useEffect(() => { - if (chartRef.current) { - if (chartInstance.current) { - chartInstance.current.destroy(); - } - - console.log("Chart Data:", loopMeasurementCurveChartData); - console.log("Von Datum:", vonDatum, "Bis Datum:", bisDatum); - console.log("Selected Mode:", selectedMode); - - // Basis-Datasets für alle Datenpunkte - const datasets = [ - { - label: "Messwert Minimum ", - data: loopMeasurementCurveChartData.map((entry) => ({ - x: new Date(entry.t).getTime(), - y: entry.i, - })), - borderColor: "rgba(75, 192, 192, 1)", // Türkis - backgroundColor: "rgba(75, 192, 192, 0.2)", - fill: false, - }, - { - label: "Messwert Maximum ", - data: loopMeasurementCurveChartData.map((entry) => ({ - x: new Date(entry.t).getTime(), - y: entry.a, - })), - borderColor: "rgba(192, 75, 75, 1)", // Rot - backgroundColor: "rgba(192, 75, 75, 0.2)", - fill: false, - }, - ]; - - // Falls DIA0: `m` als aktueller Messwert verwenden - if ( - selectedMode === "DIA0" && - loopMeasurementCurveChartData.some((entry) => entry.m !== undefined) - ) { - datasets.push({ - label: "Messwert", - data: loopMeasurementCurveChartData.map((entry) => ({ - x: new Date(entry.t).getTime(), - y: entry.m ?? NaN, - })), - borderColor: "rgba(255, 165, 0, 1)", // Orange - backgroundColor: "rgba(255, 165, 0, 0.2)", - fill: false, - }); - } - - // Falls DIA1 oder DIA2: `g` als Durchschnittswert verwenden - if ( - (selectedMode === "DIA1" || selectedMode === "DIA2") && - loopMeasurementCurveChartData.some((entry) => entry.g !== undefined) - ) { - datasets.push({ - label: "Messwert Durchschnitt", // g als Durchschnittswert verwenden - data: loopMeasurementCurveChartData.map((entry) => ({ - x: new Date(entry.t).getTime(), - y: entry.g ?? NaN, - })), - borderColor: "rgba(75, 75, 192, 1)", // Blau - backgroundColor: "rgba(75, 75, 192, 0.2)", - fill: false, - }); - } - - const ctx = chartRef.current.getContext("2d"); - if (ctx) { - chartInstance.current = new Chart(ctx, { - type: "line", - data: { datasets }, - options: { - responsive: true, - maintainAspectRatio: false, - animation: false, - elements: { - line: { spanGaps: true }, - }, - scales: { - x: { - type: "time", - time: { - unit: "day", - tooltipFormat: "dd.MM.yyyy HH:mm", - displayFormats: { day: "dd.MM.yyyy" }, - }, - title: { display: true, text: "" }, // kann Zeit oder Datum eingefügt werden für X-Achse - min: new Date(vonDatum).getTime(), - max: new Date(bisDatum).getTime(), - }, - y: { - ticks: { - callback: (value) => - (typeof value === "number" ? value.toFixed(2) : value) + - " kOhm", - }, - }, - }, - plugins: { - tooltip: { - callbacks: { - label: (tooltipItem) => { - const rawItem = tooltipItem.raw as { x: number; y: number }; - return `${tooltipItem.dataset.label}: ${rawItem.y.toFixed( - 2 - )} kOhm`; - }, - }, - }, - zoom: { - pan: { enabled: true, mode: "xy" }, - zoom: { - wheel: { enabled: true }, - pinch: { enabled: true }, - mode: "xy", - onZoomComplete: (chart) => { - const xScale = chart.chart.scales.x; - const newVonDatum = new Date(xScale.min) - .toISOString() - .split("T")[0]; - const newBisDatum = new Date(xScale.max) - .toISOString() - .split("T")[0]; - - dispatch(setVonDatum(newVonDatum)); - dispatch(setBisDatum(newBisDatum)); - }, - }, - }, - }, - }, - }); - } - } - }, [loopMeasurementCurveChartData, vonDatum, bisDatum, selectedMode]); - - return ( -
- -
- ); -}; - -export default LoopMeasurementChart; diff --git a/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart.tsx b/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart.tsx index 8b1ea42..bf310f2 100644 --- a/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart.tsx +++ b/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart.tsx @@ -1,4 +1,4 @@ -"use client"; +"use client"; // components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart.tsx import React, { useCallback, useEffect, useMemo } from "react"; import { useSelector, useDispatch } from "react-redux"; import { RootState } from "../../../../../../redux/store"; @@ -15,56 +15,7 @@ import { } from "recharts"; import { setBrushRange } from "../../../../../../redux/slices/brushSlice"; -const CustomTooltip = ({ active, payload, label, unit }: any) => { - if (active && payload && payload.length) { - const messwertMax = payload.find( - (p: any) => p.dataKey === "messwertMaximum" - ); - const messwert = payload.find((p: any) => p.dataKey === "messwert"); - const messwertMin = payload.find( - (p: any) => p.dataKey === "messwertMinimum" - ); - const messwertDurchschnitt = payload.find( - (p: any) => p.dataKey === "messwertDurchschnitt" - ); - - return ( -
- {new Date(label).toLocaleString()} - {messwertMax && ( -
- Messwert Maximum: {messwertMax.value.toFixed(2)} {unit} -
- )} - {messwert && ( -
- Messwert: {messwert.value.toFixed(2)} {unit} -
- )} - {messwertDurchschnitt && ( -
{`Messwert Durchschnitt: ${messwertDurchschnitt.value.toFixed( - 2 - )} ${unit}`}
- )} - {messwertMin && ( -
{`Messwert Minimum: ${messwertMin.value.toFixed(2)} ${unit}`}
- )} -
- ); - } - return null; -}; +import CustomTooltip from "./CustomTooltip"; const LoopMeasurementChart = () => { const dispatch = useDispatch(); diff --git a/config/webVersion.ts b/config/webVersion.ts index efc278c..df1d166 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.134"; +const webVersion = "1.6.135"; export default webVersion; diff --git a/public/CPLmockData/kuesChartData/slot1/schleifenwiderstand/DIA0.json b/public/CPLmockData/kuesChartData/slot1/schleifenwiderstand/DIA0.json index dddabee..b972127 100644 --- a/public/CPLmockData/kuesChartData/slot1/schleifenwiderstand/DIA0.json +++ b/public/CPLmockData/kuesChartData/slot1/schleifenwiderstand/DIA0.json @@ -2470,5 +2470,10 @@ { "t": "2025-03-08 06:12:00", "m": 3.419, "v": 1, "i": 3.419, "a": 3.419 }, { "t": "2025-03-08 06:09:00", "m": 3.419, "v": 1, "i": 3.419, "a": 3.419 }, { "t": "2025-03-08 06:06:00", "m": 3.419, "v": 1, "i": 3.419, "a": 3.419 }, - { "t": "2025-01-01 06:03:00", "m": 3.419, "v": 1, "i": 3.419, "a": 3.419 } + { "t": "2025-01-01 06:03:00", "m": 3.419, "v": 1, "i": 3.419, "a": 3.419 }, + { "t": "2025-01-01 05:03:00", "m": 3.419, "v": 1, "i": 3.419, "a": 3.419 }, + { "t": "2025-01-01 04:03:00", "m": 3.419, "v": 1, "i": 3.419, "a": 3.419 }, + { "t": "2025-01-01 03:03:00", "m": 3.419, "v": 1, "i": 3.419, "a": 3.419 }, + { "t": "2025-01-01 02:03:00", "m": 3.419, "v": 1, "i": 3.419, "a": 3.419 }, + { "t": "2025-01-01 01:03:00", "m": 3.419, "v": 1, "i": 3.419, "a": 3.419 } ]