Adjust onZoom callback to not trigger on chart.zoomScale introduced in v2.1.0 of the chartjs zoom plugin

Signed-off-by: yubiuser <github@yubiuser.dev>
This commit is contained in:
yubiuser
2024-11-27 22:12:46 +01:00
parent 4a7d8479b5
commit 4277311bc7

View File

@@ -515,7 +515,12 @@ $(function () {
enabled: true,
},
mode: "y",
onZoom: function ({ chart }) {
onZoom: function ({ chart, trigger }) {
if (trigger === "api") {
// Ignore onZoom triggered by the chart.zoomScale api call below
return;
}
// The first time the chart is zoomed, save the maximum initial scale bound
if (!chart.absMax) chart.absMax = chart.getInitialScaleBounds().y.max;
// Calculate the maximum value to be shown for the current zoom level