这是我的 EChart 初始化代码:
var option = {
tooltip : {
trigger: 'axis'
},
calculable : true,
xAxis : [
{
type : 'category',
boundaryGap : false,
data : cat
}
],
yAxis : [
{
type : 'value'
}
],
series : [
{
name:'Series 1',
type:'line',
smooth:true,
itemStyle: {normal: {areaStyle: {type: 'default'}}},
data:val
}
]
};
该行显示为区域(正确)并以红色显示(我认为默认情况下,我没有在我的代码中添加任何内容)。如何更改图表线条的颜色?
我试过了
itemStyle: {normal: {areaStyle: {type: 'default'}}, color: '#d5ceeb'},
但它不起作用。
最佳答案
您在 itemStyle 中写入颜色,它会更改数据点的颜色,而不是线条。 应该写成 lineStyle 来改变线条的颜色。
series : [
{
name:'Series 1',
type:'line',
smooth:true,
itemStyle: {normal: {areaStyle: {type: 'default'}}},
data:val
lineStyle: {color: '#d5ceeb'}
}
]
有关 lineStyle 的更多选项,请参阅 here
关于javascript - ECharts:改变线条颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54959134/