提交 f9bbe5df 编写于 作者: L lang

Optimize symbol create in line

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