user7187941
user7187941

Reputation:

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

Upvotes: 3

Views: 1269

Answers (1)

dominik
dominik

Reputation: 5935

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

Upvotes: 3

Related Questions