关于echarts:Echarts-柱状图渐变色

4次阅读

共计 525 个字符,预计需要花费 2 分钟才能阅读完成。

柱状图两种渐变色排列

外围代码

{
    itemStyle: {
      normal: {color: function (params) {
          let colorArray = [
            {top: 'rgba(34, 169, 255, 1)', // 蓝色
              bottom: 'rgba(11, 31, 52, 1)'
            }, {top: 'rgba(216, 184, 89, 1)', // 黄色
              bottom: 'rgba(6, 22, 42, 1)'
            }
          ]
          let num = colorArray.length
          return {
            type: 'linear',
            colorStops: [{
              offset: 0,
              color: colorArray[params.dataIndex % num].bottom
            }, {
              offset: 1,
              color: colorArray[params.dataIndex % num].top
            }]
          }
        }
      }
    }
}

柱状图两种单色排列

外围代码

{
    itemStyle: {
      normal: {color: function (params) {
          let colorArray = ['#22A9FF', '#D8B859']
         if (params.dataIndex % 2 === 0) {return colorArray[0]
         } else {return colorArray[1]
         }
       }
      }
   }
}
正文完
 0