提交 445d720b 编写于 作者: K kener

代码优化

上级 fc0259da
...@@ -28,13 +28,13 @@ define(function (require) { ...@@ -28,13 +28,13 @@ define(function (require) {
* @param {Object} series 数据 * @param {Object} series 数据
* @param {Object} component 组件 * @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); CalculableBase.call(this);
this.init(option, component); this.refresh(option);
} }
Bar.prototype = { Bar.prototype = {
...@@ -122,9 +122,9 @@ define(function (require) { ...@@ -122,9 +122,9 @@ define(function (require) {
_mapData : function (seriesArray) { _mapData : function (seriesArray) {
var series = this.series; var series = this.series;
var serie; // 临时映射变量 var serie; // 临时映射变量
var dataIndex = 0; // 堆数据所在位置映射 var dataIndex = 0; // 堆数据所在位置映射
var stackMap = {}; // 堆叠数据位置映射,堆叠组在二维中的第几项 var stackMap = {}; // 堆积数据位置映射,堆积组在二维中的第几项
var magicStackKey = '__kener__stack__'; // 堆叠命名,非堆叠数据安单一堆叠处理 var magicStackKey = '__kener__stack__'; // 堆积命名,非堆积数据安单一堆积处理
var stackKey; // 临时映射变量 var stackKey; // 临时映射变量
var serieName; // 临时映射变量 var serieName; // 临时映射变量
var legend = this.component.legend; var legend = this.component.legend;
...@@ -228,9 +228,9 @@ define(function (require) { ...@@ -228,9 +228,9 @@ define(function (require) {
var xMarkMap = {}; // 为标注记录一些参数 var xMarkMap = {}; // 为标注记录一些参数
var x; var x;
var y; var y;
var lastYP; // 正向堆处理 var lastYP; // 正向堆处理
var baseYP; var baseYP;
var lastYN; // 负向堆处理 var lastYN; // 负向堆处理
var baseYN; var baseYN;
var barShape; var barShape;
var data; var data;
...@@ -242,7 +242,7 @@ define(function (require) { ...@@ -242,7 +242,7 @@ define(function (require) {
} }
x = categoryAxis.getCoordByIndex(i) - gap / 2; x = categoryAxis.getCoordByIndex(i) - gap / 2;
for (var j = 0, k = locationMap.length; j < k; j++) { for (var j = 0, k = locationMap.length; j < k; j++) {
// 堆数据用第一条valueAxis // 堆数据用第一条valueAxis
yAxisIndex = series[locationMap[j][0]].yAxisIndex || 0; yAxisIndex = series[locationMap[j][0]].yAxisIndex || 0;
valueAxis = this.component.yAxis.getAxis(yAxisIndex); valueAxis = this.component.yAxis.getAxis(yAxisIndex);
baseYP = lastYP = baseYN = lastYN = valueAxis.getCoord(0); baseYP = lastYP = baseYN = lastYN = valueAxis.getCoord(0);
...@@ -269,12 +269,12 @@ define(function (require) { ...@@ -269,12 +269,12 @@ define(function (require) {
} }
//y = valueAxis.getCoord(value); //y = valueAxis.getCoord(value);
if (value > 0) { if (value > 0) {
// 正向堆 // 正向堆
//barHeight = baseYP - y; //barHeight = baseYP - y;
barHeight = m > 0 barHeight = m > 0
? valueAxis.getCoordSize(value) ? valueAxis.getCoordSize(value)
: (baseYP - valueAxis.getCoord(value)); : (baseYP - valueAxis.getCoord(value));
// 非堆数据最小高度有效 // 非堆数据最小高度有效
if (n == 1 if (n == 1
&& barMinHeightMap[seriesIndex] > barHeight && barMinHeightMap[seriesIndex] > barHeight
) { ) {
...@@ -284,12 +284,12 @@ define(function (require) { ...@@ -284,12 +284,12 @@ define(function (require) {
y = lastYP; y = lastYP;
} }
else if (value < 0){ else if (value < 0){
// 负向堆 // 负向堆
//barHeight = y - baseYN; //barHeight = y - baseYN;
barHeight = m > 0 barHeight = m > 0
? valueAxis.getCoordSize(value) ? valueAxis.getCoordSize(value)
: (valueAxis.getCoord(value) - baseYN); : (valueAxis.getCoord(value) - baseYN);
// 非堆数据最小高度有效 // 非堆数据最小高度有效
if (n == 1 if (n == 1
&& barMinHeightMap[seriesIndex] > barHeight && barMinHeightMap[seriesIndex] > barHeight
) { ) {
...@@ -434,9 +434,9 @@ define(function (require) { ...@@ -434,9 +434,9 @@ define(function (require) {
var xMarkMap = {}; // 为标注记录一个横向偏移 var xMarkMap = {}; // 为标注记录一个横向偏移
var x; var x;
var y; var y;
var lastXP; // 正向堆处理 var lastXP; // 正向堆处理
var baseXP; var baseXP;
var lastXN; // 负向堆处理 var lastXN; // 负向堆处理
var baseXN; var baseXN;
var barShape; var barShape;
var data; var data;
...@@ -448,7 +448,7 @@ define(function (require) { ...@@ -448,7 +448,7 @@ define(function (require) {
} }
y = categoryAxis.getCoordByIndex(i) + gap / 2; y = categoryAxis.getCoordByIndex(i) + gap / 2;
for (var j = 0, k = locationMap.length; j < k; j++) { for (var j = 0, k = locationMap.length; j < k; j++) {
// 堆数据用第一条valueAxis // 堆数据用第一条valueAxis
xAxisIndex = series[locationMap[j][0]].xAxisIndex || 0; xAxisIndex = series[locationMap[j][0]].xAxisIndex || 0;
valueAxis = this.component.xAxis.getAxis(xAxisIndex); valueAxis = this.component.xAxis.getAxis(xAxisIndex);
baseXP = lastXP = baseXN = lastXN = valueAxis.getCoord(0); baseXP = lastXP = baseXN = lastXN = valueAxis.getCoord(0);
...@@ -475,12 +475,12 @@ define(function (require) { ...@@ -475,12 +475,12 @@ define(function (require) {
} }
//x = valueAxis.getCoord(value); //x = valueAxis.getCoord(value);
if (value > 0) { if (value > 0) {
// 正向堆 // 正向堆
//barHeight = x - baseXP; //barHeight = x - baseXP;
barHeight = m > 0 barHeight = m > 0
? valueAxis.getCoordSize(value) ? valueAxis.getCoordSize(value)
: (valueAxis.getCoord(value) - baseXP); : (valueAxis.getCoord(value) - baseXP);
// 非堆数据最小高度有效 // 非堆数据最小高度有效
if (n == 1 if (n == 1
&& barMinHeightMap[seriesIndex] > barHeight && barMinHeightMap[seriesIndex] > barHeight
) { ) {
...@@ -490,12 +490,12 @@ define(function (require) { ...@@ -490,12 +490,12 @@ define(function (require) {
lastXP += barHeight; lastXP += barHeight;
} }
else if (value < 0){ else if (value < 0){
// 负向堆 // 负向堆
//barHeight = baseXN - x; //barHeight = baseXN - x;
barHeight = m > 0 barHeight = m > 0
? valueAxis.getCoordSize(value) ? valueAxis.getCoordSize(value)
: (baseXN - valueAxis.getCoord(value)); : (baseXN - valueAxis.getCoord(value));
// 非堆数据最小高度有效 // 非堆数据最小高度有效
if (n == 1 if (n == 1
&& barMinHeightMap[seriesIndex] > barHeight && barMinHeightMap[seriesIndex] > barHeight
) { ) {
...@@ -636,7 +636,7 @@ define(function (require) { ...@@ -636,7 +636,7 @@ define(function (require) {
var interval = 1; var interval = 1;
for (var j = 0, k = locationMap.length; j < k; j++) { 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++) { for (var m = 0, n = locationMap[j].length; m < n; m++) {
seriesIndex = locationMap[j][m]; seriesIndex = locationMap[j][m];
queryTarget = series[seriesIndex]; queryTarget = series[seriesIndex];
...@@ -647,12 +647,12 @@ define(function (require) { ...@@ -647,12 +647,12 @@ define(function (require) {
'barWidth' 'barWidth'
); );
if (typeof sBarWidth != 'undefined') { if (typeof sBarWidth != 'undefined') {
// 同一堆第一个生效barWidth // 同一堆第一个生效barWidth
barWidthMap[seriesIndex] = sBarWidth; barWidthMap[seriesIndex] = sBarWidth;
sBarWidthTotal += sBarWidth; sBarWidthTotal += sBarWidth;
sBarWidthCounter++; sBarWidthCounter++;
hasFound = true; hasFound = true;
// 复位前面同一堆但没被定义的 // 复位前面同一堆但没被定义的
for (var ii = 0, ll = m; ii < ll; ii++) { for (var ii = 0, ll = m; ii < ll; ii++) {
var pSeriesIndex = locationMap[j][ii]; var pSeriesIndex = locationMap[j][ii];
barWidthMap[pSeriesIndex] = sBarWidth; barWidthMap[pSeriesIndex] = sBarWidth;
...@@ -917,17 +917,6 @@ define(function (require) { ...@@ -917,17 +917,6 @@ define(function (require) {
return pos; return pos;
}, },
/**
* 构造函数默认执行的初始化方法,也用于创建实例后动态修改
* @param {Object} newSeries
* @param {Object} newComponent
*/
init : function (newOption, newComponent) {
this.component = newComponent || this.component;
this.refresh(newOption);
},
/** /**
* 刷新 * 刷新
*/ */
......
...@@ -317,13 +317,13 @@ define(function (require) { ...@@ -317,13 +317,13 @@ define(function (require) {
if (newShape._orient != 'vertical') { if (newShape._orient != 'vertical') {
var y = newShape.style.pointList[0][1]; var y = newShape.style.pointList[0][1];
for (var i = 0; i < len; i++) { 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 { else {
var x = newShape.style.pointList[0][0]; var x = newShape.style.pointList[0][0];
for (var i = 0; i < len; i++) { 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') { if (newShape.type == 'half-smooth-polygon') {
......
...@@ -25,11 +25,13 @@ define(function (require) { ...@@ -25,11 +25,13 @@ define(function (require) {
var _devicePixelRatio = window.devicePixelRatio || 1; var _devicePixelRatio = window.devicePixelRatio || 1;
function Chord(ecTheme, messageCenter, zr, option, component) { function Chord(ecTheme, messageCenter, zr, option, myChart) {
ComponentBase.call(this, ecTheme, zr, option); // 基类
ComponentBase.call(this, ecTheme, messageCenter, zr, option, myChart);
// 可计算特性装饰
CalculableBase.call(this); CalculableBase.call(this);
this.init(option, component); this.refresh(option);
} }
Chord.prototype = { Chord.prototype = {
...@@ -636,12 +638,6 @@ define(function (require) { ...@@ -636,12 +638,6 @@ define(function (require) {
return [result, unitPostfix]; return [result, unitPostfix];
}, },
init : function (newOption, newComponent) {
this.component = newComponent;
this.refresh(newOption);
},
refresh : function (newOption) { refresh : function (newOption) {
if (newOption) { if (newOption) {
this.option = newOption; this.option = newOption;
......
...@@ -41,12 +41,13 @@ define(function (require) { ...@@ -41,12 +41,13 @@ define(function (require) {
* @param {Object} series 数据 * @param {Object} series 数据
* @param {Object} component 组件 * @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); CalculableBase.call(this);
var component = myChart.component;
var legend; var legend;
var self = this; var self = this;
self.type = ecConfig.CHART_TYPE_FORCE; self.type = ecConfig.CHART_TYPE_FORCE;
......
...@@ -23,9 +23,9 @@ define(function (require) { ...@@ -23,9 +23,9 @@ define(function (require) {
* @param {ZRender} zr zrender实例 * @param {ZRender} zr zrender实例
* @param {Object} option 图表选项 * @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); CalculableBase.call(this);
......
...@@ -27,13 +27,13 @@ define(function (require) { ...@@ -27,13 +27,13 @@ define(function (require) {
* @param {Object} series 数据 * @param {Object} series 数据
* @param {Object} component 组件 * @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); CalculableBase.call(this);
this.init(option, component); this.refresh(option);
} }
K.prototype = { K.prototype = {
...@@ -437,17 +437,6 @@ define(function (require) { ...@@ -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) { ...@@ -456,7 +445,7 @@ define(function (require) {
this.option = newOption; this.option = newOption;
this.series = newOption.series; this.series = newOption.series;
} }
// this.clear();
this.backupShapeList(); this.backupShapeList();
this._buildShape(); this._buildShape();
}, },
......
...@@ -30,13 +30,13 @@ define(function (require) { ...@@ -30,13 +30,13 @@ define(function (require) {
* @param {Object} series 数据 * @param {Object} series 数据
* @param {Object} component 组件 * @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); CalculableBase.call(this);
this.init(option, component); this.refresh(option);
} }
Line.prototype = { Line.prototype = {
...@@ -48,7 +48,7 @@ define(function (require) { ...@@ -48,7 +48,7 @@ define(function (require) {
var series = this.series; var series = this.series;
this.finalPLMap = {}; // 完成的point list(PL) this.finalPLMap = {}; // 完成的point list(PL)
this._sIndex2ColorMap = {}; // series默认颜色索引,seriesIndex索引到color this._sIndex2ColorMap = {}; // series默认颜色索引,seriesIndex索引到color
this._symbol = this.ecTheme.symbolList; this._symbol = this.option.symbolList;
this._sIndex2ShapeMap = {}; // series拐点图形类型,seriesIndex索引到shape type this._sIndex2ShapeMap = {}; // series拐点图形类型,seriesIndex索引到shape type
this.selectedMap = {}; this.selectedMap = {};
...@@ -137,9 +137,9 @@ define(function (require) { ...@@ -137,9 +137,9 @@ define(function (require) {
_mapData : function (seriesArray) { _mapData : function (seriesArray) {
var series = this.series; var series = this.series;
var serie; // 临时映射变量 var serie; // 临时映射变量
var dataIndex = 0; // 堆数据所在位置映射 var dataIndex = 0; // 堆数据所在位置映射
var stackMap = {}; // 堆叠数据位置映射,堆叠组在二维中的第几项 var stackMap = {}; // 堆积数据位置映射,堆积组在二维中的第几项
var magicStackKey = '__kener__stack__'; // 堆叠命名,非堆叠数据安单一堆叠处理 var magicStackKey = '__kener__stack__'; // 堆积命名,非堆积数据安单一堆积处理
var stackKey; // 临时映射变量 var stackKey; // 临时映射变量
var serieName; // 临时映射变量 var serieName; // 临时映射变量
var legend = this.component.legend; var legend = this.component.legend;
...@@ -232,9 +232,9 @@ define(function (require) { ...@@ -232,9 +232,9 @@ define(function (require) {
var x; var x;
var y; var y;
var lastYP; // 正向堆处理 var lastYP; // 正向堆处理
var baseYP; var baseYP;
var lastYN; // 负向堆处理 var lastYN; // 负向堆处理
var baseYN; var baseYN;
//var this.finalPLMap = {}; // 完成的point list(PL) //var this.finalPLMap = {}; // 完成的point list(PL)
var curPLMap = {}; // 正在记录的point list(PL) var curPLMap = {}; // 正在记录的point list(PL)
...@@ -247,7 +247,7 @@ define(function (require) { ...@@ -247,7 +247,7 @@ define(function (require) {
} }
x = categoryAxis.getCoordByIndex(i); x = categoryAxis.getCoordByIndex(i);
for (var j = 0, k = locationMap.length; j < k; j++) { for (var j = 0, k = locationMap.length; j < k; j++) {
// 堆数据用第一条valueAxis // 堆数据用第一条valueAxis
yAxisIndex = series[locationMap[j][0]].yAxisIndex || 0; yAxisIndex = series[locationMap[j][0]].yAxisIndex || 0;
valueAxis = this.component.yAxis.getAxis(yAxisIndex); valueAxis = this.component.yAxis.getAxis(yAxisIndex);
baseYP = lastYP = baseYN = lastYN = valueAxis.getCoord(0); baseYP = lastYP = baseYN = lastYN = valueAxis.getCoord(0);
...@@ -285,14 +285,14 @@ define(function (require) { ...@@ -285,14 +285,14 @@ define(function (require) {
} }
//y = valueAxis.getCoord(value); //y = valueAxis.getCoord(value);
if (value >= 0) { if (value >= 0) {
// 正向堆 // 正向堆
lastYP -= m > 0 lastYP -= m > 0
? valueAxis.getCoordSize(value) ? valueAxis.getCoordSize(value)
: (baseYP - valueAxis.getCoord(value)); : (baseYP - valueAxis.getCoord(value));
y = lastYP; y = lastYP;
} }
else if (value < 0){ else if (value < 0){
// 负向堆 // 负向堆
lastYN += m > 0 lastYN += m > 0
? valueAxis.getCoordSize(value) ? valueAxis.getCoordSize(value)
: (valueAxis.getCoord(value) - baseYN); : (valueAxis.getCoord(value) - baseYN);
...@@ -405,9 +405,9 @@ define(function (require) { ...@@ -405,9 +405,9 @@ define(function (require) {
var x; var x;
var y; var y;
var lastXP; // 正向堆处理 var lastXP; // 正向堆处理
var baseXP; var baseXP;
var lastXN; // 负向堆处理 var lastXN; // 负向堆处理
var baseXN; var baseXN;
//var this.finalPLMap = {}; // 完成的point list(PL) //var this.finalPLMap = {}; // 完成的point list(PL)
var curPLMap = {}; // 正在记录的point list(PL) var curPLMap = {}; // 正在记录的point list(PL)
...@@ -420,7 +420,7 @@ define(function (require) { ...@@ -420,7 +420,7 @@ define(function (require) {
} }
y = categoryAxis.getCoordByIndex(i); y = categoryAxis.getCoordByIndex(i);
for (var j = 0, k = locationMap.length; j < k; j++) { for (var j = 0, k = locationMap.length; j < k; j++) {
// 堆数据用第一条valueAxis // 堆数据用第一条valueAxis
xAxisIndex = series[locationMap[j][0]].xAxisIndex || 0; xAxisIndex = series[locationMap[j][0]].xAxisIndex || 0;
valueAxis = this.component.xAxis.getAxis(xAxisIndex); valueAxis = this.component.xAxis.getAxis(xAxisIndex);
baseXP = lastXP = baseXN = lastXN = valueAxis.getCoord(0); baseXP = lastXP = baseXN = lastXN = valueAxis.getCoord(0);
...@@ -458,14 +458,14 @@ define(function (require) { ...@@ -458,14 +458,14 @@ define(function (require) {
} }
//x = valueAxis.getCoord(value); //x = valueAxis.getCoord(value);
if (value >= 0) { if (value >= 0) {
// 正向堆 // 正向堆
lastXP += m > 0 lastXP += m > 0
? valueAxis.getCoordSize(value) ? valueAxis.getCoordSize(value)
: (valueAxis.getCoord(value) - baseXP); : (valueAxis.getCoord(value) - baseXP);
x = lastXP; x = lastXP;
} }
else if (value < 0){ else if (value < 0){
// 负向堆 // 负向堆
lastXN -= m > 0 lastXN -= m > 0
? valueAxis.getCoordSize(value) ? valueAxis.getCoordSize(value)
: (baseXN - valueAxis.getCoord(value)); : (baseXN - valueAxis.getCoord(value));
...@@ -590,7 +590,7 @@ define(function (require) { ...@@ -590,7 +590,7 @@ define(function (require) {
var isLarge; var isLarge;
// 堆层叠需求,反顺序构建 // 堆层叠需求,反顺序构建
var seriesIndex; var seriesIndex;
for (var sIdx = seriesArray.length - 1; sIdx >= 0; sIdx--) { for (var sIdx = seriesArray.length - 1; sIdx >= 0; sIdx--) {
seriesIndex = seriesArray[sIdx]; seriesIndex = seriesArray[sIdx];
...@@ -863,17 +863,6 @@ define(function (require) { ...@@ -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) { ...@@ -882,6 +871,7 @@ define(function (require) {
this.option = newOption; this.option = newOption;
this.series = newOption.series; this.series = newOption.series;
} }
this.backupShapeList(); this.backupShapeList();
this._buildShape(); this._buildShape();
}, },
......
...@@ -33,14 +33,12 @@ define(function (require) { ...@@ -33,14 +33,12 @@ define(function (require) {
* @param {Object} series 数据 * @param {Object} series 数据
* @param {Object} component 组件 * @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); CalculableBase.call(this);
this.messageCenter = messageCenter;
var self = this; var self = this;
self._onmousewheel = function(param){ self._onmousewheel = function(param){
return self.__onmousewheel(param); return self.__onmousewheel(param);
...@@ -55,7 +53,33 @@ define(function (require) { ...@@ -55,7 +53,33 @@ define(function (require) {
return self.__onmouseup(param); 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 = { Map.prototype = {
...@@ -1145,46 +1169,6 @@ define(function (require) { ...@@ -1145,46 +1169,6 @@ define(function (require) {
this.zr.refresh(); 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) { ...@@ -1193,6 +1177,7 @@ define(function (require) {
this.option = newOption; this.option = newOption;
this.series = newOption.series; this.series = newOption.series;
} }
this.clear(); this.clear();
this._buildShape(); this._buildShape();
this.zr.refreshHover(); this.zr.refreshHover();
......
...@@ -29,14 +29,12 @@ define(function (require) { ...@@ -29,14 +29,12 @@ define(function (require) {
* @param {Object} series 数据 * @param {Object} series 数据
* @param {Object} component 组件 * @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); CalculableBase.call(this);
this.messageCenter = messageCenter;
var self = this; var self = this;
/** /**
* 输出动态视觉引导线 * 输出动态视觉引导线
...@@ -74,7 +72,7 @@ define(function (require) { ...@@ -74,7 +72,7 @@ define(function (require) {
} }
}; };
this.init(option, component); this.refresh(option);
} }
Pie.prototype = { Pie.prototype = {
...@@ -704,17 +702,6 @@ define(function (require) { ...@@ -704,17 +702,6 @@ define(function (require) {
return opt; 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) { ...@@ -742,7 +729,7 @@ define(function (require) {
var sectorMap = {}; var sectorMap = {};
var textMap = {}; var textMap = {};
var lineMap = {}; var lineMap = {};
var backupShapeList = zrUtil.clone(this.shapeList); var backupShapeList = this.shapeList;
this.shapeList = []; this.shapeList = [];
var seriesIndex; var seriesIndex;
...@@ -792,7 +779,7 @@ define(function (require) { ...@@ -792,7 +779,7 @@ define(function (require) {
case 'text' : case 'text' :
textMap[key] = this.shapeList[i]; textMap[key] = this.shapeList[i];
break; break;
case 'line' : case 'broken-line' :
lineMap[key] = this.shapeList[i]; lineMap[key] = this.shapeList[i];
break; break;
} }
...@@ -831,11 +818,11 @@ define(function (require) { ...@@ -831,11 +818,11 @@ define(function (require) {
400, 400,
deltaIdxMap[seriesIndex] < 0 deltaIdxMap[seriesIndex] < 0
? { ? {
endAngle : startAngle :
backupShapeList[i].style.startAngle backupShapeList[i].style.startAngle
} }
: { : {
startAngle : endAngle :
backupShapeList[i].style.endAngle backupShapeList[i].style.endAngle
} }
) )
...@@ -843,7 +830,7 @@ define(function (require) { ...@@ -843,7 +830,7 @@ define(function (require) {
} }
} }
else if (backupShapeList[i].type == 'text' else if (backupShapeList[i].type == 'text'
|| backupShapeList[i].type == 'line' || backupShapeList[i].type == 'broken-line'
) { ) {
if (targeSector == 'delete') { if (targeSector == 'delete') {
// 删除逻辑一样 // 删除逻辑一样
...@@ -851,7 +838,7 @@ define(function (require) { ...@@ -851,7 +838,7 @@ define(function (require) {
} }
else { else {
// 懒得新建变量了,借用一下 // 懒得新建变量了,借用一下
switch (backupShapeList[i].shape) { switch (backupShapeList[i].type) {
case 'text': case 'text':
targeSector = textMap[key]; targeSector = textMap[key];
this.zr.animate(backupShapeList[i].id, 'style') this.zr.animate(backupShapeList[i].id, 'style')
...@@ -864,16 +851,13 @@ define(function (require) { ...@@ -864,16 +851,13 @@ define(function (require) {
) )
.start(); .start();
break; break;
case 'line': case 'broken-line':
targeSector = lineMap[key]; targeSector = lineMap[key];
this.zr.animate(backupShapeList[i].id, 'style') this.zr.animate(backupShapeList[i].id, 'style')
.when( .when(
400, 400,
{ {
xStart:targeSector.style.xStart, pointList:targeSector.style.pointList
yStart:targeSector.style.yStart,
xEnd : targeSector.style.xEnd,
yEnd : targeSector.style.yEnd
} }
) )
.start(); .start();
......
...@@ -27,13 +27,13 @@ ...@@ -27,13 +27,13 @@
* @param {Object} series 数据 * @param {Object} series 数据
* @param {Object} component 组件 * @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); CalculableBase.call(this);
this.init(option, component); this.refresh(option);
} }
Radar.prototype = { Radar.prototype = {
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
*/ */
_buildShape : function () { _buildShape : function () {
this.selectedMap = {}; this.selectedMap = {};
this._symbol = this.ecTheme.symbolList; this._symbol = this.option.symbolList;
this._queryTarget; this._queryTarget;
this._dropBoxList = []; this._dropBoxList = [];
this._radarDataCounter = 0; this._radarDataCounter = 0;
...@@ -390,18 +390,6 @@ ...@@ -390,18 +390,6 @@
return; return;
}, },
/**
* 构造函数默认执行的初始化方法,也用于创建实例后动态修改
* @param {Object} newZr
* @param {Object} newSeries
* @param {Object} newComponent
*/
init : function (newOption, newComponent) {
this.component = newComponent || this.component;
this.refresh(newOption);
},
/** /**
* 刷新 * 刷新
*/ */
......
...@@ -28,13 +28,13 @@ define(function (require) { ...@@ -28,13 +28,13 @@ define(function (require) {
* @param {Object} series 数据 * @param {Object} series 数据
* @param {Object} component 组件 * @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); CalculableBase.call(this);
this.init(option, component); this.refresh(option);
} }
Scatter.prototype = { Scatter.prototype = {
...@@ -45,7 +45,7 @@ define(function (require) { ...@@ -45,7 +45,7 @@ define(function (require) {
_buildShape : function () { _buildShape : function () {
var series = this.series; var series = this.series;
this._sIndex2ColorMap = {}; // series默认颜色索引,seriesIndex索引到color this._sIndex2ColorMap = {}; // series默认颜色索引,seriesIndex索引到color
this._symbol = ecConfig.symbolList; this._symbol = this.option.symbolList;
this._sIndex2ShapeMap = {}; // series图形类型,seriesIndex索引到_symbol this._sIndex2ShapeMap = {}; // series图形类型,seriesIndex索引到_symbol
this.selectedMap = {}; this.selectedMap = {};
...@@ -437,18 +437,6 @@ define(function (require) { ...@@ -437,18 +437,6 @@ define(function (require) {
return pos; 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) { ...@@ -457,6 +445,7 @@ define(function (require) {
this.option = newOption; this.option = newOption;
this.series = newOption.series; this.series = newOption.series;
} }
this.backupShapeList(); this.backupShapeList();
this._buildShape(); this._buildShape();
}, },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册