uPlot
uPlot copied to clipboard
How to synchronize mouse wheel zoom/drag with zoom ranger
https://jsfiddle.net/3r5ap0kd/5/ here I combined two demos, https://leeoniya.github.io/uPlot/demos/zoom-ranger.html and https://leeoniya.github.io/uPlot/demos/zoom-wheel.html
Currently, the mouse wheel operations are not synced with zoom ranger. How could synchronization like this be achieved?
change the x clamping to use uRanger's min/max:
[nxMin, nxMax] = clamp(nxRange, nxMin, nxMax, uRanger.scales.x.max - uRanger.scales.x.min, uRanger.scales.x.min, uRanger.scales.x.max);
and something like this after u.batch(...):
uRanger.setSelect({
left: uRanger.valToPos(nxMin, 'x'),
width: uRanger.valToPos(nxMax, 'x'),
});
https://jsfiddle.net/zsvebgj5/
hopefully you can finish/fix the rest ;)