plainheart commented on code in PR #21325:
URL: https://github.com/apache/echarts/pull/21325#discussion_r2456643608


##########
src/chart/helper/whiskerBoxCommon.ts:
##########
@@ -76,10 +76,37 @@ class WhiskerBoxCommonMixin<Opts extends CommonOption> {
         const yAxisType = yAxisModel.get('type');
         let addOrdinal;
 
-        // FIXME
-        // Consider time axis.
+        const encodeRules = this.getEncode();
+        const hasXEncode = encodeRules && encodeRules.get('x') != null;
+        const hasYEncode = encodeRules && encodeRules.get('y') != null;
+
+        if (hasXEncode && hasYEncode) {
+            const xEncode = encodeRules.get('x');
+            const yEncode = encodeRules.get('y');
+            const xIsArray = zrUtil.isArray(xEncode) && xEncode.length > 1;
+            const yIsArray = zrUtil.isArray(yEncode) && yEncode.length > 1;
 
-        if (xAxisType === 'category') {
+            if (yIsArray && !xIsArray) {
+                option.layout = 'horizontal';
+            }
+            else if (xIsArray && !yIsArray) {
+                option.layout = 'vertical';
+            }
+            else if (xAxisType === 'category') {
+                option.layout = 'horizontal';
+                ordinalMeta = xAxisModel.getOrdinalMeta();
+                addOrdinal = !this._hasEncodeRule('x');
+            }
+            else if (yAxisType === 'category') {
+                option.layout = 'vertical';
+                ordinalMeta = yAxisModel.getOrdinalMeta();
+                addOrdinal = !this._hasEncodeRule('y');
+            }
+            else {
+                option.layout = option.layout || 'horizontal';
+            }
+        }
+        else if (xAxisType === 'category') {

Review Comment:
   Maybe adding simple support for the time axis is enough?
   
   ```javascript
   // ...
   }
   else if (xAxisType === 'time') {
       option.layout = 'horizontal';
   }
   else if (yAxisType === 'time') {
       option.layout = 'vertical';
   }
   ```



##########
src/chart/candlestick/CandlestickView.ts:
##########
@@ -110,6 +110,9 @@ class CandlestickView extends ChartView {
             .add(function (newIdx) {
                 if (data.hasValue(newIdx)) {
                     const itemLayout = data.getItemLayout(newIdx) as 
CandlestickItemLayout;
+                    if (!itemLayout) {

Review Comment:
   If everything goes well, `itemLayout` should never be null. If we simply 
ignore it, potential errors might be hidden unexpectedly. I suggest not adding 
this non-null check.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to