vega-lite icon indicating copy to clipboard operation
vega-lite copied to clipboard

Sorting x-axis by y value in stacked area chart doesn't work

Open suchanlee opened this issue 1 year ago • 1 comments

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:

  1. Create the most basic stacked area chart with an ordinal/nominal x-axis
  2. 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)

Editor example

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

suchanlee avatar Jan 20 '23 21:01 suchanlee

Following up here, this doesn't work for line charts either: Screenshot 2023-11-13 at 11 22 15 AM

suchanlee avatar Nov 13 '23 19:11 suchanlee