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

柱状图两种渐变色排列

外围代码

{
    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]
         }
       }
      }
   }
}

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理