Skip to content

Commit

Permalink
Merge pull request #20324 from jonoshearman/fix-boxplot-category-enco…
Browse files Browse the repository at this point in the history
…de-20319

fix(boxplot) correctly handle series.encode with category axis
  • Loading branch information
Ovilia authored Sep 25, 2024
2 parents 5cb2a72 + 399fb2f commit 2c6ecb0
Show file tree
Hide file tree
Showing 2 changed files with 151 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/chart/helper/whiskerBoxCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ class WhiskerBoxCommonMixin<Opts extends CommonOption> {

defaultValueDimensions: CoordDimensionDefinition['dimsDef'];

/**
* @private
*/
_hasEncodeRule(key: string) {
const encodeRules = this.getEncode();
if (encodeRules && encodeRules.data && encodeRules.data.has(key)) {
return encodeRules.data.get(key) != null;
}
return false;
}

/**
* @override
*/
Expand All @@ -74,12 +85,12 @@ class WhiskerBoxCommonMixin<Opts extends CommonOption> {
if (xAxisType === 'category') {
option.layout = 'horizontal';
ordinalMeta = xAxisModel.getOrdinalMeta();
addOrdinal = true;
addOrdinal = !this._hasEncodeRule('x');
}
else if (yAxisType === 'category') {
option.layout = 'vertical';
ordinalMeta = yAxisModel.getOrdinalMeta();
addOrdinal = true;
addOrdinal = !this._hasEncodeRule('y');
}
else {
option.layout = option.layout || 'horizontal';
Expand Down Expand Up @@ -161,4 +172,4 @@ class WhiskerBoxCommonMixin<Opts extends CommonOption> {
};


export {WhiskerBoxCommonMixin};
export {WhiskerBoxCommonMixin};
137 changes: 137 additions & 0 deletions test/boxplot-category.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2c6ecb0

Please sign in to comment.