Skip to content

Commit

Permalink
feat(boxplot) correctly handle series.encode with category axis
Browse files Browse the repository at this point in the history
  • Loading branch information
jonoshearman committed Sep 5, 2024
1 parent 0ffc94b commit bc5c888
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/chart/helper/whiskerBoxCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ class WhiskerBoxCommonMixin<Opts extends CommonOption> {

defaultValueDimensions: CoordDimensionDefinition['dimsDef'];

/**
* @private
*/
_hasEncodeRule(key: string) {
const encodeRules = this.getEncode();
if(encodeRules?.data?.has(key))

Check failure on line 60 in src/chart/helper/whiskerBoxCommon.ts

View workflow job for this annotation

GitHub Actions / lint (18.x)

Expected { after 'if' condition

Check failure on line 60 in src/chart/helper/whiskerBoxCommon.ts

View workflow job for this annotation

GitHub Actions / lint (18.x)

Expected space(s) after "if"
return encodeRules.data.get(key) !== null;
return false;
}

/**
* @override
*/
Expand All @@ -74,12 +84,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 +171,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 bc5c888

Please sign in to comment.