Concatenated chart
A Seattle precipitation histogram stacked above a temperature scatterplot.
Spec & Code
Spec
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"description": "Two vertically concatenated charts that show a histogram of precipitation in Seattle and the relationship between min and max temperature.",
"data": {
"url": "https://raw.githubusercontent.com/vega/vega-datasets/next/data/weather.csv"
},
"transform": [
{
"filter": "datum.location === 'Seattle'"
}
],
"vconcat": [
{
"mark": "bar",
"encoding": {
"x": {
"timeUnit": "month",
"field": "date",
"type": "ordinal"
},
"y": {
"aggregate": "mean",
"field": "precipitation",
"type": "quantitative"
}
}
},
{
"mark": "point",
"encoding": {
"x": {
"field": "temp_min",
"type": "quantitative",
"bin": true
},
"y": {
"field": "temp_max",
"type": "quantitative",
"bin": true
},
"size": {
"aggregate": "count",
"type": "quantitative"
}
}
}
]
}Usage
import { olliVis } from 'olli';
import { VegaLiteAdapter } from 'olli/adapters';
// vlSpec is your Vega-Lite specification (shown above)
const olliSpec = await VegaLiteAdapter(vlSpec);
olliVis(olliSpec, document.getElementById('olli-tree'));