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},//去除網(wǎng)格線
//boundaryGap : [0, 0.1],
axisLabel: {
show: true,
textStyle: {
color:'#666' //這里用參數(shù)代替了
}
},
}
],
xAxis : [
{
type : 'category',
splitLine:{show: false},//去除網(wǎng)格線
data : ['5','10','15','20','25','30','35','40','45'],
axisLabel: {
show: true,
textStyle: {
color:'#666' //這里用參數(shù)代替了
}
},
}
],
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'},  //設置線條區(qū)域顏色
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'},//設置線條區(qū)域顏色
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'}, //設置線條區(qū)域顏色
lineStyle:{color:'#808bc6'}  //設置線條顏色
}
}
}
]
};
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

友情鏈接更多精彩內(nèi)容