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

Quantitative area chart does not stack

Open ldegreef opened this issue 3 years ago • 2 comments

I would expect this chart to stack. It does stack when I switch the x encoding to be ordinal.

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {
    "values": [
      {"a": 0, "b": 28, "c": "A"},
      {"a": 1, "b": 55, "c": "A"},
      {"a": 0, "b": 28, "c": "B"},
      {"a": 1, "b": 55, "c": "B"}
    ]
  },
  "mark": "area",
  "encoding": {
    "x": {"field": "a", "type": "quantitative"},
    "y": {"field": "b", "type": "quantitative"},
    "color": {"field": "c", "type": "nominal"}
  }
}

ldegreef avatar Apr 02 '21 03:04 ldegreef

Actually, we can enable stacking manually. The question is, why

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {
    "values": [
      {"a": 0, "b": 28, "c": "A"},
      {"a": 1, "b": 55, "c": "A"},
      {"a": 0, "b": 28, "c": "B"},
      {"a": 1, "b": 55, "c": "B"}
    ]
  },
  "mark": "area",
  "encoding": {
    "x": {"field": "a", "type": "quantitative"},
    "y": {"field": "b", "type": "quantitative", "stack": true},
    "color": {"field": "c", "type": "nominal"}
  }
}

Default stacking was enabled in https://github.com/vega/vega-lite/issues/6864.

ldegreef avatar Apr 02 '21 03:04 ldegreef

This also seems to apply to other charts like bar charts - the bars don't stack if the x type is 'quantitative' but will stack if it's changed to 'nominal' or such.

jkillian avatar Mar 25 '22 20:03 jkillian