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


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

这里写图片描述

posted @ 2017-05-17 10:33  ning0_o  阅读(414)  评论(0编辑  收藏  举报