From 2d166a204baf3bb99075729ed632582b5b3deacb Mon Sep 17 00:00:00 2001 From: ISA Date: Tue, 22 Jul 2025 10:58:01 +0200 Subject: [PATCH] Fix: Preserve chart state during zoom, pan, and date changes - Added React.useMemo to memoize chartData and chartOptions to prevent unnecessary re-renders. - Ensured chart zoom and pan states are maintained during interactions. - Improved performance and user experience by avoiding chart --- .env.development | 2 +- .env.production | 2 +- .eslintrc.json | 15 +++++++++++---- CHANGELOG.md | 9 +++++++++ .../main/analogInputs/AnalogInputsChart.tsx | 14 ++++++++++++-- package-lock.json | 4 ++-- package.json | 2 +- 7 files changed, 37 insertions(+), 11 deletions(-) diff --git a/.env.development b/.env.development index 00b9b70..61c5514 100644 --- a/.env.development +++ b/.env.development @@ -6,6 +6,6 @@ NEXT_PUBLIC_USE_MOCK_BACKEND_LOOP_START=false NEXT_PUBLIC_EXPORT_STATIC=false NEXT_PUBLIC_USE_CGI=false # App-Versionsnummer -NEXT_PUBLIC_APP_VERSION=1.6.628 +NEXT_PUBLIC_APP_VERSION=1.6.629 NEXT_PUBLIC_CPL_MODE=json # json (Entwicklungsumgebung) oder jsSimulatedProd (CPL ->CGI-Interface-Simulator) oder production (CPL-> CGI-Interface Platzhalter) diff --git a/.env.production b/.env.production index 48267eb..0220728 100644 --- a/.env.production +++ b/.env.production @@ -5,5 +5,5 @@ NEXT_PUBLIC_CPL_API_PATH=/CPL NEXT_PUBLIC_EXPORT_STATIC=true NEXT_PUBLIC_USE_CGI=true # App-Versionsnummer -NEXT_PUBLIC_APP_VERSION=1.6.628 +NEXT_PUBLIC_APP_VERSION=1.6.629 NEXT_PUBLIC_CPL_MODE=production \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json index 69eb954..ac8aea4 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -14,15 +14,22 @@ "jsx": true } }, + "env": { + "browser": true, + "node": true, + "es2021": true + }, + "globals": { + "JSX": "readonly", + "NodeJS": "readonly" + }, "rules": { - // ✅ wirklich gefährliche Fehler - "no-undef": "error", + "no-undef": "off", "no-unreachable": "error", - - // ✅ alles andere nur als Warnung "@typescript-eslint/no-explicit-any": "warn", "@typescript-eslint/no-unused-vars": "warn", "react-hooks/exhaustive-deps": "warn", + "react/react-in-jsx-scope": "off", "@next/next/no-img-element": "warn", "react/no-unescaped-entities": "warn" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 80424da..7b8b694 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## [1.6.629] – 2025-07-22 + +- Fix: Preserve chart state during zoom, pan, and date changes + +- Added React.useMemo to memoize chartData and chartOptions to prevent unnecessary re-renders. +- Ensured chart zoom and pan states are maintained during interactions. +- Improved performance and user experience by avoiding chart + +--- ## [1.6.628] – 2025-07-22 - Fix: Preserve chart state during zoom, pan, and date changes diff --git a/components/main/analogInputs/AnalogInputsChart.tsx b/components/main/analogInputs/AnalogInputsChart.tsx index 4c1296e..4d59303 100644 --- a/components/main/analogInputs/AnalogInputsChart.tsx +++ b/components/main/analogInputs/AnalogInputsChart.tsx @@ -3,7 +3,7 @@ import React, { useEffect, useRef } from "react"; import { useDispatch, useSelector } from "react-redux"; import { RootState, AppDispatch } from "@/redux/store"; -import { Line, ChartJSOrUndefined } from "react-chartjs-2"; +import { Line } from "react-chartjs-2"; import { Chart as ChartJS, LineElement, @@ -42,8 +42,18 @@ ChartJS.register( ); export default function AnalogInputsChart() { + useEffect(() => { + if (typeof window !== "undefined") { + import("chartjs-plugin-zoom").then((zoom) => { + if (!ChartJS.registry.plugins.get("zoom")) { + ChartJS.register(zoom.default); + } + }); + } + }, []); + const dispatch = useDispatch(); - const chartRef = useRef | null>(null); + const chartRef = useRef(null); // Redux Werte für Chart-Daten const { zeitraum, vonDatum, bisDatum, data, autoLoad, selectedId } = diff --git a/package-lock.json b/package-lock.json index 4d0edee..45cbb1c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cpl-v4", - "version": "1.6.628", + "version": "1.6.629", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "cpl-v4", - "version": "1.6.628", + "version": "1.6.629", "dependencies": { "@fontsource/roboto": "^5.1.0", "@headlessui/react": "^2.2.4", diff --git a/package.json b/package.json index 2f51717..778b0ca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cpl-v4", - "version": "1.6.628", + "version": "1.6.629", "private": true, "scripts": { "dev": "next dev",