Echarts柱形图颜色设置

时间:2016-09-30 14:54:00   收藏:0   阅读:1697

ECharts图为每个数据项配置颜色

 技术分享 (2014-11-12 15:52:53)
标签: 

时尚

分类: 开发学习
其实给每个数据项配置很简单
只需要在series里面给data数组的每个元素设置itemSytle就可以了
option如下:
option = {
    title : {
        text: ‘高架排队情况‘
    },
    tooltip : {
        trigger: ‘axis‘
    },
    xAxis : [
        {
            type : ‘value‘,
          axisLabel : {
                formatter: ‘{value} 米‘
            }
        }
    ],
    yAxis : [
        {
            type : ‘category‘,
            data : [‘未知‘,‘畅通‘,‘拥挤‘,‘堵塞‘]
        }
    ],
    series : [
        {
            type:‘bar‘,
          data:[
              {
                value:200,
                itemStyle:{
                  normal:{color:‘gray‘}
              }
              }, 
              {
                value:300,
                itemStyle:{
                  normal:{color:‘green‘}
              }
              },
              {
                value:1500,
                itemStyle:{
                  normal:{color:‘yellow‘}
              }
              },
              {
                value:300,
                itemStyle:{
                  normal:{color:‘red‘}
              }
              }
            ]
        }
    ]
};

原文:http://www.cnblogs.com/zhangym/p/5923365.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!