Skip to content

Instantly share code, notes, and snippets.

@MarshalW
Created August 21, 2020 08:25
Show Gist options
  • Save MarshalW/a3b43e960535e4c47983526e2fb5aed8 to your computer and use it in GitHub Desktop.
Save MarshalW/a3b43e960535e4c47983526e2fb5aed8 to your computer and use it in GitHub Desktop.
Vega 5 hello world
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"width": 400,
"height": 200,
"data": [
{
"name": "table",
"values": [
{"date": "2020-08-01", "count": 2109},
{"date": "2020-08-02", "count": 1201},
{"date": "2020-08-03", "count": 876},
{"date": "2020-08-04", "count": 567},
{"date": "2020-08-05", "count": 432},
{"date": "2020-08-06", "count": 502},
{"date": "2020-08-07", "count": 433},
{"date": "2020-08-08", "count": 321},
{"date": "2020-08-09", "count": 299},
{"date": "2020-08-10", "count": 120}
]
}
],
"scales": [
{
"name": "xscale",
"type": "band",
"domain": {"data": "table", "field": "date"},
"range": "width",
"padding": 0.05,
"round": true
},
{
"name": "yscale",
"domain": {"data": "table", "field": "count"},
"nice": true,
"range": "height"
}
],
"axes": [
{ "orient": "bottom", "scale": "xscale" },
{ "orient": "left", "scale": "yscale" }
],
"marks": [
{
"type": "rect",
"from": {"data":"table"},
"encode": {
"enter": {
"x": {"scale": "xscale", "field": "date"},
"width": {"scale": "xscale", "band": 1},
"y": {"scale": "yscale", "field": "count"},
"y2": {"scale": "yscale", "value": 0}
},
"update": {
"fill": {"value": "steelblue"}
},
"hover": {
"fill": {"value": "red"}
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment