提交 d6c8cbcd 编写于 作者: K kener

高亮关联优化

上级 6379fa79
......@@ -43,16 +43,6 @@ define(function (require) {
this.messageCenter = messageCenter;
var self = this;
/**
* 输出关联区域
*/
self.shapeHandler.onmouseover = function (param) {
var target = param.target;
var name = target.style._text;
if (self._shapeListMap[name]) {
self.zr.addHoverShape(self._shapeListMap[name]);
}
};
self._onmousewheel = function(param){
return self.__onmousewheel(param);
};
......@@ -229,12 +219,6 @@ define(function (require) {
self._shapeListMap = {};
for (var i = 0, l = self.shapeList.length; i < l; i++) {
self.zr.addShape(self.shapeList[i]);
// 通过name关联shape,用于onmouseover
if (self.shapeList[i].type == 'path'
&& typeof self.shapeList[i].style._text != 'undefined'
) {
self._shapeListMap[self.shapeList[i].style._text] = self.shapeList[i];
}
}
self.zr.refresh();
if (!self._markAnimation) {
......@@ -395,7 +379,8 @@ define(function (require) {
});
}
//console.log(JSON.stringify(province));
//console.log(JSON.stringify(this._mapDataMap[mapType].transform));
return province;
},
......@@ -811,20 +796,24 @@ define(function (require) {
}
}
textShape = new TextShape(textShape);
shape = new PathShape(shape);
if (typeof data.hoverable != 'undefined') {
// 数据级优先
textShape.hoverable = shape.hoverable = data.hoverable;
if (data.hoverable) {
textShape.onmouseover = this.shapeHandler.onmouseover;
textShape.hoverConnect = shape.id;
textShape.onmouseover = this.hoverConnect;
}
}
else if (this._hoverable[mapType]){
// 系列级,补充一个关联响应
textShape.onmouseover = this.shapeHandler.onmouseover;
textShape.hoverConnect = shape.id;
textShape.onmouseover = this.hoverConnect;
}
// console.log(name,shape);
ecData.pack(
textShape,
{
......@@ -835,7 +824,7 @@ define(function (require) {
data, 0,
name
);
this.shapeList.push(new TextShape(textShape));
this.shapeList.push(textShape);
ecData.pack(
shape,
......@@ -847,7 +836,7 @@ define(function (require) {
data, 0,
name
);
this.shapeList.push(new PathShape(shape));
this.shapeList.push(shape);
}
//console.log(this._selected);
},
......
......@@ -40,6 +40,21 @@ define(function (require) {
this._zlevelBase = this.getZlevelBase();
this.shapeList = [];
this.effectList = [];
var self = this;
self.hoverConnect = function (param) {
var target = (param.target || {}).hoverConnect;
if (target) {
if (!(target instanceof Array)) {
self.zr.addHoverShape(self.getShapeById(target));
}
else {
for (var i = 0, l = target.length; i < l; i++) {
self.zr.addHoverShape(self.getShapeById(target[i]));
}
}
}
}
}
/**
......@@ -129,6 +144,15 @@ define(function (require) {
}
},
getShapeById : function(id) {
for (var i = 0, l = this.shapeList.length; i < l; i++) {
if (this.shapeList[i].id == id) {
return this.shapeList[i];
}
}
return null;
},
/**
* 获取自定义和默认配置合并后的字体设置
*/
......
......@@ -147,12 +147,7 @@ define(function (require) {
color
);
itemShape._name = itemName;
if (this.legendOption.selectedMode) {
itemShape.onclick = function (param) {
self._legendSelected(param);
};
}
this.shapeList.push(new IconShape(itemShape));
itemShape = new IconShape(itemShape);
// 文字
textShape = {
......@@ -184,12 +179,18 @@ define(function (require) {
}
textShape._name = itemName;
textShape = new TextShape(textShape);
if (this.legendOption.selectedMode) {
textShape.onclick = function (param) {
itemShape.onclick = textShape.onclick = function (param) {
self._legendSelected(param);
};
itemShape.onmouseover = textShape.onmouseover = this.hoverConnect;
itemShape.hoverConnect = textShape.id;
textShape.hoverConnect = itemShape.id;
}
this.shapeList.push(new TextShape(textShape));
this.shapeList.push(itemShape);
this.shapeList.push(textShape);
if (this.legendOption.orient == 'horizontal') {
lastX += itemWidth + 5
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册