From 58336fc9493d38f064134540298434227b8e2a96 Mon Sep 17 00:00:00 2001 From: kener Date: Mon, 5 May 2014 01:53:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A8=E7=94=BB=E8=BF=87=E6=B8=A1=E5=8D=87?= =?UTF-8?q?=E7=BA=A7=20scatter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chart/calculableBase.js | 4 +++- src/chart/scatter.js | 20 +++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/chart/calculableBase.js b/src/chart/calculableBase.js index 952486422..c774e3d37 100644 --- a/src/chart/calculableBase.js +++ b/src/chart/calculableBase.js @@ -178,12 +178,13 @@ define(function (require) { }, addShapeList : function() { + var maxLenth = this.option.animationThreshold / (this.canvasSupported ? 1 : 2); var lastShapeList = this.lastShapeList; var shapeList = this.shapeList; var key; var oldMap = {}; var newMap = {}; - if (lastShapeList && lastShapeList.length > 0) { + if (lastShapeList && lastShapeList.length > 0 && lastShapeList.length < maxLenth) { // 通过已有的shape做动画过渡 for (var i = 0, l = this.lastShapeList.length; i < l; i++) { key = ecData.get(lastShapeList[i], 'seriesIndex') + '_' @@ -265,6 +266,7 @@ define(function (require) { .start('ExponentialOut'); break; case 'rectangle' : + case 'icon' : var newX = newShape.style.x; var newY = newShape.style.y; var newWidth = newShape.style.width; diff --git a/src/chart/scatter.js b/src/chart/scatter.js index 4b4bc5b9a..9dd81fde9 100644 --- a/src/chart/scatter.js +++ b/src/chart/scatter.js @@ -112,20 +112,19 @@ define(function (require) { } } } - if (seriesArray.length === 0) { - return; - } + this._buildSeries(seriesArray); - - for (var i = 0, l = this.shapeList.length; i < l; i++) { - this.zr.addShape(this.shapeList[i]); - } + + this.addShapeList(); }, /** * 构建类目轴为水平方向的散点图系列 */ _buildSeries : function (seriesArray) { + if (seriesArray.length === 0) { + return; + } var series = this.series; var seriesIndex; var serie; @@ -384,7 +383,6 @@ define(function (require) { 'vertical' ); itemShape.zlevel = this._zlevelBase; - itemShape._mark = false; // 非mark itemShape._main = true; return itemShape; }, @@ -459,7 +457,7 @@ define(function (require) { this.option = newOption; this.series = newOption.series; } - this.clear(); + this.backupShapeList(); this._buildShape(); }, @@ -480,6 +478,10 @@ define(function (require) { * 动画设定 */ animation : function () { + if (this.lastShapeList && this.lastShapeList.length > 0) { + return; + } + var series = this.series; var duration = this.query(this.option, 'animationDuration'); var easing = this.query(this.option, 'animationEasing'); -- GitLab