uPlot
uPlot copied to clipboard
After continuous magnification, the coordinate axis becomes the same
Is there any way to limit the magnification, such as limiting the magnification multiple, or when the selected range is less than a certain value, it is not allowed to enlarge.
I try to set scale and set range for each coordinate axis. As in the example, unfortunately, only the x-axis setting takes effect, but the y-axis does not take effect, and the function does not seem to be called. My option:
{
cursor: {
drag: { x: true, y: true, uni: 10, dist: 5 },
},
scales: {
x: {
time: false,
min: xRange[0],
max: xRange[1],
range: (self, newMin, newMax) => {
let curMin = self.scales.x.min;
let curMax = self.scales.x.max;
// prevent zoom
if (newMax - newMin < 10) return [curMin, curMax];
// allow zoom
return [newMin, newMax];
},
},
y: {
time: false,
min: yRange[0],
max: yRange[1],
range: (self, newMin, newMax) => {
let curMin = self.scales.y.min;
let curMax = self.scales.y.max;
// prevent zoom
if (newMax - newMin < 5) return [curMin, curMax];
// allow zoom
return [newMin, newMax];
},
},
},
}
My version of uplot is 1.6.13. Thank you very much for your work. This library is very cool.
this seems to work as expected for me:
https://jsfiddle.net/r1vcL90n/
Thanks for your reply, I modified your code slightly to allow selection zoom in both x and y directions: link, unfortunately, when I keep doing selection zoom on the canvas, x The axis will be fixed and the y-axis will keep changing until all numbers are the same. I just modified this part:
cursor: {
drag: { x: true, y: true, uni: 4, dist: 2 },
}