You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by su...@apache.org on 2018/09/03 10:53:29 UTC

[incubator-echarts] branch master updated: fix: bar start when multiple axes. fix #8747.

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

sushuang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git


The following commit(s) were added to refs/heads/master by this push:
     new 0a5282b  fix: bar start when multiple axes. fix #8747.
     new 5ea50a8  Merge branch 'master' of https://github.com/apache/incubator-echarts
0a5282b is described below

commit 0a5282bdbf6a147dd70540c57ee880179904906f
Author: sushuang <su...@gmail.com>
AuthorDate: Mon Sep 3 18:50:44 2018 +0800

    fix: bar start when multiple axes. fix #8747.
---
 src/component/tooltip/TooltipRichContent.js |  4 +-
 src/layout/barGrid.js                       | 24 +++++++---
 test/bar-start.html                         | 73 ++++++++++++++++++++++++++++-
 3 files changed, 92 insertions(+), 9 deletions(-)

diff --git a/src/component/tooltip/TooltipRichContent.js b/src/component/tooltip/TooltipRichContent.js
index 1f0972c..8131b65 100644
--- a/src/component/tooltip/TooltipRichContent.js
+++ b/src/component/tooltip/TooltipRichContent.js
@@ -18,7 +18,7 @@
 */
 
 import * as zrUtil from 'zrender/src/core/util';
-import Group from 'zrender/src/container/Group';
+// import Group from 'zrender/src/container/Group';
 import Text from 'zrender/src/graphic/Text';
 
 /**
@@ -28,7 +28,7 @@ import Text from 'zrender/src/graphic/Text';
 function TooltipRichContent(api) {
     // this.el = new Group();
 
-    var zr = this._zr = api.getZr();
+    // var zr = this._zr = api.getZr();
     // zr.add(this.el);
 
     this._show = false;
diff --git a/src/layout/barGrid.js b/src/layout/barGrid.js
index e5ca44d..bf83216 100644
--- a/src/layout/barGrid.js
+++ b/src/layout/barGrid.js
@@ -420,11 +420,23 @@ function isInLargeMode(seriesModel) {
     return seriesModel.pipelineContext && seriesModel.pipelineContext.large;
 }
 
+// See cases in `test/bar-start.html` and `#7412`, `#8747`.
 function getValueAxisStart(baseAxis, valueAxis, stacked) {
-    return (
-        zrUtil.indexOf(baseAxis.getAxesOnZeroOf(), valueAxis) >= 0
-        || stacked
-    )
-    ? valueAxis.toGlobalCoord(valueAxis.dataToCoord(0))
-    : valueAxis.getGlobalExtent()[0];
+    var extent = valueAxis.getGlobalExtent();
+    var min;
+    var max;
+    if (extent[0] > extent[1]) {
+        min = extent[1];
+        max = extent[0];
+    }
+    else {
+        min = extent[0];
+        max = extent[1];
+    }
+
+    var valueStart = valueAxis.toGlobalCoord(valueAxis.dataToCoord(0));
+    valueStart < min && (valueStart = min);
+    valueStart > max && (valueStart = max);
+
+    return valueStart;
 }
diff --git a/test/bar-start.html b/test/bar-start.html
index b144973..26aff8a 100644
--- a/test/bar-start.html
+++ b/test/bar-start.html
@@ -40,6 +40,7 @@ under the License.
 
 
         <div id="main0"></div>
+        <div id="main1"></div>
 
 
         <script>
@@ -64,6 +65,9 @@ under the License.
                         min: 5000000
                     }, {
                     }],
+                    grid: {
+                        left: 100
+                    },
                     series: [{
                         name: 'bar',
                         type: 'bar',
@@ -72,7 +76,7 @@ under the License.
                     }, {
                         name: 'line',
                         type: 'line',
-                        yAxisIndex:1,
+                        yAxisIndex: 1,
                         data: [1.1496899,0.9420012,0.6743367,0.47701207,0.67934614,0.37843546]
                     }]
                 };
@@ -85,5 +89,72 @@ under the License.
             });
 
         </script>
+
+
+
+
+
+
+
+
+        <script>
+
+            // See <https://github.com/apache/incubator-echarts/issues/8747>
+            // Thanks to <https://github.com/kuky121>
+
+            var chart;
+            var myChart;
+            var option;
+
+            require([
+                'echarts'/*, 'map/js/china' */
+            ], function (echarts) {
+
+                var option = {
+                    xAxis : [
+                        {
+                            type : 'category',
+                            data : ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
+                            axisTick: {
+                                alignWithLabel: true
+                            }
+                        }
+                    ],
+                    yAxis : [
+                        {
+                            type : 'value'
+                        },
+                        {
+                            type : 'value'
+                        }
+                    ],
+                    series : [
+                        {
+                            yAxisIndex:0,
+                            name:'数据1',
+                            type:'bar',
+                            data:[10, -52]
+                        },
+                        {
+                            yAxisIndex:1,
+                            name:'数据2',
+                            type:'bar',
+                            data:[10, -52]
+                        }
+                    ]
+                };
+
+                chart = myChart = testHelper.create(echarts, 'main1', {
+                    title: 'bar start should be correct when two Y axes exists',
+                    option: option,
+                    info: option
+                });
+            });
+
+        </script>
+
+
+
+
     </body>
 </html>
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org