plot icon indicating copy to clipboard operation
plot copied to clipboard

zoom interaction

Open Fil opened this issue 2 years ago • 0 comments

zoom is a new top-level option, values "xy", "x", "y". (first pass at #1590)

  • A mark has a zoom() method, which allows it to act when the chart receives a zoom event.
  • The default zoom method puts all the node’s contents into a new g and applies the zoom transform to that g.
  • The zoom method on the axis marks computes ticks for the rescaled scale. for the tick label it is set to null.
  • The zoom method on the dot mark rescales the dots by sqrt(k) instead of k, making it easy to “declutter by zooming”

Things that don't work yet, but I foresee no blocker:

  • [ ] pointing (still points to the unzoomed positions)
  • [ ] facets
  • [ ] fixed ticks, tickFormat
  • [ ] adaptive pointRadius for the geo mark
  • [ ] the image mark when applying a zoom:"x" gets squished
  • [ ] zoomExtent defaults and more generally, zoom configuration
  • [ ] clipping (cf. armadillo)

Things that seem more difficult—maybe not necessary in the first version:

  • [ ] zooming categorical scales
  • [ ] re-running initializers (say, if we wanted a hexbin that maintains an unzoomed grid)
  • [ ] re-running render (e.g. for the raster mark to still raster the frame but with different bounds, useful for say, the julia set)
  • [ ] adaptive rendering (say, to change a map's precision during rendering and depending on the scaling factor)

(Maybe an option could be to re-render everything, but with zoomed scales—maybe just by manipulating insets or whatever is needed—this would help cover a lot of the difficult cases, but it would certainly be inefficient.)

To make tests easier zoom is considered true everywhere ("xy")—this helps to surface all the cases where it doesn't work (or fails in a funny way).

https://github.com/observablehq/plot/assets/7001/c273688c-02ae-4222-b669-d0acbf5b7399

Fil avatar Jul 07 '23 10:07 Fil