其他分享
首页 > 其他分享> > echarts隔柱换色

echarts隔柱换色

作者:互联网

option = {
        tooltip: {},
        xAxis: {
          type: "category",
          data: this.echartsData.groupX,
        },
        yAxis: {
          minInterval: 1,
          type: "value",
        },
        series: [
          {
            Width: 40,
            barWidth: 40, //柱图宽度
            data: this.echartsData.groupY,
            type: "bar",
            itemStyle: {
              normal: {
                //隔柱换色,
                color: function (params) {
                  //首先定义一个数组
                  var colorList = ["#7666FF", "#00C1CC"];
                  if (params.dataIndex % 2 == 0) {
                    return colorList[0];
                  } else {
                    return colorList[1];
                  }
                },
                
              },
            },
          },
        ],
      };

标签:return,colorList,40,隔柱,params,换色,type,echarts
来源: https://blog.csdn.net/yueye_wu/article/details/121167944