From 445d720b65361d8a985d002964686b6ec6f49a7c Mon Sep 17 00:00:00 2001 From: kener Date: Thu, 15 May 2014 23:47:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chart/bar.js | 57 ++++++++++++---------------- src/chart/calculableBase.js | 4 +- src/chart/chord.js | 14 +++---- src/chart/force.js | 5 ++- src/chart/island.js | 4 +- src/chart/k.js | 19 ++-------- src/chart/line.js | 48 ++++++++++-------------- src/chart/map.js | 75 +++++++++++++++---------------------- src/chart/pie.js | 38 ++++++------------- src/chart/radar.js | 20 ++-------- src/chart/scatter.js | 21 +++-------- 11 files changed, 108 insertions(+), 197 deletions(-) diff --git a/src/chart/bar.js b/src/chart/bar.js index cb499316f..a21a15d87 100644 --- a/src/chart/bar.js +++ b/src/chart/bar.js @@ -28,13 +28,13 @@ define(function (require) { * @param {Object} series 数据 * @param {Object} component 组件 */ - function Bar(ecTheme, messageCenter, zr, option, component){ + function Bar(ecTheme, messageCenter, zr, option, myChart){ // 基类 - ComponentBase.call(this, ecTheme, zr, option); + ComponentBase.call(this, ecTheme, messageCenter, zr, option, myChart); // 可计算特性装饰 CalculableBase.call(this); - this.init(option, component); + this.refresh(option); } Bar.prototype = { @@ -122,9 +122,9 @@ define(function (require) { _mapData : function (seriesArray) { var series = this.series; var serie; // 临时映射变量 - var dataIndex = 0; // 堆叠数据所在位置映射 - var stackMap = {}; // 堆叠数据位置映射,堆叠组在二维中的第几项 - var magicStackKey = '__kener__stack__'; // 堆叠命名,非堆叠数据安单一堆叠处理 + var dataIndex = 0; // 堆积数据所在位置映射 + var stackMap = {}; // 堆积数据位置映射,堆积组在二维中的第几项 + var magicStackKey = '__kener__stack__'; // 堆积命名,非堆积数据安单一堆积处理 var stackKey; // 临时映射变量 var serieName; // 临时映射变量 var legend = this.component.legend; @@ -228,9 +228,9 @@ define(function (require) { var xMarkMap = {}; // 为标注记录一些参数 var x; var y; - var lastYP; // 正向堆叠处理 + var lastYP; // 正向堆积处理 var baseYP; - var lastYN; // 负向堆叠处理 + var lastYN; // 负向堆积处理 var baseYN; var barShape; var data; @@ -242,7 +242,7 @@ define(function (require) { } x = categoryAxis.getCoordByIndex(i) - gap / 2; for (var j = 0, k = locationMap.length; j < k; j++) { - // 堆叠数据用第一条valueAxis + // 堆积数据用第一条valueAxis yAxisIndex = series[locationMap[j][0]].yAxisIndex || 0; valueAxis = this.component.yAxis.getAxis(yAxisIndex); baseYP = lastYP = baseYN = lastYN = valueAxis.getCoord(0); @@ -269,12 +269,12 @@ define(function (require) { } //y = valueAxis.getCoord(value); if (value > 0) { - // 正向堆叠 + // 正向堆积 //barHeight = baseYP - y; barHeight = m > 0 ? valueAxis.getCoordSize(value) : (baseYP - valueAxis.getCoord(value)); - // 非堆叠数据最小高度有效 + // 非堆积数据最小高度有效 if (n == 1 && barMinHeightMap[seriesIndex] > barHeight ) { @@ -284,12 +284,12 @@ define(function (require) { y = lastYP; } else if (value < 0){ - // 负向堆叠 + // 负向堆积 //barHeight = y - baseYN; barHeight = m > 0 ? valueAxis.getCoordSize(value) : (valueAxis.getCoord(value) - baseYN); - // 非堆叠数据最小高度有效 + // 非堆积数据最小高度有效 if (n == 1 && barMinHeightMap[seriesIndex] > barHeight ) { @@ -434,9 +434,9 @@ define(function (require) { var xMarkMap = {}; // 为标注记录一个横向偏移 var x; var y; - var lastXP; // 正向堆叠处理 + var lastXP; // 正向堆积处理 var baseXP; - var lastXN; // 负向堆叠处理 + var lastXN; // 负向堆积处理 var baseXN; var barShape; var data; @@ -448,7 +448,7 @@ define(function (require) { } y = categoryAxis.getCoordByIndex(i) + gap / 2; for (var j = 0, k = locationMap.length; j < k; j++) { - // 堆叠数据用第一条valueAxis + // 堆积数据用第一条valueAxis xAxisIndex = series[locationMap[j][0]].xAxisIndex || 0; valueAxis = this.component.xAxis.getAxis(xAxisIndex); baseXP = lastXP = baseXN = lastXN = valueAxis.getCoord(0); @@ -475,12 +475,12 @@ define(function (require) { } //x = valueAxis.getCoord(value); if (value > 0) { - // 正向堆叠 + // 正向堆积 //barHeight = x - baseXP; barHeight = m > 0 ? valueAxis.getCoordSize(value) : (valueAxis.getCoord(value) - baseXP); - // 非堆叠数据最小高度有效 + // 非堆积数据最小高度有效 if (n == 1 && barMinHeightMap[seriesIndex] > barHeight ) { @@ -490,12 +490,12 @@ define(function (require) { lastXP += barHeight; } else if (value < 0){ - // 负向堆叠 + // 负向堆积 //barHeight = baseXN - x; barHeight = m > 0 ? valueAxis.getCoordSize(value) : (baseXN - valueAxis.getCoord(value)); - // 非堆叠数据最小高度有效 + // 非堆积数据最小高度有效 if (n == 1 && barMinHeightMap[seriesIndex] > barHeight ) { @@ -636,7 +636,7 @@ define(function (require) { var interval = 1; for (var j = 0, k = locationMap.length; j < k; j++) { - hasFound = false; // 同一堆叠第一个barWidth生效 + hasFound = false; // 同一堆积第一个barWidth生效 for (var m = 0, n = locationMap[j].length; m < n; m++) { seriesIndex = locationMap[j][m]; queryTarget = series[seriesIndex]; @@ -647,12 +647,12 @@ define(function (require) { 'barWidth' ); if (typeof sBarWidth != 'undefined') { - // 同一堆叠第一个生效barWidth + // 同一堆积第一个生效barWidth barWidthMap[seriesIndex] = sBarWidth; sBarWidthTotal += sBarWidth; sBarWidthCounter++; hasFound = true; - // 复位前面同一堆叠但没被定义的 + // 复位前面同一堆积但没被定义的 for (var ii = 0, ll = m; ii < ll; ii++) { var pSeriesIndex = locationMap[j][ii]; barWidthMap[pSeriesIndex] = sBarWidth; @@ -917,17 +917,6 @@ define(function (require) { return pos; }, - /** - * 构造函数默认执行的初始化方法,也用于创建实例后动态修改 - * @param {Object} newSeries - * @param {Object} newComponent - */ - init : function (newOption, newComponent) { - this.component = newComponent || this.component; - - this.refresh(newOption); - }, - /** * 刷新 */ diff --git a/src/chart/calculableBase.js b/src/chart/calculableBase.js index 43cb41468..19e778cb0 100644 --- a/src/chart/calculableBase.js +++ b/src/chart/calculableBase.js @@ -317,13 +317,13 @@ define(function (require) { if (newShape._orient != 'vertical') { var y = newShape.style.pointList[0][1]; for (var i = 0; i < len; i++) { - newPointList[i] = [newShape.style.pointList[i][0], y + i]; + newPointList[i] = [newShape.style.pointList[i][0], y]; }; } else { var x = newShape.style.pointList[0][0]; for (var i = 0; i < len; i++) { - newPointList[i] = [x + i, newShape.style.pointList[i][1]]; + newPointList[i] = [x, newShape.style.pointList[i][1]]; }; } if (newShape.type == 'half-smooth-polygon') { diff --git a/src/chart/chord.js b/src/chart/chord.js index 87054bf64..0bff01926 100644 --- a/src/chart/chord.js +++ b/src/chart/chord.js @@ -25,11 +25,13 @@ define(function (require) { var _devicePixelRatio = window.devicePixelRatio || 1; - function Chord(ecTheme, messageCenter, zr, option, component) { - ComponentBase.call(this, ecTheme, zr, option); + function Chord(ecTheme, messageCenter, zr, option, myChart) { + // 基类 + ComponentBase.call(this, ecTheme, messageCenter, zr, option, myChart); + // 可计算特性装饰 CalculableBase.call(this); - this.init(option, component); + this.refresh(option); } Chord.prototype = { @@ -636,12 +638,6 @@ define(function (require) { return [result, unitPostfix]; }, - init : function (newOption, newComponent) { - this.component = newComponent; - - this.refresh(newOption); - }, - refresh : function (newOption) { if (newOption) { this.option = newOption; diff --git a/src/chart/force.js b/src/chart/force.js index 683b2b114..563a4ea46 100644 --- a/src/chart/force.js +++ b/src/chart/force.js @@ -41,12 +41,13 @@ define(function (require) { * @param {Object} series 数据 * @param {Object} component 组件 */ - function Force(ecTheme, messageCenter, zr, option, component) { + function Force(ecTheme, messageCenter, zr, option, myChart) { // 基类 - ComponentBase.call(this, ecTheme, zr, option); + ComponentBase.call(this, ecTheme, messageCenter, zr, option, myChart); // 可计算特性装饰 CalculableBase.call(this); + var component = myChart.component; var legend; var self = this; self.type = ecConfig.CHART_TYPE_FORCE; diff --git a/src/chart/island.js b/src/chart/island.js index 0fc20192c..7f75256b3 100644 --- a/src/chart/island.js +++ b/src/chart/island.js @@ -23,9 +23,9 @@ define(function (require) { * @param {ZRender} zr zrender实例 * @param {Object} option 图表选项 */ - function Island(ecTheme, messageCenter, zr) { + function Island(ecTheme, messageCenter, zr, option, myChart) { // 基类 - ComponentBase.call(this, ecTheme, zr, {}); + ComponentBase.call(this, ecTheme, messageCenter, zr, {}, myChart); // 可计算特性装饰 CalculableBase.call(this); diff --git a/src/chart/k.js b/src/chart/k.js index 949156f7f..18375458a 100644 --- a/src/chart/k.js +++ b/src/chart/k.js @@ -27,13 +27,13 @@ define(function (require) { * @param {Object} series 数据 * @param {Object} component 组件 */ - function K(ecTheme, messageCenter, zr, option, component){ + function K(ecTheme, messageCenter, zr, option, myChart){ // 基类 - ComponentBase.call(this, ecTheme, zr, option); + ComponentBase.call(this, ecTheme, messageCenter, zr, option, myChart); // 可计算特性装饰 CalculableBase.call(this); - this.init(option, component); + this.refresh(option); } K.prototype = { @@ -437,17 +437,6 @@ define(function (require) { ]; }, - /** - * 构造函数默认执行的初始化方法,也用于创建实例后动态修改 - * @param {Object} newSeries - * @param {Object} newComponent - */ - init : function (newOption, newComponent) { - this.component = newComponent || this.component; - - this.refresh(newOption); - }, - /** * 刷新 */ @@ -456,7 +445,7 @@ define(function (require) { this.option = newOption; this.series = newOption.series; } - // this.clear(); + this.backupShapeList(); this._buildShape(); }, diff --git a/src/chart/line.js b/src/chart/line.js index 3872bddc9..f10880f1a 100644 --- a/src/chart/line.js +++ b/src/chart/line.js @@ -30,13 +30,13 @@ define(function (require) { * @param {Object} series 数据 * @param {Object} component 组件 */ - function Line(ecTheme, messageCenter, zr, option, component){ + function Line(ecTheme, messageCenter, zr, option, myChart){ // 基类 - ComponentBase.call(this, ecTheme, zr, option); + ComponentBase.call(this, ecTheme, messageCenter, zr, option, myChart); // 可计算特性装饰 CalculableBase.call(this); - this.init(option, component); + this.refresh(option); } Line.prototype = { @@ -48,7 +48,7 @@ define(function (require) { var series = this.series; this.finalPLMap = {}; // 完成的point list(PL) this._sIndex2ColorMap = {}; // series默认颜色索引,seriesIndex索引到color - this._symbol = this.ecTheme.symbolList; + this._symbol = this.option.symbolList; this._sIndex2ShapeMap = {}; // series拐点图形类型,seriesIndex索引到shape type this.selectedMap = {}; @@ -137,9 +137,9 @@ define(function (require) { _mapData : function (seriesArray) { var series = this.series; var serie; // 临时映射变量 - var dataIndex = 0; // 堆叠数据所在位置映射 - var stackMap = {}; // 堆叠数据位置映射,堆叠组在二维中的第几项 - var magicStackKey = '__kener__stack__'; // 堆叠命名,非堆叠数据安单一堆叠处理 + var dataIndex = 0; // 堆积数据所在位置映射 + var stackMap = {}; // 堆积数据位置映射,堆积组在二维中的第几项 + var magicStackKey = '__kener__stack__'; // 堆积命名,非堆积数据安单一堆积处理 var stackKey; // 临时映射变量 var serieName; // 临时映射变量 var legend = this.component.legend; @@ -232,9 +232,9 @@ define(function (require) { var x; var y; - var lastYP; // 正向堆叠处理 + var lastYP; // 正向堆积处理 var baseYP; - var lastYN; // 负向堆叠处理 + var lastYN; // 负向堆积处理 var baseYN; //var this.finalPLMap = {}; // 完成的point list(PL) var curPLMap = {}; // 正在记录的point list(PL) @@ -247,7 +247,7 @@ define(function (require) { } x = categoryAxis.getCoordByIndex(i); for (var j = 0, k = locationMap.length; j < k; j++) { - // 堆叠数据用第一条valueAxis + // 堆积数据用第一条valueAxis yAxisIndex = series[locationMap[j][0]].yAxisIndex || 0; valueAxis = this.component.yAxis.getAxis(yAxisIndex); baseYP = lastYP = baseYN = lastYN = valueAxis.getCoord(0); @@ -285,14 +285,14 @@ define(function (require) { } //y = valueAxis.getCoord(value); if (value >= 0) { - // 正向堆叠 + // 正向堆积 lastYP -= m > 0 ? valueAxis.getCoordSize(value) : (baseYP - valueAxis.getCoord(value)); y = lastYP; } else if (value < 0){ - // 负向堆叠 + // 负向堆积 lastYN += m > 0 ? valueAxis.getCoordSize(value) : (valueAxis.getCoord(value) - baseYN); @@ -405,9 +405,9 @@ define(function (require) { var x; var y; - var lastXP; // 正向堆叠处理 + var lastXP; // 正向堆积处理 var baseXP; - var lastXN; // 负向堆叠处理 + var lastXN; // 负向堆积处理 var baseXN; //var this.finalPLMap = {}; // 完成的point list(PL) var curPLMap = {}; // 正在记录的point list(PL) @@ -420,7 +420,7 @@ define(function (require) { } y = categoryAxis.getCoordByIndex(i); for (var j = 0, k = locationMap.length; j < k; j++) { - // 堆叠数据用第一条valueAxis + // 堆积数据用第一条valueAxis xAxisIndex = series[locationMap[j][0]].xAxisIndex || 0; valueAxis = this.component.xAxis.getAxis(xAxisIndex); baseXP = lastXP = baseXN = lastXN = valueAxis.getCoord(0); @@ -458,14 +458,14 @@ define(function (require) { } //x = valueAxis.getCoord(value); if (value >= 0) { - // 正向堆叠 + // 正向堆积 lastXP += m > 0 ? valueAxis.getCoordSize(value) : (valueAxis.getCoord(value) - baseXP); x = lastXP; } else if (value < 0){ - // 负向堆叠 + // 负向堆积 lastXN -= m > 0 ? valueAxis.getCoordSize(value) : (baseXN - valueAxis.getCoord(value)); @@ -590,7 +590,7 @@ define(function (require) { var isLarge; - // 堆叠层叠需求,反顺序构建 + // 堆积层叠需求,反顺序构建 var seriesIndex; for (var sIdx = seriesArray.length - 1; sIdx >= 0; sIdx--) { seriesIndex = seriesArray[sIdx]; @@ -863,17 +863,6 @@ define(function (require) { ]; }, - /** - * 构造函数默认执行的初始化方法,也用于创建实例后动态修改 - * @param {Object} newSeries - * @param {Object} newComponent - */ - init : function (newOption, newComponent) { - this.component = newComponent || this.component; - - this.refresh(newOption); - }, - /** * 刷新 */ @@ -882,6 +871,7 @@ define(function (require) { this.option = newOption; this.series = newOption.series; } + this.backupShapeList(); this._buildShape(); }, diff --git a/src/chart/map.js b/src/chart/map.js index a172cba8d..d9fad883d 100644 --- a/src/chart/map.js +++ b/src/chart/map.js @@ -33,14 +33,12 @@ define(function (require) { * @param {Object} series 数据 * @param {Object} component 组件 */ - function Map(ecTheme, messageCenter, zr, option, component){ + function Map(ecTheme, messageCenter, zr, option, myChart){ // 基类 - ComponentBase.call(this, ecTheme, zr, option); + ComponentBase.call(this, ecTheme, messageCenter, zr, option, myChart); // 可计算特性装饰 CalculableBase.call(this); - this.messageCenter = messageCenter; - var self = this; self._onmousewheel = function(param){ return self.__onmousewheel(param); @@ -55,7 +53,33 @@ define(function (require) { return self.__onmouseup(param); }; - this.init(option, component); + this._isAlive = true; // 活着标记 + this._selectedMode = {}; // 选择模式 + this._hoverable = {}; // 悬浮高亮模式,索引到图表 + this._showLegendSymbol = {}; // 显示图例颜色标识 + this._selected = {}; // 地图选择状态 + this._mapTypeMap = {}; // 图例类型索引 + this._mapDataMap = {}; // 根据地图类型索引bbox,transform,path + this._nameMap = {}; // 个性化地名 + this._specialArea = {}; // 特殊 + this._refreshDelayTicket; // 滚轮缩放时让refresh飞一会 + this._mapDataRequireCounter; // 异步回调计数器 + this._markAnimation = false; + + // 漫游相关信息 + this._roamMap = {}; + this._needRoam; + this._mx; + this._my; + this._mousedown; + this._justMove; // 避免移动响应点击 + this._curMapType; // 当前移动的地图类型 + + this.refresh(option); + if (this._needRoam) { + this.zr.on(zrConfig.EVENT.MOUSEWHEEL, this._onmousewheel); + this.zr.on(zrConfig.EVENT.MOUSEDOWN, this._onmousedown); + } } Map.prototype = { @@ -1145,46 +1169,6 @@ define(function (require) { this.zr.refresh(); }, - - /** - * 构造函数默认执行的初始化方法,也用于创建实例后动态修改 - * @param {Object} newSeries - * @param {Object} newComponent - */ - init : function (newOption, newComponent) { - this.component = newComponent; - this._isAlive = true; // 活着标记 - - this._selectedMode = {}; // 选择模式 - this._hoverable = {}; // 悬浮高亮模式,索引到图表 - this._showLegendSymbol = {}; // 显示图例颜色标识 - this._selected = {}; // 地图选择状态 - this._mapTypeMap = {}; // 图例类型索引 - this._mapDataMap = {}; // 根据地图类型索引bbox,transform,path - this._nameMap = {}; // 个性化地名 - this._specialArea = {}; // 特殊 - this._refreshDelayTicket; // 滚轮缩放时让refresh飞一会 - this._mapDataRequireCounter; - - // 漫游相关信息 - this._roamMap = {}; - this._needRoam; - this._mx; - this._my; - this._mousedown; - this._justMove; // 避免移动响应点击 - this._curMapType; // 当前移动的地图类型 - - this._markAnimation = false; - - this.refresh(newOption); - - if (this._needRoam) { - this.zr.on(zrConfig.EVENT.MOUSEWHEEL, this._onmousewheel); - this.zr.on(zrConfig.EVENT.MOUSEDOWN, this._onmousedown); - } - }, - /** * 刷新 */ @@ -1193,6 +1177,7 @@ define(function (require) { this.option = newOption; this.series = newOption.series; } + this.clear(); this._buildShape(); this.zr.refreshHover(); diff --git a/src/chart/pie.js b/src/chart/pie.js index 645f2cc9e..766206379 100644 --- a/src/chart/pie.js +++ b/src/chart/pie.js @@ -29,14 +29,12 @@ define(function (require) { * @param {Object} series 数据 * @param {Object} component 组件 */ - function Pie(ecTheme, messageCenter, zr, option, component){ + function Pie(ecTheme, messageCenter, zr, option, myChart){ // 基类 - ComponentBase.call(this, ecTheme, zr, option); + ComponentBase.call(this, ecTheme, messageCenter, zr, option, myChart); // 可计算特性装饰 CalculableBase.call(this); - this.messageCenter = messageCenter; - var self = this; /** * 输出动态视觉引导线 @@ -74,7 +72,7 @@ define(function (require) { } }; - this.init(option, component); + this.refresh(option); } Pie.prototype = { @@ -704,17 +702,6 @@ define(function (require) { return opt; }, - /** - * 构造函数默认执行的初始化方法,也用于创建实例后动态修改 - * @param {Object} newSeries - * @param {Object} newComponent - */ - init : function (newOption, newComponent) { - this.component = newComponent || this.component; - - this.refresh(newOption); - }, - /** * 刷新 */ @@ -742,7 +729,7 @@ define(function (require) { var sectorMap = {}; var textMap = {}; var lineMap = {}; - var backupShapeList = zrUtil.clone(this.shapeList); + var backupShapeList = this.shapeList; this.shapeList = []; var seriesIndex; @@ -792,7 +779,7 @@ define(function (require) { case 'text' : textMap[key] = this.shapeList[i]; break; - case 'line' : + case 'broken-line' : lineMap[key] = this.shapeList[i]; break; } @@ -831,11 +818,11 @@ define(function (require) { 400, deltaIdxMap[seriesIndex] < 0 ? { - endAngle : + startAngle : backupShapeList[i].style.startAngle } : { - startAngle : + endAngle : backupShapeList[i].style.endAngle } ) @@ -843,7 +830,7 @@ define(function (require) { } } else if (backupShapeList[i].type == 'text' - || backupShapeList[i].type == 'line' + || backupShapeList[i].type == 'broken-line' ) { if (targeSector == 'delete') { // 删除逻辑一样 @@ -851,7 +838,7 @@ define(function (require) { } else { // 懒得新建变量了,借用一下 - switch (backupShapeList[i].shape) { + switch (backupShapeList[i].type) { case 'text': targeSector = textMap[key]; this.zr.animate(backupShapeList[i].id, 'style') @@ -864,16 +851,13 @@ define(function (require) { ) .start(); break; - case 'line': + case 'broken-line': targeSector = lineMap[key]; this.zr.animate(backupShapeList[i].id, 'style') .when( 400, { - xStart:targeSector.style.xStart, - yStart:targeSector.style.yStart, - xEnd : targeSector.style.xEnd, - yEnd : targeSector.style.yEnd + pointList:targeSector.style.pointList } ) .start(); diff --git a/src/chart/radar.js b/src/chart/radar.js index 52c45eb11..8a2ae49e2 100644 --- a/src/chart/radar.js +++ b/src/chart/radar.js @@ -27,13 +27,13 @@ * @param {Object} series 数据 * @param {Object} component 组件 */ - function Radar(ecTheme, messageCenter, zr, option, component) { + function Radar(ecTheme, messageCenter, zr, option, myChart) { // 基类 - ComponentBase.call(this, ecTheme, zr, option); + ComponentBase.call(this, ecTheme, messageCenter, zr, option, myChart); // 可计算特性装饰 CalculableBase.call(this); - this.init(option, component); + this.refresh(option); } Radar.prototype = { @@ -43,7 +43,7 @@ */ _buildShape : function () { this.selectedMap = {}; - this._symbol = this.ecTheme.symbolList; + this._symbol = this.option.symbolList; this._queryTarget; this._dropBoxList = []; this._radarDataCounter = 0; @@ -390,18 +390,6 @@ return; }, - /** - * 构造函数默认执行的初始化方法,也用于创建实例后动态修改 - * @param {Object} newZr - * @param {Object} newSeries - * @param {Object} newComponent - */ - init : function (newOption, newComponent) { - this.component = newComponent || this.component; - - this.refresh(newOption); - }, - /** * 刷新 */ diff --git a/src/chart/scatter.js b/src/chart/scatter.js index a44db9f19..1f230dcbb 100644 --- a/src/chart/scatter.js +++ b/src/chart/scatter.js @@ -28,13 +28,13 @@ define(function (require) { * @param {Object} series 数据 * @param {Object} component 组件 */ - function Scatter(ecTheme, messageCenter, zr, option, component){ + function Scatter(ecTheme, messageCenter, zr, option, myChart){ // 基类 - ComponentBase.call(this, ecTheme, zr, option); + ComponentBase.call(this, ecTheme, messageCenter, zr, option, myChart); // 可计算特性装饰 CalculableBase.call(this); - this.init(option, component); + this.refresh(option); } Scatter.prototype = { @@ -45,7 +45,7 @@ define(function (require) { _buildShape : function () { var series = this.series; this._sIndex2ColorMap = {}; // series默认颜色索引,seriesIndex索引到color - this._symbol = ecConfig.symbolList; + this._symbol = this.option.symbolList; this._sIndex2ShapeMap = {}; // series图形类型,seriesIndex索引到_symbol this.selectedMap = {}; @@ -437,18 +437,6 @@ define(function (require) { return pos; }, - /** - * 构造函数默认执行的初始化方法,也用于创建实例后动态修改 - * @param {Object} newZr - * @param {Object} newSeries - * @param {Object} newComponent - */ - init : function (newOption, newComponent) { - this.component = newComponent; - - this.refresh(newOption); - }, - /** * 刷新 */ @@ -457,6 +445,7 @@ define(function (require) { this.option = newOption; this.series = newOption.series; } + this.backupShapeList(); this._buildShape(); }, -- GitLab