This is an automated email from the ASF dual-hosted git repository.

sushuang pushed a commit to branch fix/axis-min-max-fn
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git

commit f3a6b9aa8bab16701c1085c0b20a07aa397fbe39
Author: 100pah <[email protected]>
AuthorDate: Thu Apr 2 18:35:11 2020 +0800

    fix: axis min/max function return null:
    The original PR is:  #12215
    cf5812f6aad64e433c0de89c62bd0d84b7f3f0cf
    Fix from that:
    (1) The min/max function call should not be called twice (necessary and 
probably wrong input params).
    (2) `fixMin` `fixMax` should cover function return.
    (3) Add more test cases.
---
 src/coord/axisHelper.js    |  37 ++++++--------
 src/coord/radar/Radar.js   |   2 +-
 test/min-max-function.html | 117 ++++++++++++++++++++++++++++++++++++++++-----
 3 files changed, 119 insertions(+), 37 deletions(-)

diff --git a/src/coord/axisHelper.js b/src/coord/axisHelper.js
index 75a4240..d6f7cd3 100644
--- a/src/coord/axisHelper.js
+++ b/src/coord/axisHelper.js
@@ -42,8 +42,6 @@ export function getScaleExtent(scale, model) {
 
     var min = model.getMin();
     var max = model.getMax();
-    var fixMin = min != null;
-    var fixMax = max != null;
     var originalExtent = scale.getExtent();
 
     var axisDataLen;
@@ -107,6 +105,9 @@ export function getScaleExtent(scale, model) {
         });
     }
 
+    var fixMin = min != null;
+    var fixMax = max != null;
+
     if (min == null) {
         min = scaleType === 'ordinal'
             ? (axisDataLen ? 0 : NaN)
@@ -168,7 +169,13 @@ export function getScaleExtent(scale, model) {
         }
     }
 
-    return [min, max];
+    return {
+        extent: [min, max],
+        // "fix" means "fixed", the value should not be
+        // changed in the subsequent steps.
+        fixMin: fixMin,
+        fixMax: fixMax
+    };
 }
 
 function adjustScaleForOverflow(min, max, model, barWidthAndOffset) {
@@ -207,24 +214,8 @@ function adjustScaleForOverflow(min, max, model, 
barWidthAndOffset) {
 }
 
 export function niceScaleExtent(scale, model) {
-    var extent = getScaleExtent(scale, model);
-    var min = model.getMin();
-    var max = model.getMax();
-    var originalExtent = scale.getExtent();
-
-    if (typeof min === 'function') {
-        min = min({
-            min: originalExtent[0],
-            max: originalExtent[1]
-        });
-    }
-
-    if (typeof max === 'function') {
-        max = max({
-            min: originalExtent[0],
-            max: originalExtent[1]
-        });
-    }
+    var extentInfo = getScaleExtent(scale, model);
+    var extent = extentInfo.extent;
 
     var splitNumber = model.get('splitNumber');
 
@@ -236,8 +227,8 @@ export function niceScaleExtent(scale, model) {
     scale.setExtent(extent[0], extent[1]);
     scale.niceExtent({
         splitNumber: splitNumber,
-        fixMin: min != null,
-        fixMax: max != null,
+        fixMin: extentInfo.fixMin,
+        fixMax: extentInfo.fixMin,
         minInterval: (scaleType === 'interval' || scaleType === 'time')
             ? model.get('minInterval') : null,
         maxInterval: (scaleType === 'interval' || scaleType === 'time')
diff --git a/src/coord/radar/Radar.js b/src/coord/radar/Radar.js
index 818e036..5ddf23a 100644
--- a/src/coord/radar/Radar.js
+++ b/src/coord/radar/Radar.js
@@ -186,7 +186,7 @@ Radar.prototype.update = function (ecModel, api) {
     }
     // Force all the axis fixing the maxSplitNumber.
     zrUtil.each(indicatorAxes, function (indicatorAxis, idx) {
-        var rawExtent = getScaleExtent(indicatorAxis.scale, 
indicatorAxis.model);
+        var rawExtent = getScaleExtent(indicatorAxis.scale, 
indicatorAxis.model).extent;
         niceScaleExtent(indicatorAxis.scale, indicatorAxis.model);
 
         var axisModel = indicatorAxis.model;
diff --git a/test/min-max-function.html b/test/min-max-function.html
index f1d7821..b4d51c3 100644
--- a/test/min-max-function.html
+++ b/test/min-max-function.html
@@ -21,33 +21,29 @@ under the License.
 <html>
     <head>
         <meta charset="utf-8">
+        <meta name="viewport" content="width=device-width, initial-scale=1" />
         <script src="lib/esl.js"></script>
         <script src="lib/config.js"></script>
-        <meta name="viewport" content="width=device-width, initial-scale=1" />
+        <script src="lib/jquery.min.js"></script>
+        <script src="lib/facePrint.js"></script>
+        <script src="lib/testHelper.js"></script>
+        <link rel="stylesheet" href="lib/reset.css" />
     </head>
     <body>
         <style>
-            html, body, .chart {
-                width: 100%;
-                margin: 0;
-            }
-
             .chart {
                 height: 400px;
             }
         </style>
+
         <div id="chart-1" class="chart"></div>
+        <div id="main1"></div>
+
+
         <script>
 
             require([
                 'echarts'
-                // 'echarts/chart/bar',
-                // 'echarts/chart/line',
-                // 'echarts/component/tooltip',
-                // 'echarts/component/dataZoom',
-                // 'echarts/component/markPoint',
-                // 'echarts/component/toolbox',
-                // 'zrender/vml/vml'
             ], function (echarts) {
 
                 var chart = echarts.init(document.getElementById('chart-1'));
@@ -125,5 +121,100 @@ under the License.
                 });
             });
         </script>
+
+
+
+
+        <script>
+
+            require([
+                'echarts'
+            ], function (echarts) {
+                function xAxisData() { return ['a', 'b', 'c']; };
+                function seriesData() { return [12, 32, 44]; };
+                var gridWidth = 100;
+                var gridBottom = 80;
+                var gridGap = 50;
+                var gridCurrLeft = gridGap;
+                var nameTextStyle = {align: 'left'};
+
+                function getGridLeft() {
+                    var left = gridCurrLeft;
+                    gridCurrLeft += gridWidth + gridGap;
+                    return left;
+                }
+
+                var option = {
+                    dataZoom: [
+                        {type: 'inside', yAxisIndex: 1},
+                        {type: 'inside', yAxisIndex: 3}
+                    ],
+                    grid: [
+                        {width: gridWidth, bottom: gridBottom, left: 
getGridLeft()},
+                        {width: gridWidth, bottom: gridBottom, left: 
getGridLeft()},
+                        {width: gridWidth, bottom: gridBottom, left: 
getGridLeft()},
+                        {width: gridWidth, bottom: gridBottom, left: 
getGridLeft()}
+                    ],
+                    xAxis: [
+                        {gridIndex: 0, data: xAxisData()},
+                        {gridIndex: 1, data: xAxisData()},
+                        {gridIndex: 2, data: xAxisData()},
+                        {gridIndex: 3, data: xAxisData()}
+                    ],
+                    yAxis: [{
+                        gridIndex: 0,
+                        name: 'y min/max:\nfunction return null\nno dataZoom',
+                        nameTextStyle: nameTextStyle,
+                        min: function (param) {
+                            return null;
+                        },
+                        max: function (param) {
+                            return null;
+                        }
+                    }, {
+                        gridIndex: 1,
+                        name: 'y min/max:\nfunction return null\ny inside 
dataZoom',
+                        nameTextStyle: nameTextStyle,
+                        min: function (param) {
+                            return null;
+                        },
+                        max: function (param) {
+                            return null;
+                        }
+                    }, {
+                        gridIndex: 2,
+                        name: 'y min/max:\nnull\nno dataZoom',
+                        nameTextStyle: nameTextStyle,
+                        min: null,
+                        max: null
+                    }, {
+                        gridIndex: 3,
+                        name: 'y min/max:\nnull\ny inside dataZoom',
+                        nameTextStyle: nameTextStyle,
+                        min: null,
+                        max: null
+                    }],
+                    series: [
+                        {type: 'scatter', data: seriesData(), xAxisIndex: 0, 
yAxisIndex: 0},
+                        {type: 'scatter', data: seriesData(), xAxisIndex: 1, 
yAxisIndex: 1},
+                        {type: 'scatter', data: seriesData(), xAxisIndex: 2, 
yAxisIndex: 2},
+                        {type: 'scatter', data: seriesData(), xAxisIndex: 3, 
yAxisIndex: 3},
+                    ]
+                };
+
+                var chart = testHelper.create(echarts, 'main1', {
+                    title: [
+                        'Y range should be all the same',
+                        'dataZoom should be normal'
+                    ],
+                    option: option
+                });
+
+            });
+
+        </script>
+
+
+
     </body>
 </html>
\ No newline at end of file


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

Reply via email to