提交 7893d129 编写于 作者: K kener

syncBackupData bug fixed~

上级 464d02ab
...@@ -72,6 +72,10 @@ define(function (require) { ...@@ -72,6 +72,10 @@ define(function (require) {
zr.addShape(self.shapeList[i]); zr.addShape(self.shapeList[i]);
} }
} }
function getOption() {
return option;
}
function resize() { function resize() {
var newWidth = zr.getWidth(); var newWidth = zr.getWidth();
...@@ -230,6 +234,7 @@ define(function (require) { ...@@ -230,6 +234,7 @@ define(function (require) {
self.render = render; self.render = render;
self.resize = resize; self.resize = resize;
self.getOption = getOption;
self.add = add; self.add = add;
self.del = del; self.del = del;
self.ondrop = ondrop; self.ondrop = ondrop;
......
...@@ -302,7 +302,7 @@ define(function(require) { ...@@ -302,7 +302,7 @@ define(function(require) {
[data, serie], [data, serie],
'symbolSize' 'symbolSize'
); );
lastYP += symbolSize * 2 + 2; lastYP += symbolSize * 2 + 5;
y = lastYP; y = lastYP;
self.shapeList.push(_getCalculableItem( self.shapeList.push(_getCalculableItem(
seriesIndex, i, categoryAxis.getNameByIndex(i), seriesIndex, i, categoryAxis.getNameByIndex(i),
...@@ -422,7 +422,7 @@ define(function(require) { ...@@ -422,7 +422,7 @@ define(function(require) {
[data, serie], [data, serie],
'symbolSize' 'symbolSize'
); );
lastXP -= symbolSize * 2 + 2; lastXP -= symbolSize * 2 + 5;
x = lastXP; x = lastXP;
self.shapeList.push(_getCalculableItem( self.shapeList.push(_getCalculableItem(
seriesIndex, i, categoryAxis.getNameByIndex(i), seriesIndex, i, categoryAxis.getNameByIndex(i),
......
...@@ -234,10 +234,12 @@ define(function (require) { ...@@ -234,10 +234,12 @@ define(function (require) {
setTimeout( setTimeout(
function(){ function(){
messageCenter && messageCenter.dispatch( messageCenter && messageCenter.dispatch(
ecConfig.EVENT.DATA_VIEW_CHANGED ecConfig.EVENT.DATA_VIEW_CHANGED,
null,
{option : option}
); );
}, },
document.createElement('canvas').getContext ? 800 : 100 !G_vmlCanvasManager ? 800 : 100
); );
} }
...@@ -340,7 +342,6 @@ define(function (require) { ...@@ -340,7 +342,6 @@ define(function (require) {
} }
contentIdx++; contentIdx++;
} }
} }
} }
......
...@@ -159,6 +159,13 @@ define(function (require) { ...@@ -159,6 +159,13 @@ define(function (require) {
// 找到缩放控制的所有series // 找到缩放控制的所有series
for (var i = 0, l = series.length; i < l; i++) { for (var i = 0, l = series.length; i < l; i++) {
if (series[i].type != ecConfig.CHART_TYPE_LINE
&& series[i].type != ecConfig.CHART_TYPE_BAR
&& series[i].type != ecConfig.CHART_TYPE_SCATTER
&& series[i].type != ecConfig.CHART_TYPE_K
) {
continue;
}
for (var j = 0, k = xAxisIndex.length; j < k; j++) { for (var j = 0, k = xAxisIndex.length; j < k; j++) {
if (xAxisIndex[j] == (series[i].xAxisIndex || 0)) { if (xAxisIndex[j] == (series[i].xAxisIndex || 0)) {
zoomSeriesIndex.push(i); zoomSeriesIndex.push(i);
...@@ -905,6 +912,45 @@ define(function (require) { ...@@ -905,6 +912,45 @@ define(function (require) {
_syncData(true); _syncData(true);
return _zoom; return _zoom;
} }
function syncBackupData(curOption, optionBackup) {
var start;
var target = _originalData['series'];
var curSeries = curOption.series;
var curData;
for (var i = 0, l = curSeries.length; i < l; i++) {
curData = curSeries[i].data;
if (target[i]) {
// dataZoom接管的
start = Math.floor(_zoom.start / 100 * target[i].length);
}
else {
// 非dataZoom接管
start = 0;
}
for (var j = 0, k = curData.length; j < k; j++) {
if (typeof optionBackup.series[i].data[j + start].value
!= 'undefined'
) {
optionBackup.series[i].data[j + start].value
= curData[j].value;
if (target[i]) {
// 同步内部备份
target[i][j + start].value
= curData[j].value;
}
}
else {
optionBackup.series[i].data[j + start] = curData[j];
if (target[i]) {
// 同步内部备份
target[i][j + start]
= curData[j];
}
}
}
}
}
function init(newOption) { function init(newOption) {
option = newOption; option = newOption;
...@@ -933,6 +979,7 @@ define(function (require) { ...@@ -933,6 +979,7 @@ define(function (require) {
} }
self.init = init; self.init = init;
self.syncBackupData = syncBackupData;
self.absoluteZoom = absoluteZoom; self.absoluteZoom = absoluteZoom;
self.rectZoom = rectZoom; self.rectZoom = rectZoom;
self.ondragend = ondragend; self.ondragend = ondragend;
......
...@@ -29,7 +29,8 @@ define(function(require) { ...@@ -29,7 +29,8 @@ define(function(require) {
var self = this; var self = this;
var _zr; var _zr;
var _option; var _option;
var _optionBackup; var _optionBackup; // for各种change和zoom
var _optionRestore; // for restore;
var _chartList; // 图表实例 var _chartList; // 图表实例
var _messageCenter; // Echarts层的消息中心,做zrender原始事件转换 var _messageCenter; // Echarts层的消息中心,做zrender原始事件转换
...@@ -249,6 +250,7 @@ define(function(require) { ...@@ -249,6 +250,7 @@ define(function(require) {
// 发生过重计算 // 发生过重计算
if (_status.needRefresh) { if (_status.needRefresh) {
_syncBackupData(_island.getOption());
_messageCenter.dispatch( _messageCenter.dispatch(
ecConfig.EVENT.DATA_CHANGED, ecConfig.EVENT.DATA_CHANGED,
param.event, param.event,
...@@ -338,9 +340,12 @@ define(function(require) { ...@@ -338,9 +340,12 @@ define(function(require) {
_render(magicOption); _render(magicOption);
} }
function _ondataViewChanged() { function _ondataViewChanged(param) {
_syncBackupData(param.option);
_messageCenter.dispatch( _messageCenter.dispatch(
ecConfig.EVENT.DATA_CHANGED ecConfig.EVENT.DATA_CHANGED,
null,
param
); );
_messageCenter.dispatch(ecConfig.EVENT.REFRESH); _messageCenter.dispatch(ecConfig.EVENT.REFRESH);
} }
...@@ -353,6 +358,42 @@ define(function(require) { ...@@ -353,6 +358,42 @@ define(function(require) {
refresh(); refresh();
} }
function _syncBackupData(curOption) {
if ((curOption.dataZoom && curOption.dataZoom.show)
|| (curOption.toolbox
&& curOption.toolbox.show
&& curOption.toolbox.feature
&& curOption.toolbox.feature.dataZoom
)
) {
// 有dataZoom就dataZoom做同步
for (var i = 0, l = _chartList.length; i < l; i++) {
if (_chartList[i].type == ecConfig.COMPONENT_TYPE_DATAZOOM
) {
_chartList[i].syncBackupData(curOption, _optionBackup);
return;
}
}
}
// 没有就ECharts做
var curSeries = curOption.series;
var curData;
for (var i = 0, l = curSeries.length; i < l; i++) {
curData = curSeries[i].data;
for (var j = 0, k = curData.length; j < k; j++) {
if (typeof _optionBackup.series[i].data[j].value
!= 'undefined'
) {
_optionBackup.series[i].data[j].value
= curData[j].value;
}
else {
_optionBackup.series[i].data[j] = curData[j];
}
}
}
}
/** /**
* 打包Echarts层的事件附件 * 打包Echarts层的事件附件
*/ */
...@@ -512,7 +553,8 @@ define(function(require) { ...@@ -512,7 +553,8 @@ define(function(require) {
function restore() { function restore() {
var zrUtil = require('zrender/tool/util'); var zrUtil = require('zrender/tool/util');
_selectedMap = {}; _selectedMap = {};
_option = zrUtil.clone(_optionBackup); _optionBackup = zrUtil.clone(_optionRestore);
_option = zrUtil.clone(_optionRestore);
_island.clear(); _island.clear();
_toolbox.reset(_option); _toolbox.reset(_option);
_render(_option); _render(_option);
...@@ -601,6 +643,7 @@ define(function(require) { ...@@ -601,6 +643,7 @@ define(function(require) {
}; };
_optionBackup = zrUtil.clone(_option); _optionBackup = zrUtil.clone(_option);
_optionRestore = zrUtil.clone(_option);
_selectedMap = {}; _selectedMap = {};
_island.clear(); _island.clear();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册