From 59809d99597b733c07efdaf12017feb68019f450 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 7 Nov 2023 06:43:41 +0100 Subject: [PATCH] Remeber original axis limit instead of trying to calculate it Signed-off-by: DL6ER --- scripts/pi-hole/js/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index b8a91267..2cc985d9 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -432,10 +432,10 @@ $(function () { }, mode: "y", onZoom: function ({ chart }) { - // Get absolute maximum from all datasets - const absMax = Math.max(...chart.data.datasets.map(dataset => Math.max(...dataset.data))); + // The first time the chart is zoomed, save the absolute maximum value + if (!chart.absMax) chart.absMax = chart.scales.y.max; // Calculate the maximum value to be shown for the current zoom level - const zoomMax = absMax / chart.getZoomLevel(); + const zoomMax = chart.absMax / chart.getZoomLevel(); // Update the y axis scale chart.zoomScale("y", { min: 0, max: zoomMax }, "default"); // Update the y axis ticks and round values to natural numbers