From 41ff0b09dc378aa618d094d844f4d07fc81500ed Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 5 Sep 2024 12:04:52 -0600 Subject: [PATCH 1/2] fix(boxplot) correctly handle series.encode with category axis close #20319 --- src/chart/helper/whiskerBoxCommon.ts | 17 +++- test/boxplot-category.html | 137 +++++++++++++++++++++++++++ 2 files changed, 151 insertions(+), 3 deletions(-) create mode 100644 test/boxplot-category.html diff --git a/src/chart/helper/whiskerBoxCommon.ts b/src/chart/helper/whiskerBoxCommon.ts index 177105283e..132ee56d35 100644 --- a/src/chart/helper/whiskerBoxCommon.ts +++ b/src/chart/helper/whiskerBoxCommon.ts @@ -52,6 +52,17 @@ class WhiskerBoxCommonMixin { 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 */ @@ -74,12 +85,12 @@ class WhiskerBoxCommonMixin { 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'; @@ -161,4 +172,4 @@ class WhiskerBoxCommonMixin { }; -export {WhiskerBoxCommonMixin}; \ No newline at end of file +export {WhiskerBoxCommonMixin}; diff --git a/test/boxplot-category.html b/test/boxplot-category.html new file mode 100644 index 0000000000..9a4b1695f1 --- /dev/null +++ b/test/boxplot-category.html @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + From 399fb2f71ee3e41d00dff88f8a87bf51066e5e62 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 24 Sep 2024 15:40:23 +0300 Subject: [PATCH 2/2] change equality check after PR review --- src/chart/helper/whiskerBoxCommon.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chart/helper/whiskerBoxCommon.ts b/src/chart/helper/whiskerBoxCommon.ts index 132ee56d35..9502d3b6f8 100644 --- a/src/chart/helper/whiskerBoxCommon.ts +++ b/src/chart/helper/whiskerBoxCommon.ts @@ -58,7 +58,7 @@ class WhiskerBoxCommonMixin { _hasEncodeRule(key: string) { const encodeRules = this.getEncode(); if (encodeRules && encodeRules.data && encodeRules.data.has(key)) { - return encodeRules.data.get(key) !== null; + return encodeRules.data.get(key) != null; } return false; }