var a = [0, 10, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 85]; var b = [150290, 3, 4, 5, 6, 7, 8, 9, 151, 1, 2, 3, 4, 5, 6, 7, 8, 9, 152, 1, 2, 3, 4, 5, 6, 7, 152785]; var s = []; for (var i = 0; i < a.length; i++) { s.push({ name: i, type: 'bar', barWidth:0.2, label:{ show:true, position:"bottom", formatter:function(params,index){ return b[params.componentIndex] } }, stack: '总量', data: [a[i]] }) } option = { color:['#000','#ff0033'], tooltip: { show:false }, legend: { data: ['直接访问', '邮件营销', '联盟广告', '视频广告', '搜索引擎'] }, grid: { left: '3%', right: '4%', bottom: '3%', containLabel: true }, xAxis: { type: 'value', show:false, }, yAxis: { show:false, type: 'category', data: [''] }, series: s };
Done !