提交 84df0036 编写于 作者: K kener

代码优化

上级 8dbebc9a
......@@ -111,14 +111,6 @@ define(function (require) {
}
},
render : function (newOption) {
this.refresh(newOption);
for (var i = 0, l = this.shapeList.length; i < l; i++) {
this.zr.addShape(this.shapeList[i]);
}
},
getOption : function () {
return this.option;
},
......
......@@ -1218,9 +1218,7 @@ define(function (require) {
*/
clear :function () {
this.clearAnimationShape();
if (this.zr) {
this.zr.delShape(this.shapeList);
}
this.zr && this.zr.delShape(this.shapeList);
this.shapeList = [];
},
......
......@@ -896,7 +896,6 @@ define(function (require) {
this._zoom.start2 = param.start2;
//this.zoomOption.end2 =
this._zoom.end2 = param.end2;
console.log(this._zoom,1111)
this._syncShape();
this._syncData(true);
return;
......
......@@ -54,6 +54,7 @@ define(function (require) {
// this._zoomShape;
// this._zoomQueue;
// this._dataView;
this._markShapeList = [];
var self = this;
self._onmousemove = function (param) {
if (self._marking) {
......@@ -138,7 +139,7 @@ define(function (require) {
}
if (self._marking) {
self._marking = false;
self.shapeList.push(self._markShape);
self._markShapeList.push(self._markShape);
self._iconEnable(self._iconShapeMap['markUndo']);
self._iconEnable(self._iconShapeMap['markClear']);
self.zr.addShape(self._markShape);
......@@ -580,16 +581,16 @@ define(function (require) {
if (this._marking) {
this._marking = false;
} else {
var len = this.shapeList.length - 1; // 有一个是背景shape
if (this._iconList.length == len - 1) {
this._iconDisable(this._iconShapeMap['markUndo']);
this._iconDisable(this._iconShapeMap['markClear']);
}
if (this._iconList.length < len) {
var target = this.shapeList[this.shapeList.length - 1];
var len = this._markShapeList.length;
if (len >= 1) {
var target = this._markShapeList[len - 1];
this.zr.delShape(target.id);
this.zr.refresh();
this.shapeList.pop();
this._markShapeList.pop();
if (len == 1) {
this._iconDisable(this._iconShapeMap['markUndo']);
this._iconDisable(this._iconShapeMap['markClear']);
}
}
}
return true;
......@@ -599,14 +600,11 @@ define(function (require) {
if (this._marking) {
this._marking = false;
}
// 有一个是背景shape
var len = this.shapeList.length - this._iconList.length - 1;
var hasClear = false;
while(len--) {
this.zr.delShape(this.shapeList.pop().id);
hasClear = true;
}
if (hasClear) {
var len = this._markShapeList.length;
if (len > 0) {
while(len--) {
this.zr.delShape(this._markShapeList.pop().id);
}
this._iconDisable(this._iconShapeMap['markUndo']);
this._iconDisable(this._iconShapeMap['markClear']);
this.zr.refresh();
......@@ -870,7 +868,9 @@ define(function (require) {
},
// 重置备份还原状态等
reset : function (newOption) {
reset : function (newOption, needClear) {
needClear && this.clear();
if (this.query(newOption, 'toolbox.show')
&& this.query(newOption, 'toolbox.feature.magicType.show')
) {
......@@ -998,25 +998,6 @@ define(function (require) {
this._isSilence = s;
},
render : function (newOption){
this._resetMark();
this._resetZoom();
newOption.toolbox = this.reformOption(newOption.toolbox);
// 补全padding属性
newOption.toolbox.padding = this.reformCssArray(
newOption.toolbox.padding
);
this.option = newOption || this.option;
this.clear();
if (newOption.toolbox.show) {
this._buildShape();
}
this.hideDataView();
},
resize : function () {
this._resetMark();
this.clear();
......@@ -1033,7 +1014,19 @@ define(function (require) {
this._dataView.hide();
}
},
clear : function(notMark) {
if (this.zr) {
this.zr.delShape(this.shapeList);
this.shapeList = [];
if (!notMark) {
this.zr.delShape(this._markShapeList);
this._markShapeList = [];
}
}
},
/**
* 释放后实例不可用
*/
......@@ -1044,6 +1037,7 @@ define(function (require) {
}
this.clear();
this.shapeList = null;
this._markShapeList = null;
},
/**
......@@ -1051,12 +1045,23 @@ define(function (require) {
*/
refresh : function (newOption) {
if (newOption) {
this._resetMark();
this._resetZoom();
newOption.toolbox = this.reformOption(newOption.toolbox);
// 补全padding属性
newOption.toolbox.padding = this.reformCssArray(
newOption.toolbox.padding
);
this.option = newOption;
this.clear(true);
if (newOption.toolbox.show) {
this._buildShape();
}
this.hideDataView();
}
}
};
......
......@@ -680,16 +680,12 @@ define(function (require) {
}
}
this._island.render(magicOption);
this._toolbox.render(magicOption);
this._island.refresh(magicOption);
this._toolbox.refresh(magicOption);
if (magicOption.animation && !magicOption.renderAsImage) {
this._zr.refresh();
}
else {
this._zr.render();
}
magicOption.animation && !magicOption.renderAsImage
? this._zr.refresh()
: this._zr.render()
var imgId = 'IMG' + this.id;
var img = document.getElementById(imgId);
......@@ -727,8 +723,9 @@ define(function (require) {
*/
restore : function () {
this._option = zrUtil.clone(this._optionRestore);
this._disposeChartList();
this._island.clear();
this._toolbox.reset(this._option);
this._toolbox.reset(this._option, true);
this._render(this._option);
},
......@@ -748,10 +745,12 @@ define(function (require) {
magicOption = this.getOption();
zrUtil.merge(magicOption, param.option, true);
zrUtil.merge(this._optionRestore, param.option, true);
this._island.refresh(magicOption);
this._toolbox.refresh(magicOption);
this._toolbox.reset(magicOption);
}
this._island.refresh(magicOption);
this._toolbox.refresh(magicOption);
// 停止动画
this._zr.clearAnimation();
// 先来后到,安顺序刷新各种图表,图表内部refresh优化检查magicOption,无需更新则不更新~
......@@ -1084,8 +1083,6 @@ define(function (require) {
}
// dataZoom同步数据
this.component.dataZoom && this.component.dataZoom.syncOption(magicOption);
this._island.refresh(magicOption);
this._toolbox.refresh(magicOption);
this._option = magicOption;
var self = this;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册