mathisonian / d3-multiaxis-zoom

d3 plugin to zoom along multiple axes independently
MIT License
15 stars 1 forks source link

Zoom across X or Y axes but not both #1

Closed arjain closed 9 years ago

arjain commented 9 years ago

I want to disable zooming across both the axes together. So, say default behavior will be to only zoom across X axes and Meta + zoom zooms only along the Y axis. Do you how can I do this?

mathisonian commented 9 years ago

Hey @arjain

the relevant code is here - you could fork and update or else I'd be willing to accept a PR to support more user controlled options.

It'd look something like:

    if (d3.event.altKey) {
     // only Y axis on meta
      scaleTo(view.kx, Math.pow(2, d3_behavior_zoomDelta() * .002));
    } else if (d3.event.ctrlKey) {
      // no special case for control so zoom along X-axis
      scaleTo(Math.pow(2, d3_behavior_zoomDelta() * .002) *  view.kx, view.ky);
    } else {
      // default - only X axis
      scaleTo(Math.pow(2, d3_behavior_zoomDelta() * .002) *  view.kx, view.ky);
    }
arjain commented 9 years ago

Thanks for the reply! That's exactly what I ended up doing.