HighCharts 分组堆叠柱状图
<div id="container" style="min-width:400px;height:400px"></div>
var chart = Highcharts.chart('container', {
chart: {
type: 'column'
},
title: {
text: '按性别划分的水果消费总量'
},
xAxis: {
categories: ['苹果', '橘子', '梨', '葡萄', '香蕉']
},
yAxis: {
allowDecimals: false,
min: 0,
title: {
text: '水果数量'
}
},
tooltip: {
formatter: function () {
return '<b>' + this.x + '</b><br/>' +
this.series.name + ': ' + this.y + '<br/>' +
'总量: ' + this.point.stackTotal;
}
},
plotOptions: {
column: {
stacking: 'normal'
}
},
series: [{
name: '小张',
data: [5, 3, 4, 7, 2],
stack: 'male' // stack 值相同的为同一组
}, {
name: '小潘',
data: [3, 4, 4, 2, 5],
stack: 'male'
}, {
name: '小彭',
data: [2, 5, 6, 2, 1],
stack: 'female'
}, {
name: '小王',
data: [3, 0, 4, 4, 3],
stack: 'female'
}]
});

浙公网安备 33010602011771号