Remeber original axis limit instead of trying to calculate it

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2023-11-07 06:43:41 +01:00
parent 80971905c4
commit 59809d9959
+3 -3
View File
@@ -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