设置柱状图:每项颜色不一样


var color = ['red', 'blue', 'yellow', '#349ee7', '#349ee7', '#349ee7'];

// 渐变色
color.push(new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
        offset: 0,
        color: '#9a1111'
      }, {
        offset: 1,
        color: 'rgba(203,47,47,.8)'
      }]));

option = {
    xAxis : [
        {
            type : 'category',
            data : ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
            axisTick: {
                alignWithLabel: true
            }
        }
    ],
    yAxis : [
        {
            type : 'value'
        }
    ],
    series: [{
        type: 'bar',
        data:[10, 52, 200, 334, 390, 330, 220],
        itemStyle: {
          normal: {
            color: function(params) {
              return color[params.dataIndex];
            }
          }
        }
      }]
};

这里写图片描述

原文地址:https://www.cnblogs.com/Zting00/p/7497627.html