如何在vega-lite中添加参考线?

时间:2016-11-21 06:42:45

标签: vega vega-lite

我有一个时间序列图(简单的折线图),我想在图表中添加一条或多条参考线,它们将表示为边界(类似于SPC图表,最小值和最大值以及平均值)。

Vega-Lite有可能吗?

感谢。

指向我的图表的链接: EGV data from 5 different sensors for one day

1 个答案:

答案 0 :(得分:3)

不幸的是还没有。但我们正在研究Vega-Lite 2.0并支持分层。有关详细信息,请参阅我们在http://idl.cs.washington.edu/papers/vega-lite/的研究论文。

我们有初步的(没有记录,可能会在Vega-Lite 2中打破)对分层的支持。

{
  "data": {
    "values": [
      {"x": 1,"y": 2},
      {"x": 2,"y": 4},
      {"x": 3,"y": 5},
      {"x": 4,"y": 3},
      {"x": 5,"y": 4}
    ]
  },
  "layers": [
    {
      "encoding": {
        "x": {"type": "ordinal","field": "x"},
        "y": {"type": "quantitative","field": "y"}
      },
      "mark": "line",
      "config": {"mark": {"color": "#1f77b4"}}
    },
    {
      "encoding": {
        "y": {"type": "quantitative","field": "y", "aggregate": "mean"}
      },
      "mark": "rule",
      "config": {"mark": {"color": "#ff7f0e"}}
    }
  ]
}

chart

相关问题