-
-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto X / Y Zoom #219
Comments
A while ago I threw together a quick proof of concept while evaluating AM charts, so this kind of shows what I mean interactively (but doesn't work super great). |
dygraphs has something like this too (try on the home page): http://dygraphs.com/ except it only flips between either x or y but never both. from the amcharts codepen, i think having all 3 variants causes too much UI flashing during the selection...and you dont really save that much time over just doing an x zoom followed by a y zoom. i might be open to having the dygraphs style if it doesn't add too much code or option complexity. i don't think we need to go as far as adding thresholds but just use whichever is greater of dx or dy to toggle between x or y scale. that means another option, e.g.
that being said, if what you need is the 3-variant flavor, having the 2-variant in the core won't help you much - you'll probably need to make a plugin that implements all the selection logic. |
So doing it both ways is fairly straightforward if it works for you. Basically instead of setting omni to a boolean I used a number:
|
not bad, actually. except that the PR breaks unidirectional zooming 🤣 |
🤦 Maybe the next thing to look at is #72 |
that's a one large can of worms, my friend. even #175 wouldn't have saved you in this case. |
Okay new push should solve it. I was only test uni on the non omni charts! Relatively simple fix this go around. |
if we're gonna do the threshold thing, the API has to change.
we'll need 2 explicit opts. or something else. i havent thought this through too hard. suggestions welcome. |
I guess the hard part is differentiating between omni as in the x/y window (how it is today) and omni as in the dygraph example. I took "omni" to mean "dygraph" style (so that Maybe omni is the wrong terminology? Regardless, setting two params works for me so I can get that part done. |
Okay, that's done.
Doing it this way was kind of interesting, because you could say that a threshold of 0 would be equivalent to the window style (how it is today). I'm starting to think that the dygraph style is the edge case So if you want we could dump the |
the original intent is that x only (unidirectional, default): x: true y only (unidirectional): x: false x & y (omnidirectional): x: true dygraphs (unidirectional up to 1e9, effectively Infinity): x: true your needed case (unidirectional up to 35, otherwise omnidirectional): x: true the last two options now share the same uni testing logic. when x: true, y: true, all unidirectional behavior will use the larger of dx or dy to determine the direction. this feels pretty good to me; i can explain it without too many mental gymnastics. thoughts? |
Yep that makes sense to me |
If uni is set should we infer that x and y must be true? |
yeah, should make the code cleaner. |
also, let's include all the above variants in a single demo. in least to most complex order. |
Done. The way I got it to work was by saying that if we are in the burgundy square then use the dygraph way. In my original use case I would have made that zoom omni, but when you have a small enough threshold I think it should work for my users. Since a uni of infinity means that the whole chart is basically the burgundy square, all works as expected. The variations also show that setting uni to 0 == omni which I think is logical. But the value is set to null instead of default 0 so that we can skip computations if the user didn't specify uni. |
nice. seems to work well. final tweaks:
|
Done! |
awesome! https://leeoniya.github.io/uPlot/demos/zoom-variations.html thanks for doing the good work and sticking through my nagging :) i'm gonna do a couple follow-ups to add it to the demos index and add comments to the typings file about how |
did some minor refactoring tweaks here: 188e521#diff-0e94ed30087b62b2ab95466722c48f84 i swapped dx/dy distance testing to give dragX precedence when dx == dy. otherwise everything should still be logically equivalent 🤞. |
i found a small bug (fixed by 0895041) when the uni-directional zooming is done along x, the y failed to autoscale within the zoomed x range because the mouseup handler only inspected the i hoisted the vars up into a cache, next to |
Reference drawing:
Say you are trying to zoom from the point Mo.
What I'd like to do:
Hopefully that explanation makes sense!
Is this something that should be done via a plugin or would you consider it being part of the lib?
Thanks.
The text was updated successfully, but these errors were encountered: