简体   繁体   English

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

[英]How to add reference lines in vega-lite?

I have a time series graphs (simple line graphs) and I want to add one or more reference lines to the graph that will denote as boundaries (something like the SPC Charts, minimum and maximum and the average). 我有一个时间序列图(简单的线图),我想在该图上添加一条或多条参考线,这些线将表示为边界(类似于SPC图表,最小和最大以及平均值)。

Is this possible in Vega-Lite? Vega-Lite有可能吗?

Thanks. 谢谢。

The link to my graph: EGV data from 5 different sensors for one day 我的图表的链接: 一天来自5个不同传感器的EGV数据

Unfortunately not yet. 不幸的是还没有。 But we are working on Vega-Lite 2.0 with support for layering. 但是我们正在开发Vega-Lite 2.0,并支持分层。 See our research paper at http://idl.cs.washington.edu/papers/vega-lite/ for details. 有关详细信息,请参见http://idl.cs.washington.edu/papers/vega-lite/上的研究论文。

We have preliminary (not documented and may break in Vega-Lite 2) support for layering. 我们已经初步(未记录,可能会破坏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"}}
    }
  ]
}

图表

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM