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