This is an automated email from the ASF dual-hosted git repository. shenyi pushed a commit to branch fix-bar-stack in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git
commit 9adb6a93f7f96d3db0d4fb55c4654ddd05e638a8 Author: pissang <[email protected]> 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: [email protected] For additional commands, e-mail: [email protected]
