提交 d140ddc7 编写于 作者: L lang

Graph legend selectable

上级 242830b3
......@@ -41,7 +41,10 @@ define(function (require) {
lineDraw.updateData(
data.graph.edgeData,
seriesModel, api, false
seriesModel, api, false,
function (idx) {
return data.graph.edges[idx].dataIndex >= 0;
}
);
// Save the original lineWidth
......
......@@ -13,15 +13,18 @@ define(function (require) {
* @param {module:echarts/model/Series} seriesModel
* @param {module:echarts/ExtensionAPI} api
* @param {boolean} [enableAnimation=false]
* @param {Function} [isIgnore]
*/
lineDrawProto.updateData = function (data, seriesModel, api, enableAnimation) {
lineDrawProto.updateData = function (
data, seriesModel, api, enableAnimation, isIgnore
) {
var group = this.group;
var oldData = this._data;
data.diff(oldData)
.add(function (idx) {
var shape = data.getItemLayout(idx);
if (shape) {
if (!(isIgnore && isIgnore[idx])) {
var line = new graphic[shape.cpx1 != null ? 'BezierCurve' : 'Line']({
shape: shape
});
......@@ -33,7 +36,7 @@ define(function (require) {
.update(function (newIdx, oldIdx) {
var line = oldData.getItemGraphicEl(oldIdx);
var shape = data.getItemLayout(newIdx);
if (!shape) {
if (!(isIgnore && isIgnore(newIdx))) {
group.remove(line);
return;
}
......
......@@ -65,10 +65,10 @@ define(function (require) {
* @param {module:echarts/model/Series} seriesModel
* @param {module:echarts/ExtensionAPI} api
* @param {boolean} [enableAnimation=false]
* @param {Array.<boolean>} [ignoreMap]
* @param {Array.<boolean>} [isIgnore]
*/
symbolProto.updateData = function (
data, seriesModel, api, enableAnimation, ignoreMap
data, seriesModel, api, enableAnimation, isIgnore
) {
var group = this.group;
......@@ -76,7 +76,7 @@ define(function (require) {
data.diff(oldData)
.add(function (newIdx) {
if (data.hasValue(newIdx) && !(ignoreMap && ignoreMap[newIdx])) {
if (data.hasValue(newIdx) && !(isIgnore && isIgnore(newIdx))) {
var symbolEl = createSymbol(data, newIdx, enableAnimation);
if (symbolEl) {
......@@ -88,7 +88,7 @@ define(function (require) {
.update(function (newIdx, oldIdx) {
var el = oldData.getItemGraphicEl(oldIdx);
// Empty data
if (!data.hasValue(newIdx) || (ignoreMap && ignoreMap[newIdx])) {
if (!data.hasValue(newIdx) || (isIgnore && isIgnore(newIdx))) {
group.remove(el);
return;
}
......@@ -102,7 +102,7 @@ define(function (require) {
// Symbol changed
if (
oldData.getItemVisual(oldIdx, 'symbol') !== symbolType
|| (!el && !(ignoreMap && ignoreMap[newIdx]))
|| (!el && !(isIgnore && isIgnore(newIdx)))
) {
// Remove the old one
el && group.remove(el);
......
......@@ -110,8 +110,8 @@ define(function(require) {
var stackedOnPoints = getStackedOnPoints(coordSys, data);
var symbolIgnoreMap = !isCoordSysPolar && !seriesModel.get('showAllSymbol')
&& this._getSymbolIgnored(data, coordSys);
var isSymbolIgnore = !isCoordSysPolar && !seriesModel.get('showAllSymbol')
&& this._getSymbolIgnoreFunc(data, coordSys);
// Initialization animation or coordinate system changed
if (
......@@ -120,7 +120,7 @@ define(function(require) {
&& hasAnimation)
) {
symbolDraw.updateData(
data, seriesModel, api, hasAnimation, symbolIgnoreMap
data, seriesModel, api, hasAnimation, isSymbolIgnore
);
polyline = this._newPolyline(group, points, coordSys, hasAnimation);
......@@ -135,7 +135,7 @@ define(function(require) {
else {
symbolDraw.updateData(
data, seriesModel, api, false, symbolIgnoreMap
data, seriesModel, api, false, isSymbolIgnore
);
// Update clipPath
......@@ -281,20 +281,17 @@ define(function(require) {
/**
* @private
*/
_getSymbolIgnored: function (data, coordSys) {
_getSymbolIgnoreFunc: 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.each(function (idx) {
ignoreMap[idx] = (typeof labelInterval === 'function')
&& !labelInterval(idx, categoryAxis.scale.getItem(idx))
|| idx % (labelInterval + 1);
});
return function (idx) {
return (typeof labelInterval === 'function')
&& !labelInterval(idx, categoryAxis.scale.getItem(idx))
|| idx % (labelInterval + 1);
};
}
return ignoreMap;
},
/**
......
......@@ -42,5 +42,5 @@ define(function (require) {
linkToTree: function (list, tree) {
linkList(list, tree, 'tree');
}
}
};
});
\ No newline at end of file
......@@ -159,7 +159,7 @@ define(function(require) {
function doSingleEnterHover(el) {
if (el.__isHover) {
return;
};
}
if (el.__hoverStlDirty) {
var stroke = el.style.stroke;
var fill = el.style.fill;
......@@ -266,7 +266,7 @@ define(function(require) {
/**
* Set hover style of element
* @param {module:zrender/graphic/Displayable} el
* @param {module:zrender/Element} el
* @param {Object} [hoverStyle]
*/
graphic.setHoverStyle = function (el, hoverStyle) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册