提交 53bbd07e 编写于 作者: L lang

LegendView avoid duplicate rendering, funnel tweak

上级 a869c2bc
......@@ -120,7 +120,8 @@ define(function (require) {
var y = viewRect.y;
var getLinePoints = function (idx, offY) {
var val = data.get('value', idx);
// End point index is data.count() and we assign it 0
var val = data.get('value', idx) || 0;
var itemWidth = number.linearMap(val, dataExtent, sizeExtent);
var x0;
switch (funnelAlign) {
......@@ -152,13 +153,7 @@ define(function (require) {
var idx = indices[i];
var nextIdx = indices[i + 1];
var start = getLinePoints(idx, y);
var end = nextIdx == null
// End point
? [
[viewRect.x + viewRect.width / 2, y + itemHeight],
[viewRect.x + viewRect.width / 2, y + itemHeight]
]
: getLinePoints(nextIdx, y + itemHeight);
var end = getLinePoints(nextIdx, y + itemHeight);
y += itemHeight + gap;
......
......@@ -83,13 +83,14 @@ define(function (require) {
}
var legendDataMap = {};
var legendDrawedMap = {};
zrUtil.each(legendModel.getData(), function (itemModel) {
var seriesName = itemModel.get('name');
var seriesModel = ecModel.getSeriesByName(seriesName, true);
legendDataMap[seriesName] = itemModel;
if (!seriesModel) {
if (!seriesModel || legendDrawedMap[seriesName]) {
// Series not exists
return;
}
......@@ -121,6 +122,8 @@ define(function (require) {
itemGroup.on('click', curry(dispatchSelectAction, seriesName, api))
.on('mouseover', curry(dispatchHighlightAction, seriesName, '', api))
.on('mouseout', curry(dispatchDownplayAction, seriesName, '', api));
legendDrawedMap[seriesName] = true;
}, this);
ecModel.eachSeriesAll(function (seriesModel) {
......@@ -129,7 +132,8 @@ define(function (require) {
data.each(function (idx) {
var name = data.getName(idx);
if (!legendDataMap[name]) {
// Avoid mutiple series use the same data name
if (!legendDataMap[name] || legendDrawedMap[name]) {
return;
}
......@@ -151,6 +155,8 @@ define(function (require) {
itemGroup.on('click', curry(dispatchSelectAction, name, api))
.on('mouseover', curry(dispatchHighlightAction, seriesModel.name, name, api))
.on('mouseout', curry(dispatchDownplayAction, seriesModel.name, name, api));
legendDrawedMap[name] = true;
}, false, this);
}
}, this);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册