This website is for Vega-Lite v3. Go to the main Vega-Lite homepage for the latest release.

Multi Series Line Chart with Tooltip

This plot requires the data to have different series in different fields. See #1274 and #1552 for relevant future syntax improvements.

View this example in the online editor

Vega-Lite JSON Specification

{
  "$schema": "https://vega.github.io/schema/vega-lite/v3.json",
  "data": {"url": "data/seattle-weather.csv", "format": {"type": "csv"}},
  "encoding": {
    "x": {"timeUnit": "yearmonthdate", "field": "date", "type": "temporal"},
    "tooltip": [
      {"timeUnit": "yearmonthdate", "field": "date", "type": "temporal"},
      {"field": "temp_max", "type": "quantitative"},
      {"field": "temp_min", "type": "quantitative"}
    ]
  },
  "layer": [{
    "mark": {"type": "line", "color": "orange"},
    "encoding": {
      "y": {"field": "temp_max", "type": "quantitative"}
    }
  }, {
    "mark": {"type": "line", "color": "red"},
    "encoding": {
      "y": {"field": "temp_min", "type": "quantitative"}
    }
  }, {
    "mark": "rule",
    "selection": {
      "hover": {"type": "single", "on": "mouseover", "empty": "none"}
    },
    "encoding": {
      "color": {
        "condition":{
          "selection": {"not": "hover"}, "value": "transparent"
        }
      }
    }
  }],
  "config": {"axisY": {"minExtent": 30}}
}