diff --git a/src/chart/helper/whiskerBoxCommon.ts b/src/chart/helper/whiskerBoxCommon.ts index 177105283e..9502d3b6f8 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 @@ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +