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'}
}
}
}
]
};

 

posted @   雪莉06  阅读(39575)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2016-04-28 bootstrap3学习1:响应式布局layout
点击右上角即可分享
微信分享提示