From bc5c888f5ebdd1df289a2ce8b0ec591f285c092f Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 5 Sep 2024 12:04:52 -0600 Subject: [PATCH] feat(boxplot) correctly handle series.encode with category axis --- src/chart/helper/whiskerBoxCommon.ts | 16 +++- test/boxplot-category.html | 137 +++++++++++++++++++++++++++ 2 files changed, 150 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..bb971bc32a 100644 --- a/src/chart/helper/whiskerBoxCommon.ts +++ b/src/chart/helper/whiskerBoxCommon.ts @@ -52,6 +52,16 @@ class WhiskerBoxCommonMixin { defaultValueDimensions: CoordDimensionDefinition['dimsDef']; + /** + * @private + */ + _hasEncodeRule(key: string) { + const encodeRules = this.getEncode(); + if(encodeRules?.data?.has(key)) + return encodeRules.data.get(key) !== null; + return false; + } + /** * @override */ @@ -74,12 +84,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 +171,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 @@ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +