Echarts组件属性function回调函数的灵活使用调整不同的图表状态_echarts

柱图隔行显示不同的颜色

        series: [{
            data: [],
            type: 'bar',
            itemStyle: {
                color: function (params) {
                    if (params.dataIndex % 2 == 0) {//隔行取余,返回对应的颜色
                        return 'rgba(50,50,50,0.7)';
                    } else {
                        return "#C1232B";
                    }
                }
            },
        }]

Done!