echarts 折线图自定义颜色与修改legend颜色

图示
option4 = {
title : {
text: '',
subtext: ''
},
color:['#2db7f5','#ff6600','#808bc6'],      //关键加上这句话,legend的颜色和折线的自定义颜色就一致了
legend: {
icon: 'rectangle',
data: ['total', 'dfs_used','non_dfs_used'],
right: '4%',
textStyle: {
fontSize: 12,
color: '#666'
}
},
/*grid:{y:15},*/
tooltip : {
trigger: 'axis'
},
calculable : true,
yAxis : [
{
type : 'value',
splitLine:{show: false},//去除网格线
//boundaryGap : [0, 0.1],
axisLabel: {
show: true,
textStyle: {
color:'#666' //这里用参数代替了
}
},
}
],
xAxis : [
{
type : 'category',
splitLine:{show: false},//去除网格线
data : ['5','10','15','20','25','30','35','40','45'],
axisLabel: {
show: true,
textStyle: {
color:'#666' //这里用参数代替了
}
},
}
],
series : [
{
name:'total',
type:'line',
symbol:'none', //这句就是去掉点的
smooth:true,
barWidth:'37',
data:[43, 48, 36, 32, 46, 32,30, 40, 29],
//symbol:'none',
//smooth:true,
itemStyle: {
normal: {
areaStyle: {type: 'default',color:'#d5f0fd'},  //设置线条区域颜色
lineStyle:{color:'#2db7f5'}  //设置线条颜色
}
},
},
{
name:'dfs_used',
type:'line',
symbol:'none', //这句就是去掉点的
smooth:true,
barWidth:'37',
data:[28, 32, 30, 52, 56, 22,20, 25, 20],
itemStyle: {
normal: {
areaStyle: {type: 'default',color:'#fff5e6'},//设置线条区域颜色
lineStyle:{color:'#ff6600'} //设置线条颜色
}
}
},
{
name:'non_dfs_used',
type:'line',
symbol:'none', //这句就是去掉点的
smooth:true,
barWidth:'37',
data:[20, 12, 20, 32, 46, 12,10, 15, 10],
itemStyle: {
normal: {
areaStyle: {type: 'default',color:'#dcdfee'}, //设置线条区域颜色
lineStyle:{color:'#808bc6'}  //设置线条颜色
}
}
}
]
};

你可能感兴趣的:(echarts 折线图自定义颜色与修改legend颜色)