From 34c38d5c9db58d1ed299a36226a55ca84f1aa6b5 Mon Sep 17 00:00:00 2001 From: lang Date: Fri, 11 Dec 2015 10:59:54 +0800 Subject: [PATCH] Symbol needs draw validate fix, symbol hover animation on line fix --- src/chart/helper/SymbolDraw.js | 18 ++++++++++-------- src/chart/line/LineView.js | 2 +- src/chart/pie/PieView.js | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/chart/helper/SymbolDraw.js b/src/chart/helper/SymbolDraw.js index 2cefafbd7..79bb35cce 100644 --- a/src/chart/helper/SymbolDraw.js +++ b/src/chart/helper/SymbolDraw.js @@ -19,6 +19,11 @@ define(function (require) { var symbolDrawProto = SymbolDraw.prototype; + function symbolNeedsDraw(data, idx, isIgnore) { + var point = data.getItemLayout(idx); + return point && !isNaN(point[0]) && !isNaN(point[1]) && !(isIgnore && isIgnore(idx)) + && data.getItemVisual(idx, 'symbol') !== 'none'; + } /** * Update symbols draw by new data * @param {module:echarts/data/List} data @@ -33,24 +38,21 @@ define(function (require) { data.diff(oldData) .add(function (newIdx) { - if (!(isIgnore && isIgnore(newIdx)) - && data.getItemVisual(newIdx, 'symbol') !== 'none' - ) { + var point = data.getItemLayout(newIdx); + if (symbolNeedsDraw(data, newIdx, isIgnore)) { var symbolEl = new SymbolCtor(data, newIdx); - symbolEl.attr('position', data.getItemLayout(newIdx)); + symbolEl.attr('position', point); data.setItemGraphicEl(newIdx, symbolEl); group.add(symbolEl); } }) .update(function (newIdx, oldIdx) { var symbolEl = oldData.getItemGraphicEl(oldIdx); - if ((isIgnore && isIgnore(newIdx)) - || data.getItemVisual(newIdx, 'symbol') === 'none' - ) { + var point = data.getItemLayout(newIdx); + if (!symbolNeedsDraw(data, newIdx, isIgnore)) { group.remove(symbolEl); return; } - var point = data.getItemLayout(newIdx); if (!symbolEl) { symbolEl = new SymbolCtor(data, newIdx); symbolEl.attr('position', point); diff --git a/src/chart/line/LineView.js b/src/chart/line/LineView.js index aeedb7a70..de22b5062 100644 --- a/src/chart/line/LineView.js +++ b/src/chart/line/LineView.js @@ -329,7 +329,7 @@ define(function(require) { data.setItemGraphicEl(dataIndex, symbol); // Stop scale animation - symbol.stopAnimation(true); + symbol.stopSymbolAnimation(true); this.group.add(symbol); } diff --git a/src/chart/pie/PieView.js b/src/chart/pie/PieView.js index 52957518e..b3ab6eb35 100644 --- a/src/chart/pie/PieView.js +++ b/src/chart/pie/PieView.js @@ -214,7 +214,7 @@ define(function (require) { data.getItemLayout(idx), itemModel.get('selected'), seriesModel.get('selectedOffset'), - seriesModel.ecModel.get('animation') + seriesModel.get('animation') ); function onEmphasis() { -- GitLab