vega-lite icon indicating copy to clipboard operation
vega-lite copied to clipboard

Add box-based zoom support for interval selections.

Open tweeter0830 opened this issue 5 years ago • 24 comments

I spend a lot of time looking at engineering time-series data.

I currently use bokeh for this, but I would love to switch to vega/vega-lite/altair.

However, I'm hesitant to switch because vega appears to be missing a box-zoom feature. This feature is incredibly useful for exploratory time-series plotting/analysis.

As an example, my data often looks like a more complex version of this bokeh example.

There may be many phenomenon of different x/y axis scales which get manifested in time-series data and being able to change the zoom level/aspect ratio is incredibly useful.

Basically, I would love to see Bokeh's BoxZoomTool (as enabled in the box_annotaion example above) in vega/vega-lite/altair.

tweeter0830 avatar Mar 20 '19 18:03 tweeter0830

Thanks for posting! The good news is that what you describe is already expressible within Vega. Here is a modified zoomable scatterplot example. You can shift-drag to create a zoom region, and when you release the mouse button the view will snap to the new scale extents. You can also double click to restore the chart to the initial configuration. Note that this works alongside standard drag-pan and scroll-zoom interactions. Or, here is the same example within an Observable notebook: https://observablehq.com/@vega/vega-interactive-scatter-plot

The less good news is that I don't think this is currently expressible in Vega-Lite / Altair. However, I could imagine extensions to the interval selection logic that would change that. So, I'm going to rename this issue and transfer it over to the Vega-Lite repo for folks to look at there!

jheer avatar Mar 20 '19 18:03 jheer

Oh cool! It's good to know that this is one step closer to being in Altair. Thanks for moving the bug over.

tweeter0830 avatar Mar 20 '19 21:03 tweeter0830

This feature would be great.

pramitchoudhary avatar May 06 '20 01:05 pramitchoudhary

@allenjlee are you working on this? If not, let's unassign you.

domoritz avatar May 06 '20 03:05 domoritz

Is there any alternative to getting interactive zooming of arbitrary regions of a plot working with vega-lite?

robsmith11 avatar May 08 '21 04:05 robsmith11

Is there any development on this yet? Thanks!

Episkiliski avatar Feb 01 '22 08:02 Episkiliski

No updates yet, unfortunately. Sorry.

arvind avatar Feb 01 '22 14:02 arvind

Is there any plan for this? Or is it just in the backlog with no plans at the moment? Thanks!

Episkiliski avatar Feb 01 '22 21:02 Episkiliski

It's in the backlog but I think @kanitw wanted to address this issue so it's higher up in the queue. He can comment on the timing.

If this is not urgent, we should remove the P1.

domoritz avatar Feb 01 '22 22:02 domoritz

It would be great and I understand many folks are waiting for this feature too. Having the hability to box-zoom is sometimes a must for some data exploration. So yeah, I'm really looking forward to this...

Episkiliski avatar Feb 03 '22 21:02 Episkiliski

I'm looking forward to this too, if it's possible with Vega-lite. Thanks !

bendasse avatar Feb 28 '22 15:02 bendasse

I'm also really looking forward to this feature. If there is any way I can help with this, let me know

krokosik avatar Jun 02 '22 23:06 krokosik

Not quite the real thing, but a workaround is to zoom x- and y-axis independently via Selection projection and event filters depending on whether the shift key is held:

(in Altair)

selection_x = alt.selection_interval(
    bind='scales',
    encodings=["x"],
    zoom="wheel![!event.shiftKey]",
)
selection_y = alt.selection_interval(
    bind='scales',
    encodings=["y"],
    zoom="wheel![event.shiftKey]",
)
chart = (alt.Chart(...)
    ...
    .add_selection(selection_x)
    .add_selection(selection_y)
)

(in vega-lite)

{
  ...
  "selection": {
    "selectorx": {
      "bind": "scales",
      "encodings": [
        "x"
      ],
      "type": "interval",
      "zoom": "wheel![!event.shiftKey]"
    },
    "selectory": {
      "bind": "scales",
      "encodings": [
        "y"
      ],
      "type": "interval",
      "zoom": "wheel![event.shiftKey]"
    }
  },
}

wisp3rwind avatar Sep 02 '22 12:09 wisp3rwind

Is there any development regarding this feature? I honestly can't wait to have it....

Episkiliski avatar Jan 11 '24 09:01 Episkiliski

The lack of this feature is holding Altair back compared to plotly, bokeh, etc

samimia-swks avatar Mar 06 '24 19:03 samimia-swks