From d9314c7bb235a8dfab04984f5eb4de2df80e683d Mon Sep 17 00:00:00 2001 From: ISA Date: Wed, 7 May 2025 15:30:03 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20LoopMeasurementChart=20zeigt=20Stunden?= =?UTF-8?q?=20bei=201=E2=80=932=20Tagen,=20sonst=20Tagesansicht=20in=20X-A?= =?UTF-8?q?chse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LoopMeasurementChart.tsx | 18 +++++++++++++----- config/webVersion.ts | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart.tsx b/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart.tsx index d336481..994f780 100644 --- a/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart.tsx +++ b/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart.tsx @@ -17,6 +17,7 @@ import { import "chartjs-adapter-date-fns"; import { de } from "date-fns/locale"; +import { differenceInHours, parseISO } from "date-fns"; ChartJS.register( LineElement, @@ -30,6 +31,7 @@ ChartJS.register( ); import { getColor } from "../../../../../../utils/colors"; import { PulseLoader } from "react-spinners"; + const usePreviousData = (data: any[]) => { const ref = useRef([]); useEffect(() => { @@ -48,6 +50,8 @@ const LoopMeasurementChart = () => { unit, isFullScreen, isLoading, + vonDatum, + bisDatum, } = useSelector((state: RootState) => state.kabelueberwachungChartSlice); const previousData = usePreviousData(loopMeasurementCurveChartData); @@ -69,6 +73,12 @@ const LoopMeasurementChart = () => { return true; }; + // ⏱ Zeitspanne in Stunden berechnen + const from = vonDatum ? parseISO(vonDatum) : null; + const to = bisDatum ? parseISO(bisDatum) : null; + const durationInHours = from && to ? differenceInHours(to, from) : 9999; + const timeUnit = durationInHours <= 48 ? "hour" : "day"; + useEffect(() => { import("chartjs-plugin-zoom").then((zoomPlugin) => { if (!ChartJS.registry.plugins.get("zoom")) { @@ -146,7 +156,7 @@ const LoopMeasurementChart = () => { plugins: { legend: { position: "top" as const }, tooltip: { - yAlign: "bottom" as const, // ← explizit casten + yAlign: "bottom" as const, mode: "index" as const, intersect: false, }, @@ -163,10 +173,9 @@ const LoopMeasurementChart = () => { x: { type: "time" as const, time: { - unit: "minute" as const, + unit: timeUnit as const, tooltipFormat: "dd.MM.yyyy HH:mm:ss", displayFormats: { - minute: "HH:mm", hour: "HH:mm", day: "dd.MM.", }, @@ -174,7 +183,6 @@ const LoopMeasurementChart = () => { }, title: { display: true, text: "Zeit" }, }, - y: { title: { display: true, text: unit }, ticks: { precision: 0 }, @@ -188,7 +196,7 @@ const LoopMeasurementChart = () => { options, }); }); - }, [loopMeasurementCurveChartData, selectedMode]); + }, [loopMeasurementCurveChartData, selectedMode, vonDatum, bisDatum]); return (
diff --git a/config/webVersion.ts b/config/webVersion.ts index 3d3cb14..3b39881 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.392"; +const webVersion = "1.6.393"; export default webVersion;