Skip to content

Commit

Permalink
Adjust onZoom callback to not trigger on chart.zoomScale introduced i…
Browse files Browse the repository at this point in the history
…n v2.1.0 of the chartjs zoom plugin

Signed-off-by: yubiuser <[email protected]>
  • Loading branch information
yubiuser committed Nov 27, 2024
1 parent 4a7d847 commit 4277311
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion scripts/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4277311

Please sign in to comment.