Skip to content

Instantly share code, notes, and snippets.

@kanitw
Last active August 4, 2017 16:36
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 kanitw/02edd4fe0173cf3b535468292e1610fe to your computer and use it in GitHub Desktop.
Save kanitw/02edd4fe0173cf3b535468292e1610fe to your computer and use it in GitHub Desktop.
Vega-lite Quick Demo
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.json",
"description": "Summarized and per year weather information for Seatle and New York.",
"data": {"url": "data/weather.csv"},
"repeat": {"column": ["temp_max","precipitation","wind"]},
"spec": {
"layer": [
{
"mark": "line",
"encoding": {
"y": {
"aggregate": "mean",
"field": {"repeat": "column"},
"type": "quantitative"
},
"x": {
"timeUnit": "month",
"type": "temporal",
"field": "date"
},
"detail": {
"timeUnit": "year",
"type": "temporal",
"field": "date"
},
"color": {"type": "nominal","field": "location"},
"opacity": {"value": 0.2}
}
},
{
"mark": "line",
"encoding": {
"y": {
"aggregate": "mean",
"field": {"repeat": "column"},
"type": "quantitative"
},
"x": {
"timeUnit": "month",
"type": "temporal",
"field": "date"
},
"color": {"type": "nominal","field": "location"}
}
}
]
}
}
{
"data": {"url": "data/cars.json"},
"selection": {
"brush": {
"type": "interval"
}
},
"mark": {"type": "circle", "clip": true},
"encoding": {
"x": {
"field": "Horsepower", "type": "quantitative",
"scale": {"domain": [75, 150]}
},
"y": {
"field": "Miles_per_Gallon", "type": "quantitative",
"scale": {"domain": [20, 40]}
},
"size": {"field": "Cylinders", "type": "quantitative"},
"color": {
"condition": {
"selection": "brush",
"field": "Origin", "type": "nominal"
},
"value": "grey"
}
}
}
@kanitw
Copy link
Author

kanitw commented Aug 4, 2017

"zoom": "wheel![event.shiftKey]"
"bind": "scales"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment