Skip to content

Instantly share code, notes, and snippets.

@brew
Created October 5, 2017 10:31
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 brew/abcf6089bb68831571d50d74b1c5c7b7 to your computer and use it in GitHub Desktop.
Save brew/abcf6089bb68831571d50d74b1c5c7b7 to your computer and use it in GitHub Desktop.
Vega view for a visualisation of Work Horses vs Tractors
{
"width": 800,
"height": 200,
"data": [
{
"name": "farm-survey",
"url": "https://gist.githubusercontent.com/brew/9cd259fda775ad3f7713ca8f2b623aaa/raw/e8c4dc4b2af82032d1c1ffd42ecd6acc2484a74a/farm-survey",
"format": {
"type": "csv",
"parse": {
"Year": "integer",
"WorkHorses": "number",
"Tractor": "number"
}
},
"transform": [
{
"type": "aggregate",
"groupby": ["Year"],
"summarize": [
{
"field": "WorkHorses",
"ops": ["sum"],
"as": ["workhorses_sum"]
},
{
"field": "Tractor",
"ops": ["sum"],
"as": ["tractor_sum"]
}
]
}
]
}
],
"scales": [
{
"name": "x",
"type": "linear",
"range": "width",
"zero": false,
"domainMin": 1938,
"domainMax": 1986,
"domain": {"data": "farm-survey","field": "Year"}
},
{
"name": "y",
"type": "linear",
"range": "height",
"nice": true,
"domain": {"data": "farm-survey","field": "tractor_sum"}
}
],
"axes": [
{"type": "x","scale": "x","format": "04d"},
{"type": "y","scale": "y"}
],
"marks": [
{
"type": "rect",
"from": {"data": "farm-survey"},
"properties": {
"enter": {
"x": {"scale": "x", "field": "Year"},
"width": {"value": 15},
"y": {"scale": "y", "field": "tractor_sum"},
"y2": {"scale": "y", "value": 0},
"fill": {"value": "#B3D9E6"},
"strokeWidth": {"value": 0.25}
}
}
},
{
"type": "rect",
"from": {"data": "farm-survey"},
"properties": {
"enter": {
"x": {"scale": "x", "field": "Year"},
"width": {"value": 15},
"y": {"scale": "y", "field": "workhorses_sum"},
"y2": {"scale": "y", "value": 0},
"fill": {"value": "#aaa"},
"fillOpacity": {"value": 0.5},
"strokeWidth": {"value": 0.25}
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment