In chart.js v3 data decimation doesn't work when zooming in via the zoom plugin.
Initially at 100%, data decimation works, but if I zoom in it's no longer working (i.e. shows all points)
If I zoom out to 100% again then data decimation works again.
Any ideas on how to fix this? Do I need to call something to trigger data decimation after a zoom event?
I suspect that it works in fact correctly.
Code sample before some possible explaination:
It was due to a modification that was proposed a while ago: the idea was to re-perform decimation each time you zoom in order to have the "highest resolution" possible (for history: https://github.com/chartjs/Chart.js/issues/8833)
But the thing that you probably missed (I suppose) are the following properties of the decimation plugin (https://www.chartjs.org/docs/master/configuration/decimation.html#configuration-options):
And the "problem" is probably the default values of each of these:
Meaning that for a 800px graph, you will have 800 points, and decimation will happen only if you have more than 800*4 points on the current range.
So what I suppose is happening: you have let say 1000 points that you display on a 200px graph. At first everything is ok, but once you zoom, you have 750 points, which will be less than 200*4, so decimation won't happen and you will have in fact 750 points (while you would expect 200)
In the end, you might want to update your decimation plugin configuration with something like: