fix: only count bar dataset axes in bar width calculation for multiple x-axis#12263
Open
godfengliang wants to merge 1 commit into
Open
fix: only count bar dataset axes in bar width calculation for multiple x-axis#12263godfengliang wants to merge 1 commit into
godfengliang wants to merge 1 commit into
Conversation
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.
Fixes #12262
Problem
When a chart has both bar and line datasets on different x-axes, the bar width is incorrectly calculated. The
_getAxis()method counts ALL dataset axes (including those used by non-bar datasets like line), causingstackCount * axisCountto be larger than necessary and bars to appear thinner than they should.Root Cause
Commit 8ea47ca introduced
_getAxis()to handle stacked bars with multiple x-axes. However, it iterates over ALL datasets regardless of type, collecting axes from line/scatter/etc. datasets that do not affect bar width.Fix
Modified
_getAxis()to skip datasets whose resolved type (meta.type) does not match the bar controller type (this._type). This ensures only axes containing bar datasets are counted, consistent with how_getStacks()already filters by type viagetMatchingVisibleMetas(this._type).Before: Axis count includes line dataset axes -> bars too thin
After: Axis count only includes bar dataset axes -> bars fill correct width
Testing
The existing test
stacked-and-multiple-axis.js(all bar datasets) continues to work correctly since all datasets have type === 'bar'. Mixed charts (bar + line) now correctly exclude line dataset axes from the calculation.