简体   繁体   English

ECharts:更改线条颜色

[英]ECharts: change line color

This is my EChart init code:这是我的 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
      }
  ]
};

The line appears with area (correct) and colored in red (I think by default, I haven't added anything to my code).该行显示为区域(正确)并以红色着色(我认为默认情况下,我没有在代码中添加任何内容)。 How can I change the color of the chart's line?如何更改图表线条的颜色?

I've tried with我试过

itemStyle: {normal: {areaStyle: {type: 'default'}}, color: '#d5ceeb'},

but it doesn't work.但它不起作用。

You are writing color inside itemStyle which changes color of your data points, not the line.您正在 itemStyle 内写入颜色,它会更改数据点的颜色,而不是线条。 It should be written in lineStyle for the line color to change.它应该写在 lineStyle 中,以便更改线条颜色。

series : [
  {
      name:'Series 1',
      type:'line',
      smooth:true,
      itemStyle: {normal: {areaStyle: {type: 'default'}}},
      data:val
      lineStyle: {color: '#d5ceeb'}

  }

] ]

For more options on lineStyle refere here有关 lineStyle 的更多选项,请参阅此处

As you can see on image below, if you don't neet to define details of line or item (in case scatter chart type) color can be specified on the same level as data, type ... etc如下图所示,如果您不需要定义行或项目的详细信息(以防散点图类型),可以在与数据相同的级别上指定颜色,类型...等echarts 颜色示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM