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
Add DragZoomLayer #2796
Add DragZoomLayer #2796
Conversation
I like the idea here, but I worry it might be a bit too narrowly scoped:
A more modular implementation might be to have a domain-setter on scale.domain(newDomain, easingFunction, duration); Calling this function in the Let us know if you want some help implementing this. |
Yes, that does seem like a good API point to have (probably can be useful in other contexts as well). Re: whether this is too narrowly scoped: I agree it is pretty specific to a particular usecase. I feel that having this code exist in public is still useful though, so that Plottable is a bit more "batteries included" with the ability to just do basic charting-type tasks (eg crosshairs, zooming) in a sane configuration without needing to think about XYDragBoxLayers vs XDragBoxLayers and DragEnd callbacks and so forth. Obviously I love the customizability and that this flexibility exists, but it might be nice to provide a path to simplicity for those who want it. Maybe one way to tackle this would be to break out repositories, plottable-core and plottable-koans or something, where plottable-koans contains pieces like DragZoomLayer that are a bit narrower in scope but are both useful pieces of code in their own right, and provide examples of how you can use the pieces provided by plottable-core. Or you could imagine going more modular still and encouraging people to publish this kind of code to bower and keep a registry of "plottable modules" (although now you start to have severe versioning issues if you're ever breaking backcompat, not sure if you are...) |
Hey @danmane, Would you like to implement the changes to .domain()? Or should we try to schedule it? |
Sorry, I probably won't have time to pay attention to this for a few weeks. If you can take over putting in the domain change that would be great. |
DragZoomLayer creates a SelectionBox that powers a drag-to-zoom interaction. When you drag a box, the scales zoom into the bounds drawn out in that box and the box disappears. The zoom can be animated over a variable amount of time (default 750ms) with a custom easing function (default d3.cubic-in-out). Tests included.