提交 f9bbe5df 编写于 作者: L lang

Optimize symbol create in line

上级 eec38cd1
......@@ -40,7 +40,9 @@ define(function (require) {
symbolType, x, y, w, h, color
);
symbolEl.position = point;
var symbolElPos = symbolEl.position;
symbolElPos[0] = point[0];
symbolElPos[1] = point[1];
symbolEl.z2 = 100;
......@@ -69,7 +71,15 @@ define(function (require) {
return this._data;
},
updateData: function (data, seriesModel, enableAnimation) {
/**
* @param {module:echarts/data/List} data
* @param {module:echarts/model/Series} seriesModel
* @param {boolean} enableAnimation
* @param {Array.<boolean>} [ignoreMap]
*/
updateData: function (
data, seriesModel, enableAnimation, ignoreMap
) {
var group = this.group;
var oldData = this._data;
......@@ -82,20 +92,24 @@ define(function (require) {
return;
}
var symbolEl = createSymbol(
data, newIdx, enableAnimation
);
if (!(ignoreMap && ignoreMap[newIdx])) {
var symbolEl = createSymbol(
data, newIdx, enableAnimation
);
if (symbolEl) {
data.setItemGraphicEl(newIdx, symbolEl);
if (symbolEl) {
data.setItemGraphicEl(newIdx, symbolEl);
group.add(symbolEl);
group.add(symbolEl);
}
}
})
.update(function (newIdx, oldIdx) {
var el = oldData.getItemGraphicEl(oldIdx);
// Empty data
if (!data.hasValue(newIdx)) {
if (!data.hasValue(newIdx)
|| (ignoreMap && ignoreMap[newIdx])
) {
group.remove(el);
return;
}
......@@ -107,7 +121,10 @@ define(function (require) {
var symbolType = data.getItemVisual(newIdx, 'symbol');
// Symbol changed
if (oldData.getItemVisual(oldIdx, 'symbol') !== symbolType) {
if (
oldData.getItemVisual(oldIdx, 'symbol') !== symbolType
|| (!el && !(ignoreMap && ignoreMap[newIdx]))
) {
// Remove the old one
el && group.remove(el);
el = createSymbol(data, newIdx, enableAnimation);
......@@ -138,7 +155,7 @@ define(function (require) {
el.setColor(newColor);
// TODO Merge animateTo and attr methods into one
newTarget.position = point.slice();
newTarget.position = point;
if (!isAroundEqual(el.scale[0], 1)) { // May have scale 0
newTarget.scale = [1, 1];
}
......@@ -146,6 +163,7 @@ define(function (require) {
el.animateTo(newTarget, 300, 'cubicOut');
}
else {
newTarget.position = point.slice();
// May still have animation. Must stop
el.stopAnimation();
el.attr(newTarget);
......
......@@ -109,13 +109,19 @@ define(function(require) {
var isAreaChart = !areaStyleModel.isEmpty();
var stackedOnPoints = getStackedOnPoints(coordSys, data);
var symbolIgnoreMap = !isCoordSysPolar && !seriesModel.get('showAllSymbol')
&& this._getSymbolIgnored(data, coordSys);
// Initialization animation or coordinate system changed
if (
!(polyline
&& prevCoordSys.type === coordSys.type
&& hasAnimation)
) {
dataSymbol.updateData(data, seriesModel, hasAnimation);
dataSymbol.updateData(
data, seriesModel, hasAnimation, symbolIgnoreMap
);
polyline = this._newPolyline(group, points, coordSys, hasAnimation);
if (isAreaChart) {
......@@ -128,7 +134,9 @@ define(function(require) {
}
else {
dataSymbol.updateData(data, seriesModel, false);
dataSymbol.updateData(
data, seriesModel, false, symbolIgnoreMap
);
// Update clipPath
// FIXME Clip path used by more than one elements
......@@ -194,9 +202,6 @@ define(function(require) {
this._coordSys = coordSys;
this._stackedOnPoints = stackedOnPoints;
this._points = points;
!isCoordSysPolar && !seriesModel.get('showAllSymbol')
&& this._updateSymbolDisplay(data, coordSys);
},
/**
......@@ -265,17 +270,20 @@ define(function(require) {
/**
* @private
*/
_updateSymbolDisplay: function (data, coordSys) {
var categoryAxis = coordSys.getAxesByScale('ordinal')[0]
_getSymbolIgnored: function (data, coordSys) {
var categoryAxis = coordSys.getAxesByScale('ordinal')[0];
var ignoreMap;
// `getLabelInterval` is provided by echarts/component/axis
if (categoryAxis && categoryAxis.getLabelInterval) {
ignoreMap = [];
var labelInterval = categoryAxis.getLabelInterval();
data.eachItemGraphicEl(function (el, idx) {
el.ignore = (typeof labelInterval === 'function')
data.each(function (idx) {
ignoreMap[idx] = (typeof labelInterval === 'function')
&& !labelInterval(idx, categoryAxis.scale.getItem(idx))
|| idx % (labelInterval + 1);
});
}
return ignoreMap;
},
/**
......
......@@ -15,7 +15,7 @@ define(function (require) {
var list = createListFromArray(option.data, this, ecModel);
// Not holding the data anymore so it can be removed in momory
// PENDING
option.data = null;
// option.data = null;
return list;
},
......
......@@ -197,7 +197,9 @@ define(function (require) {
var value1D = dimensions.length === 1;
// Use the first data to indicate data type;
var isValueArray = zrUtil.isArray(data[0].value == null ? data[0] : data[0].value);
var isValueArray = data[0] != null && zrUtil.isArray(
data[0].value == null ? data[0] : data[0].value
);
for (var idx = 0; idx < data.length; idx++) {
var value = data[idx];
// Each data item contains value and option
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册