力导向图 定义连线点击事件/样式/标注文字及源代码。
来源:互联网 发布:加工中心g76镗孔编程 编辑:程序博客网 时间:2024/06/05 19:43
今天这篇,主要介绍定义连线点击事件/样式/标注文字及源代码。
全部的demo代码下载:http://pan.baidu.com/s/1jGzEb6u。
预览界面:http://www.suchso.com/code/KFdemo/force.html
使用_buildLinkShapes(nodes, links)函数,针对定义的全部线段数据,设置线段的权重(粗细)、样式和高亮样式。
1、zrender定义线段数据:
1
2
3
4
5
6
7
8
9
10
11
12
13
var
shape = {
id : zr.newShapeId(self.type),
shape :
'line'
,
hoverable :
false
,
style : {
xStart : 0,
yStart : 0,
xEnd : 0,
yEnd : 0
},
clickable :
true
,
highlightStyle : {}
};
clickable : true则是支持点击。
2、将link对象的点击事件,赋值给shape:
1
2
3
4
5
if
(
typeof
(link.onclick) !==
'undefined'
) {
if
(link.onclick) {
shape.onclick = link.onclick;
}
}
我们在定义echarts事件的时候,是通过这么一个流程来的:
应用层echarts的js--->echarts事件--->echarts传递事件给zrender处理。
3、调用方法:下面是一个links数据的一个数据demo
1
2
3
4
5
6
7
8
9
10
11
12
13
{source : 1, target : 0, weight : 1,
onclick:
function
(params){
alert(params.target.style.text);
},
itemStyle:{
normal:{
lineWidth:10,
text:
'丽萨-乔布斯'
,
textColor:
'#030303'
,
textFont:
'bold 15px verdana'
,
textPosition:
'inside'
}
}}
onclick是点击事件。onclick:function(params){alert(params.target.shape);
lineWidth是线段宽度。
text是标注的文字。
textPosition 采用的zrender中的文字位置。
定义线段事件和样式全部代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
function
_buildLinkShapes(nodes, links) {
var
l = links.length;
for
(
var
i = 0; i < l; i++) {
var
link = links[i];
//var source = nodes[link.source];
// var target = nodes[link.target];
var
weight = link.weight || 1;
linkWeights.push(weight);
var
shape = {
id : zr.newShapeId(self.type),
shape :
'line'
,
hoverable :
false
,
style : {
xStart : 0,
yStart : 0,
xEnd : 0,
yEnd : 0
},
clickable :
true
,
highlightStyle : {}
};
zrUtil.merge(shape.style, linkStyle);
zrUtil.merge(shape.highlightStyle, linkEmphasisStyle);
//优先级 ItemStyle > linkStyle
if
(
typeof
(link.itemStyle) !==
'undefined'
) {
if
(link.itemStyle.normal){
zrUtil.merge(shape.style, link.itemStyle.normal, {
overwrite :
true
});
}
if
(link.itemStyle.emphasis){
zrUtil.merge(
shape.highlightStyle,
link.itemStyle.emphasis,
{ overwrite :
true
}
);
}
}
//zhao
if
(
typeof
(link.onclick) !==
'undefined'
) {
if
(link.onclick) {
shape.onclick = link.onclick;
}
}
linkShapes.push(shape);
self.shapeList.push(shape);
zr.addShape(shape);
}
var
narr =
new
NDArray(linkWeights);
var
max = narr.max();
if
(max !== 0) {
linkWeights = narr.mul(1/max, narr).toArray();
}
}
0 0
- 力导向图 定义连线点击事件/样式/标注文字及源代码。
- 力导向图之弧形箭头连线
- 天地图专题六:复杂操作,天地图上标注点的连线以及模拟点击事件
- ECharts--基于力导向布局图功能更完善的人物关系图插件扩展-节点样式和点击事件2
- SharpMap增加标注图层LabelLayer及标注样式控制
- 14-在文字上方标注说明标记(文字及列表样式)
- 【D3.js数据可视化系列教程】(三十二)-- 力导向图之弧形箭头连线
- TextView设置部分文字可点击及样式
- 修改标注样式文字填充颜色
- 力导向图知识图谱可视化(节点可点击)
- 天地图WEB API 循环添加标注点,注册点击事件,标注增加属性
- 部分文字点击事件
- S-232接口定义及连线
- RadioButton自定义样式及点击事件全解析
- 百度API 批量添加标注和监听标注点击事件
- RecyclerView定义点击事件
- android 给选中的文字添加点击事件和修改audoLink 的超链接样式
- android 为TextView的部分文字设置超链接样式并监听点击事件
- 11g R2 RAC打最新11.2.0.4.8 PSU补丁记录
- YAFFS2移植指南
- 操作系统调度算法简介
- Linux和bootstrap的学习总结
- arm-poky-linux-gnueabi-ld: unrecognized option '-Wl,-O1' 错误
- 力导向图 定义连线点击事件/样式/标注文字及源代码。
- listView设置自动滚动
- IE10首个修复补丁出现 解决ASP.NET兼容性
- Boost type_index库使用介绍
- 学点儿c#语言wpf开发
- Log4net 写文件日志与数据库日志
- ios7 - 怎么得到七牛返回的 文件和图片的 上传进度
- java读取txt文件内容
- 每日一Vim(3)——替换