echarts柱狀圖實現多條不同顏色漸變


series層里面
 
itemStyle: {
              normal: {
                // 設置圓角
                barBorderRadius: [6,0,6,0],
                //多條線實現漸變效果
                color:function(params) {
                  var colorList = [
                    ['#662C58','#F84F50'],
                    ['#124480','#46E6ED'],
                    ['#032786','#0068F2'],
                    ['#433E68','#E7A95F'],
                    ['#0D3285','#1E76C8'],
                    ['#433E68','#E7A95F'],
                    ['#662C58','#F84F50'],
                    ['#124480','#46E6ED']
                  ]
                  var index=params.dataIndex;
                  if (params.dataIndex >= colorList.length) {
                      index = params.dataIndex - colorList.length;
                  }
                  return new that.$echarts.graphic.LinearGradient(0, 1, 0, 0, [
                  { offset: 0, color: colorList[index][0] },
                  { offset: 1, color: colorList[index][1] }
                  ])
                },
                
              }
            },


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM