我在显示堆栈标签值(直方图)时遇到问题,实际上,堆叠列标签不显示,当列总和在yAxis上具有接近的值时,我上传了(屏幕截图和代码):
谢谢您的帮助screenshot histogram
Highcharts.chart('container', {
chart: {
type: 'column'
},
title: {
text: 'Stacked column chart'
},
xAxis: {
categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
},
yAxis: {
title: {
text: 'Total fruit consumption'
},
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
}
}
},
legend: {
align: 'right',
x: -30,
verticalAlign: 'top',
y: 25,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
tooltip: {
headerFormat: '<b>{point.x}</b><br/>',
pointFormat: '{series.name}: {point.y}<br/>Total: {point.stackTotal}'
},
plotOptions: {
column: {
stacking: 'normal',
}
},
series: [{
name: 'John',
data: [54701, 56762, 42544, 94446, 20473],
stack: 'x'
}, {
name: 'Jane',
data: [54701, 52762, 36879, 68872, 82761],
stack: 'y'
}]
});
这是因为默认情况下stackLabels.allowOverlap = false
。将此属性设置为true,您将看到所有标签:
stackLabels: {
enabled: true,
allowOverlap: true,
rotation: 0,
style: {
fontWeight: 'bold',
fontSize: '9px',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
}
}
Demo:
API参考: