diff --git a/scripts/js/index.js b/scripts/js/index.js index a68648c07..d5ec1125d 100644 --- a/scripts/js/index.js +++ b/scripts/js/index.js @@ -515,8 +515,13 @@ $(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 const zoomMax = chart.absMax / chart.getZoomLevel();