title: {
text: "ECharts简单线形图表及其配置展示实例",
link: "http://www.stepday.com",
top: 'bottom',
left: 'right'
subtext: "From:http://www.stepday.com",
sublink: "http://www.stepday.com",
textStyle: {
fontSize:24
},
subtextStyle: {
fontSize:12,
color:"red"
}
},
tooltip: {formatter: function (x) {
return x.data.name;//设置提示框的内容和格式 节点和边都显示name属性
}
},
toolbox: {
show : true,
feature : {
magicType: ['line', 'bar'],
restore: true,
saveAsImage: true
}
},
legend: [{
x: 'left',
data:['调研机构','接待公司']
}],
lineStyle: {
normal: {
show : true,
color: 'target',//决定边的颜色是与起点相同还是与终点相同
curveness: 0.3//边的曲度,支持从 0 到 1 的值,值越大曲度越大。
}
},
label: {
normal: {
show : true,
position: 'right',
formatter: function(params){
return params.data.label;
},
}
},
force : {
repulsion : 100,
gravity : 0.03,
edgeLength :80,
layoutAnimation : true
},
edgeLabel: {
normal: {
show: true,
formatter: function (x) {
return x.data.name;
}
}
},
edgeLabel: {
normal: {
textStyle: {
fontSize: 20
}
}
},
- focusNodeAdjacency:true,//当鼠标移动到节点上,突出显示节点以及节点的边和邻接节点
- draggable: true,//指示节点是否可以拖动
- symbolSize: 20,//节点大小
- edgeSymbol: ['circle', 'arrow'],//边两端的标记类型
- edgeSymbolSize: [4, 8],//边两端的标记大小
- roam : true,//是否开启鼠标缩放和平移漫游。默认不开启。如果只想要开启缩放或者平移,可以设置成 'scale' 或者 'move'。设置成 true 为都开启
- legendHoverLink : true,//是否启用图例 hover(悬停) 时的联动高亮。
node数据:
[{category:0,name: 1, value :5,label: '乔布斯'},
{category:1, name: 2,value : 2,label: '丽萨-乔布斯'},
]
link数据:
{source : 2, target : 1, value : 5, label: '女儿'}
使用回调函数设置节点和连接线的提示内容:
formatter: function(params){
if (params.data.category !=undefined) {
return '人物:'+params.data.label;
}else {
return '关系:'+params.data.label;
}
}
- 设置节点形状和大小
通过node 的symbol设置节点形状, symbolSize 设置节点大小
node数据
{
id : 1,
category : 1,
name : '192.168.8.88',
symbol : 'rect',
value : 20,
symbolSize : 70
},