Skip to content

Support side-by-side grouped bar by disabling stacking when color dimension exists #505

@su-jin02

Description

@su-jin02

Problem

In Graphic Walker, when creating a bar chart with:

  • x: categorical field (e.g. Year)
  • y: quantitative field (e.g. Revenue)
  • color: categorical field (e.g. Company)

the current behavior always results in a stacked bar (or normalized / centered stack),
even when the analytical intent is to compare values side-by-side within the same x category.

There is currently no way to render a true "grouped (side-by-side) bar" where
each color category produces an independent bar within the same x value.

Image

Observation

From inspecting the generated Vega-Lite spec and renderer behavior,
the key difference between stacked vs grouped bar appears to be whether
the y encoding has stack enabled.

In Vega-Lite, a grouped bar can be achieved by explicitly disabling stacking:

y: {
  field: "...",
  type: "quantitative",
  stack: null
}

Minimal logic proposal

A minimal and non-invasive way to support grouped bars could be:

  1. Detect grouped-bar intent
const isGrouped = !!(colorField && xField && colorField !== xField);
  1. Disable stacking on y encoding for grouped bars
if (isGrouped && mark === "bar") {
  yEncoding.stack = null;
}

This does not introduce facet, multi-view, or additional UI complexity.
It only changes the stacking behavior when a color dimension exists
and a grouped comparison is desired.


Why this works well for Graphic Walker

  • Uses standard Vega-Lite semantics (no custom renderer required)
  • Minimal change in spec generation
  • No need to expose raw "facet" concepts in the UI
  • Aligns with common BI expectations (Tableau-style grouped bar)
  • Keeps existing Stack / Normalize / Center modes intact

A new UI option such as "Grouped (side-by-side)" could internally map to
this behavior without changing the overall UX philosophy.


Expected result

For:

  • x = Year
  • y = Revenue
  • color = Company

Bars should render side-by-side within each Year,
instead of being merged into a single stacked bar.


If this direction makes sense, I’m happy to help with a PoC or PR.
Note: This proposal focuses on rendering behavior only.
UI exposure (toggle or preset) can be discussed separately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions