Skip to content

Commit

Permalink
fix(boxplot) correctly handle series.encode with category axis close #…
Browse files Browse the repository at this point in the history
  • Loading branch information
jonoshearman committed Sep 20, 2024
1 parent 0ffc94b commit 41ff0b0
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 41ff0b0

Please sign in to comment.