Skip to content

Instantly share code, notes, and snippets.

@djbarnwal
Last active June 24, 2019 16:51
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 djbarnwal/b02b6db5c4b60b709c653a7f5cba3a05 to your computer and use it in GitHub Desktop.
Save djbarnwal/b02b6db5c4b60b709c653a7f5cba3a05 to your computer and use it in GitHub Desktop.
Budget VL
{
"$schema": "https://vega.github.io/schema/vega-lite/v3.json",
"background": "#edf1f7",
"description": "Google's stock price over time.",
"data": {
"url": "data/budgets.json"
},
"width": 700,
"height": 400,
"layer": [
{
"selection": {
"year": {
"type": "single",
"encodings": [
"x"
],
"init": {
"forecastYear": 2016
},
"bind": {
"forecastYear": {
"input": "range",
"min": 1980,
"max": 2016,
"step": 1
}
}
}
},
"transform": [
{
"filter": "datum.budgetYear <= year.forecastYear && datum.forecastYear == datum.budgetYear - 1"
}
],
"mark": "line",
"encoding": {
"x": {
"field": "forecastYear",
"type": "quantitative",
"axis": {
"gridOpacity": 0.5
},
"scale": {
"domain": [
1982,
2018
]
}
},
"y": {
"field": "value",
"type": "quantitative",
"axis": null,
"scale": {
"domain": [
-2,
1
]
}
}
}
},
{
"mark": "text",
"encoding": {
"text": {
"aggregate": "count",
"type": "quantitative"
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment