Aggregate Bar Chart (Sorted)
A bar chart that sorts the y-values by the x-values.
View this example in the online editor
Vega-Lite JSON Specification
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"description": "A bar chart that sorts the y-values by the x-values.",
"data": {"url": "data/population.json"},
"transform": [{"filter": "datum.year == 2000"}],
"height": {"step": 17},
"mark": "bar",
"encoding": {
"y": {
"field": "age",
"type": "ordinal",
"sort": "-x"
},
"x": {
"aggregate": "sum",
"field": "people",
"title": "population"
}
}
}