<canvas id="ctx">
<script type="module">
import { Chart, LinearScale, PointElement, ScatterController } from "https://esm.sh/chart.js@4.5.1";
import zoomPlugin from "https://esm.sh/chartjs-plugin-zoom@2.2.0";
Chart.register(LinearScale, PointElement, ScatterController, zoomPlugin);
const chart = new Chart(ctx, {
type: "scatter",
data: {
datasets: [{
data: [...Array(10000).keys()].map(() => ({ x: Math.random(), y: Math.random() })),
}],
},
options: { plugins: { zoom: { zoom: { wheel: { enabled: true } } } } },
});
</script>
Two problems with the
wheelevent handler compound to make zooming completely uncontrollable on a touchpad with high-resolution scrolling, which emitswheelevents with smalldeltaYat a high frequency:deltaModeand the magnitude ofdeltaY: it only takes the sign into account. So the high event frequency leads to much more zooming than the user intended.chartjs-plugin-zoom/src/handlers.js
Lines 246 to 247 in 4aa6d11
requestAnimationFramecallback. If the redraw is even just a little slower than the time between events, a backlog of events builds up in the queue, and the chart lags farther and farther behind real time.chartjs-plugin-zoom/src/handlers.js
Line 257 in 4aa6d11
Reproduction
https://jsfiddle.net/anderskaseorg/ezy5guf2/