Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add reference lines in vega-lite?

Tags:

vega-lite

vega

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


1 Answers

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

chart

like image 180
dominik Avatar answered Dec 24 '25 11:12

dominik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!