fix: stacked color does not drop categories when one category is all-null#9846
Open
mvanhorn wants to merge 1 commit into
Open
Conversation
…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
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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