Skip to content

fix: stacked color does not drop categories when one category is all-null#9846

Open
mvanhorn wants to merge 1 commit into
vega:mainfrom
mvanhorn:fix/9753-stacked-color-drops-categories-when-one-category-i
Open

fix: stacked color does not drop categories when one category is all-null#9846
mvanhorn wants to merge 1 commit into
vega:mainfrom
mvanhorn:fix/9753-stacked-color-drops-categories-when-one-category-i

Conversation

@mvanhorn

Copy link
Copy Markdown

Summary

In a stacked bar chart with a categorical color encoding, when a category had all-null values for the stacked field, the entire category was dropped from the color domain. The result was confusing for users animating between data slices because the legend kept shifting. This change retains the category in the domain and emits a zero-height bar instead.

Why this matters

#9753 reported the exact case: a yearly dashboard where one year had no data for a category, and the legend visibly changed. Stable color domains are a long-standing expectation in vega-lite stacked charts.

Changes

  • src/compile/data/stack.ts - retain category keys with all-null measures in the stack output.
  • test/compile/data/stack.test.ts - tests covering all-null category retention with sum, count, and missing-field cases.
  • examples/specs/stacked_bar_null_color_category.vl.json - example spec showing the new behavior.

Testing

Existing stack/data tests + new cases pass locally.

Fixes #9753

…null

In a stacked color encoding, if a category had all null values for the
stacked field, the entire category was dropped from the color domain
rather than rendered with a zero-height bar. Adjust the stack data
transform to retain category keys with all-null measures so the
color domain stays stable across small data shifts.

Fixes vega#9753
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Aggregation fails to render groups alphabetically preceding all-NULL category

1 participant