Y/X 轴缩放滑块?

问题描述 投票:0回答:1

在 Deneb vega-lite 中,我正在寻找在 y 轴和 x 轴上缩放幻灯片的功能,就像本地 Power BI 折线图一样。

这是我使用的模板。

理想情况下,希望这些滑块像原生视觉效果一样分别位于 y 轴和 x 轴

{
  "$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"}
  }
}
powerbi visualization powerbi-desktop vega-lite deneb
1个回答
0
投票

此代码可平移和缩放。

{
  "$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"
  }],
}
© www.soinside.com 2019 - 2024. All rights reserved.