0
votes

In Scale Domains docs of Vega-Lite it is noted:

An alternate way to construct this technique would be to filter out
the input data to the top (detail) view like so:

{
  "vconcat": [{
    "transform": [{"filter": {"selection": "brush"}}],
    ...
  }]
}

Which is indeed almost the same (although filter method being much slower, as noted in the docs), except for one difference:

  • With filter-selection method (demo), the y-axis of the upper chart will be automatically zoomed in to the selected points. This is pretty neat, especially if you have large amount of points.
  • With scale-domain method (demo), the y-axis remains frozen as you move the selection around.

The question: is it possible to have the y-axis automatically zoom in to the selected points as you move the selection, with "scale domain" method (same as it does with filter-selection method)?

Why is the above difference important? Imagine a stock price that has been increasing on average by a total of $1 every day last year (but within a particular day it may have experinced any kind of volatile behaviour) and we're plotting it with line marks. If you plot the entire year, you see the whole picture. If you zoom in on a particular day without resetting your y-axis zoom, however, your intraday price plot will be just a flat line, or close to that.

// I've checked all scale-domain-related issues on vega-lite, on altair repo and SO and couldn't find anything related; I've also posted this question on vega-lite repo on GH, but was forwarded over to SO.

1

1 Answers

0
votes

No. Unless otherwise specified, the y scale is determined from all of the data within the plot.

When you filter the data, the data in the plot changes, which causes the y axis to change. When you change the scale based on an x-selection without filtering the data, it does not change the data in the plot, and so the y scale remains constant.

If you want the y-scale to be determined automatically based on the data within the selection, the only option is to filter on that selection.