当前位置:网站首页>Echart折线图:当多条折线图的name一样时也显示不同的颜色

Echart折线图:当多条折线图的name一样时也显示不同的颜色

2022-06-13 06:04:00 HaanLen

echart折线图,当多条折线图的name一样的,颜色也是一致。

在这里插入图片描述

option = {
    
  xAxis: {
    
    type: 'category',
    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  },
  tooltip: {
    
    trigger: 'axis'
  },
  yAxis: {
    
    type: 'value'
  },
  series: [
    {
    
      data: [150, 230, 224, 218, 135, 147, 260],
      type: 'line',
      name: 'heeki'
    },
    {
    
      data: [110, 210, 224, 18, 135, 17, 260],
      type: 'line',
      name: 'heeki'
    }
  ]
};

要设置不同颜色,需要在series中单独设置不同的颜色

在这里插入图片描述

在这里插入图片描述

option = {
    
  xAxis: {
    
    type: 'category',
    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  },
  tooltip: {
    
    trigger: 'axis'
  },
  yAxis: {
    
    type: 'value'
  },
  series: [
    {
    
      data: [150, 230, 224, 218, 135, 147, 260],
      type: 'line',
      name: 'heeki',
      itemStyle: {
    
        normal: {
    
          color: 'red'
        }
      }
    },
    {
    
      data: [110, 210, 224, 18, 135, 17, 260],
      type: 'line',
      name: 'heeki',
      itemStyle: {
    
        normal: {
    
          color: 'yellow'
        }
      }
    }
  ]
};

原网站

版权声明
本文为[HaanLen]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_40119412/article/details/124901239