chart: {
type: 'column'
},
xAxis: {
type: 'category'
},
plotOptions: {
series: {
dataLabels: {
enabled: true,
formatter: function () {
return '<b >'+Math.round(this.point.y)+'%</b>'+'<br>
<b >(N='+ this.point.count + ')</b>';
}
}
}
}
我想在上面列/中心的中心显示 5%、1%、0% (N=600)
这里是 jsfiddle
最佳答案
添加 useHTML 并使元素居中。
引用 Highcharts Labels and String Formatting
dataLabels: {
enabled: true,
useHTML: true,
formatter: function () {
return '<center><b>'+Math.round(this.point.y)+'%</b></center>'
+'<br><center><b>(N='+ this.point.count + ')</b><center>';
}
如果你想导出,那么在导出中添加下面的allowHTML。
exporting: {
allowHTML: true
}
关于javascript - Highcharts : Center text in plot option in column chart,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38868010/