使用echarts绘制关系图谱时,通过name绑定数据时,会出现重名冲突的情况,这时图谱无法绘制。
解决方案:
不通过name进行绑定,而是改成通过人员的id绘制图谱;
data: [{
name: '节点1',
x: 300,
y: 300,
id: '1'
}, {
name: '节点2',
x: 800,
y: 300,
id: '2'
}, {
name: '节点3',
x: 550,
y: 100,
id: '3'
}, {
name: '节点4',
x: 550,
y: 500,
id: '4'
},{
name: '节点4',
x: 800,
y: 500,
id: '5'
}],
// links: [],
links: [{
source: 0,
target: 1,
symbolSize: [5, 20],
label: {
show: true
},
lineStyle: {
width: 5,
curveness: 0.2
}
}, {
source: '2',
target: '1',
label: {
show: true
},
lineStyle: {
curveness: 0.2
}
}, {
source: '1',
target: '3'
}, {
source: '2',
target: '3'
}, {
source: '2',
target: '4'
}, {
source: '1',
target: '4'
},{
source: '5',
target: '2'
},{
source: '5',
target: '4'
}],
lineStyle: {
opacity: 0.9,
width: 2,
curveness: 0
}
最终实现的效果图:
其中有两个 节点4