vega-lite
vega-lite copied to clipboard
Sorting x-axis by y value in stacked area chart doesn't work
Description
Sorting an ordinal/nominal x-axis by y value in a stacked area chart (color field set) results in an incomprehensible chart.
Repro steps:
- Create the most basic stacked area chart with an ordinal/nominal x-axis
- Set the x-axis "sort" value to "y" or "-y"
(also, see that when the mark type is changed to "bar" it works as expected)
Minimal spec and example
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {"url": "data/barley.json"},
"mark": "area",
"encoding": {
"x": {"field": "variety", "sort": "y"},
"y": {"field": "yield", "type": "quantitative", "aggregate": "sum"},
"color": {"field": "site", "type": "nominal"}
}
}
Vega versions
Vega 5.22.1, Vega-Lite 5.2.0, Vega-Tooltip 0.28.0, Editor 60b772c
Following up here, this doesn't work for line charts either: