简体   繁体   中英

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).

Is this possible in Vega-Lite?

Thanks.

The link to my graph: EGV data from 5 different sensors for one day

Unfortunately not yet. But we are working on Vega-Lite 2.0 with support for layering. See our research paper at http://idl.cs.washington.edu/papers/vega-lite/ for details.

We have preliminary (not documented and may break in Vega-Lite 2) support for layering.

{
  "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"}}
    }
  ]
}

图表

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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