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 2020/02/27 12:47:42 UTC

[incubator-echarts] branch release updated: fix: fix stacked bar not drawn because of NaN value brought in #11951

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

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


The following commit(s) were added to refs/heads/release by this push:
     new 879b895  fix: fix stacked bar not drawn because of NaN value brought in #11951
879b895 is described below

commit 879b895855afe13979ef2dfc3dfa26da303901ce
Author: pissang <bm...@gmail.com>
AuthorDate: Thu Feb 27 11:30:39 2020 +0800

    fix: fix stacked bar not drawn because of NaN value brought in #11951
---
 src/chart/bar/BarView.js |  1 +
 src/layout/barGrid.js    | 10 ++++++++--
 test/bar.html            |  2 +-
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/chart/bar/BarView.js b/src/chart/bar/BarView.js
index 18c5e2a..f1f7c5a 100644
--- a/src/chart/bar/BarView.js
+++ b/src/chart/bar/BarView.js
@@ -145,6 +145,7 @@ export default echarts.extendChartView({
                     bgEls[dataIndex] = bgEl;
                 }
 
+                // If dataZoom in filteMode: 'empty', the baseValue can be set as NaN in "axisProxy".
                 if (!data.hasValue(dataIndex)) {
                     return;
                 }
diff --git a/src/layout/barGrid.js b/src/layout/barGrid.js
index e7947eb..2e3cf93 100644
--- a/src/layout/barGrid.js
+++ b/src/layout/barGrid.js
@@ -452,7 +452,10 @@ export function layout(seriesType, ecModel) {
                 if (Math.abs(width) < barMinHeight) {
                     width = (width < 0 ? -1 : 1) * barMinHeight;
                 }
-                stacked && (lastStackCoords[stackId][baseValue][sign] += width);
+                // Ignore stack from NaN value
+                if (!isNaN(width)) {
+                    stacked && (lastStackCoords[stackId][baseValue][sign] += width);
+                }
             }
             else {
                 var coord = cartesian.dataToPoint([baseValue, value]);
@@ -465,7 +468,10 @@ export function layout(seriesType, ecModel) {
                     // Include zero to has a positive bar
                     height = (height <= 0 ? -1 : 1) * barMinHeight;
                 }
-                stacked && (lastStackCoords[stackId][baseValue][sign] += height);
+                // Ignore stack from NaN value
+                if (!isNaN(height)) {
+                    stacked && (lastStackCoords[stackId][baseValue][sign] += height);
+                }
             }
 
             data.setItemLayout(idx, {
diff --git a/test/bar.html b/test/bar.html
index a92e5fd..fbb3137 100644
--- a/test/bar.html
+++ b/test/bar.html
@@ -82,7 +82,7 @@ under the License.
 
                 for (var i = 0; i < 10; i++) {
                     xAxisData.push('类目' + i);
-                    data1.push((Math.random() * 5).toFixed(2));
+                    data1.push(i === 0 ? '-' : (Math.random() * 5).toFixed(2));
                     data2.push(-Math.random().toFixed(2));
                     data3.push((Math.random() + 0.5).toFixed(2));
                     data4.push((Math.random() + 0.3).toFixed(2));


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