Skip to content

Instantly share code, notes, and snippets.

@joninvski
Created October 30, 2020 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joninvski/5d585bc41fd11e099a87d914e453986a to your computer and use it in GitHub Desktop.
Save joninvski/5d585bc41fd11e099a87d914e453986a to your computer and use it in GitHub Desktop.
Vega-Lite spec from Fri Oct 30 2020
{
"$schema":"https://vega.github.io/schema/vega-lite/v4.json",
"data":{
"url":"https://covid.ourworldindata.org/data/owid-covid-data.csv",
"format":{
"parse":{
"date":"date"
}
}
},
"width":600,
"height":400,
"transform":[
{
"filter":{
"or":[
{
"field":"iso_code",
"equal":"PRT"
},
{
"field":"iso_code",
"equal":"USA"
},
{
"field":"iso_code",
"equal":"ESP"
},
{
"field":"iso_code",
"equal":"NOR"
},
{
"field":"iso_code",
"equal":"DNK"
},
{
"field":"iso_code",
"equal":"NLD"
},
{
"field":"iso_code",
"equal":"ITA"
},
{
"field":"iso_code",
"equal":"DEU"
},
{
"field":"iso_code",
"equal":"BRA"
},
{
"field":"iso_code",
"equal":"SWE"
}
]
}
}
],
"encoding":{
"x":{
"field":"date",
"type":"temporal"
},
"y":{
"field":"total_deaths_per_million",
"type":"quantitative"
},
"color":{
"field":"iso_code",
"type":"nominal"
}
},
"layer":[
{
"mark":"line"
},
{
"selection":{
"label":{
"type":"single",
"nearest":true,
"on":"mouseover",
"encodings":[ "x" ],
"empty":"none"
}
},
"mark":"point",
"encoding":{
"opacity":{
"condition":{
"selection":"label",
"value":1
},
"value":0
}
}
},
{
"transform": [{"filter": {"selection": "label"}}],
"layer": [
{
"encoding": {
"text": {"type": "quantitative", "field": "total_deaths_per_million"},
"x": {"type": "temporal", "field": "date"},
"y": {"type": "quantitative", "field": "total_deaths_per_million"}
},
"layer": [
{
"mark": {
"type": "text",
"stroke": "white",
"strokeWidth": 2,
"align": "left",
"dx": 5,
"dy": -5
}
},
{
"mark": {"type": "text", "align": "left", "dx": 5, "dy": -5} }
]
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment