SOURCE

var provRank = ["杭州", "北京", "南京", "青岛", "厦门", "宁波", "武汉", "广州", "上海", "济南"]

let arrs = ['10%','20%','30%']
let newData = [1,1,1]
let current= 0
option = {
    title: {
        text: '18同济交通夏令营录取情况',
        subtext: '点击右边学校可交互',
        x: 'center'
    },
    backgroundColor: '#eee',
    legend: {
        data: ['录取','不录取'],
        align: 'left',
        left: 10
    },
    toolbox: {
        feature: {
            magicType: {
                type: ['stack', 'tiled']
            },
            dataView: {}
        }
    },
    tooltip: {},
   xAxis: {
        type: 'value',
        axisTick: {
            show: false
        },
        axisLine: {
            show: false
        },
        axisLabel: {
            show: true,
            
        },
        splitLine: {
            show: true
        }
    },
    yAxis: {
        type: 'category',
        boundaryGap: true,
        inverse: true, //反向
        axisLine: {
            show: false
        },
        axisTick: {
            show: true
        },
        axisLabel:{
            margin:18,
            	formatter: function (value, index){
				var ind=index+1;
						if(ind==1){
							return '{a|'+value +'}'
						}else if(ind==2){
							return '{b|'+value +'}'
						}else if(ind==3){
							return '{c|'+value +'}'
						}else{
							return '{d|'+value +'}'
						}
					},
					rich: {
						a: {
							color:"#fb4d4b",
						},
						b: {
						    	color:"#f39c12",
						    	
						},
						c:{
						color:"#00a65a",
						},
						d:{
						color:"#fff",
						}
					}
        },
        data: provRank
    },
    grid: [{
        left: 50,
        name: '人数',
        top:'10%',
        height: '40%',
        width: '40%',

    }
    ],
    series: [{
            name: '录取',
            type: 'bar',
            stack: 'cur',
            xAxisIndex: 0,
            yAxisIndex: 0,
            data: [26, 17, 7, 0, 17, 7, 2],
            label: {
                normal: {
                    show: true,
                    position: 'inside'
                }
            },
        }, {
            name: '不录取',
            type: 'bar',
            stack: 'cur',
            xAxisIndex: 0,
            yAxisIndex: 0,
            data: [10, 8, 1, 2, 12, 7, 0],
            label: {
                normal: {
                    show: true,
                    position: 'inside'
                }
            },
        }, 
       {
            type: 'bar',
            stack: 'cur',
            label: {
                normal: {
                    show: true,
                    position: 'insideLeft',
                    formatter: function (param) {
                      console.log(param,5555)
                      // if(arrs.length>param.)
                        if(newData.length>current){
                            count=newData[current];
                            current++;
                        }else{return;}
                        
                        return 11;
                    }
                }
            },
     
            itemStyle:{
                 normal: {
                 //color: 'rgba(0,0,0,0)',
                 barBorderRadius: [0, 18, 18, 0]
                }
            },
            data:[0,0,0,0,0,0,0,0,0,0,0,0] 
        }

    ]
};
console 命令行工具 X clear

                    
>
console