echats节点设置不同颜色
this.$nextTick(()=>{
var chartDom = document.getElementById('echartshow');
var myChart = echarts.init(chartDom);
var option;
option = {
tooltip: {},
animationDurationUpdate: 1500,
animationEasingUpdate: 'quinticInOut',
series: [
{
type: 'graph',
layout: 'none',
symbolSize: [60,25],
symbolOffset:[10,0],
roam: true,
label: {
show: true
},
symbol:'rect',
edgeSymbol: ['circle', 'arrow'],
edgeSymbolSize: [2, 6],
edgeLabel: {
fontSize: 20
},
itemStyle: {
shadowBlur: 9,
shadowOffsetX: 1.5,
shadowOffsetY: 3,
shadowColor: '#555',
normal:{
color: function(params) {
return params.data.colors
},
}
},
data: [
{
name: 'Node 1',
x: 300,
y: 300,
colors:'#333'
},
{
name: 'Node 2',
x: 650,
y: 300,
colors:'#600'
},
{
name: 'Node 5',
x: 650,
y: 400,
colors:'#897'
},
{
name: 'Node 6',
x: 650,
y: 500,
colors:'#004'
},
{
name: 'Node 7',
x: 950,
y: 300,
colors:'#234'
},
{
name: 'Node 8',
x: 1200,
y: 300,
colors:'#520'
},
],
links: [
{
source: 'Node 1',
target: 'Node 2',
},
{
source: 'Node 2',
target: 'Node 7',
},
{
source: 'Node 5',
target: 'Node 7'
},
{
source: 'Node 6',
target: 'Node 7'
},
{
source: 'Node 7',
target: 'Node 8'
}
],
lineStyle: {
opacity: 0.9,
width: 2,
curveness: 0
}
}
]
};
option && myChart.setOption(option);
})
模型图以及改后结果图