echarts关系图graph优化(放到缩小,节点大小保持不变)
记录一下echarts关系图graph优化(放到缩小,节点大小保持不变)
1. 代码
series: [
{
type: 'graph',
layout: 'none',
symbol: 'rect',
draggable: true,
symbolSize: [149, 44],
itemStyle: {
color: '#F5FDFF',
borderColor: '#38AAD0',
borderWidth: 0.5,
},
roam: true,
label: {
normal: {
show: true,
color: '#32B2CB',
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
formatter: function (param) {
if (param.name.length > 12) {
return `${param.name.slice(0, 10)}...`;
}
return param.name;
}
}
},
edgeLabel: {
normal: {
show: true,
textStyle: {
fontSize: 14,
fontWeight: 400,
color: '#626262'
},
formatter: '{c}'
}
},
data: data,
links: links,
lineStyle: {
opacity: 1,
width: 1,
normal: {
color: '#38AAD0'
}
},
emphasis: {
focus: 'adjacency',
lineStyle: {
opacity: 1,
width: 3,
}
}
}
]
2. 效果(正常和放大)
3. 添加代码
nodeScaleRatio: 0,
4. 效果(放大后节点大小不变)