Skip to content
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

Closed
wants to merge 3 commits into from
Closed

Conversation

teamdandelion
Copy link
Contributor

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.

@jtlan
Copy link
Contributor

jtlan commented Sep 24, 2015

@danmane,

I like the idea here, but I worry it might be a bit too narrowly scoped:

  • What if the user wants this effect, but only in X or Y?
  • What if the user doesn't want double-click to unzoom?

A more modular implementation might be to have a domain-setter on QuantitativeScale that allows passing in an easing function and duration:

scale.domain(newDomain, easingFunction, duration);

Calling this function in the onDragEnd() callback of a DragBoxLayer could provide the smooth zoom-in behavior. As an added bonus, it could be used with XDragBoxLayer, YDragBoxLayer, and anywhere else a user might want to smoothly transition the domain.

Let us know if you want some help implementing this.

@teamdandelion
Copy link
Contributor Author

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...)

@crmorford
Copy link
Contributor

Hey @danmane,
Just checking in on status -- are you working on this PR, or waiting on us to approve something? I think we only want changes to scales.domain() at this point; the discussion about -core and -koans belongs somewhere else.

Would you like to implement the changes to .domain()? Or should we try to schedule it?

@teamdandelion
Copy link
Contributor Author

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.

@CalvinFernandez
Copy link
Contributor

@danmane landing further changes here #3136 . Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants