d3 / d3-zoom

Pan and zoom SVG, HTML or Canvas using mouse or touch input.
https://d3js.org/d3-zoom
ISC License
507 stars 143 forks source link

Ability to set X & Y transform scale #48

Closed joshuahiggins closed 4 years ago

joshuahiggins commented 8 years ago

With zoom.x() and zoom.y() removed, there doesn't appear to be an elegant way to zoom a single axis while leaving the opposite axis's domain untouched.

I'd like to propose the idea of extending the transform methods to support 1 or 2 scales, replacing the single k value with kx and ky values and extending the transform.scale method to accept an optional second parameter. By default, when called with a single parameter, kx and ky would be assigned with the same scale, resulting in the same functionality as today. However, users would have more control over their transforms through the added ability to compress and expand axises as needed.

I'm happy to work on this functionality but wanted to get a feel for it's perceived viability before I dove in.

ricardomatias commented 2 years ago

Please re-open this issue and provide an API for it via a .scaleFactor as shown in https://github.com/wiremind/d3-xyzoom, f.ex. 5-years later this is still a perfect common problem that needs addressing.