Skip to content

fix(boxplot): correctly handle series.encode with category axis #20324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using != instead of !== please.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, changes pushed

}
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.