Echarts柱形图颜色设置


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

只需要在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'}
              }
              }
            ]
        }
    ]
};

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM