Search code examples
powerbivisualizationpowerbi-desktopvega-litedeneb

Y/X-Axis Zoom Slider in Deneb Vega Lite?


In Deneb vega-lite I am looking for the ability to zoom slide on the y-axis and x-axis as you would a native Power BI line chart.

Here is the template i used.

Ideally, would like these sliders to sit respective to the y-axis and x-axis like the native visual is

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "description": "Stock prices of 5 Tech Companies over Time.",
  "data": {"url": "data/stocks.csv"},
  "mark": "line",
  "encoding": {
    "x": {"field": "date", "type": "temporal"},
    "y": {"field": "price", "type": "quantitative"},
    "color": {"field": "symbol", "type": "nominal"}
  }
}

Solution

  • This code pans and zooms.

    {
      "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
      "description": "Stock prices of 5 Tech Companies over Time.",
      "data": {"url": "data/stocks.csv"},
      "mark": "line",
      "encoding": {
        "x": {"field": "date", "type": "temporal"},
        "y": {"field": "price", "type": "quantitative"},
        "color": {"field": "symbol", "type": "nominal"}
      },
      "params": [{
        "name": "grid",
        "select": "interval",
        "bind": "scales"
      }],
    }