我试图在 Highcharts 的条形图中将标签居中。在我的例子中,您可以在此处看到倒瀑布图:
我正在尝试将数据标签水平居中放置在每个条形中,这样如果系列中的数据点的低值为 1,而 y 为 3,则该点将位于 2。我尝试了中建议的解决方法 Highcharts 文档在这里:
对于最新版本,它似乎不会通过更改格式化程序回调中的选项来影响渲染。
感谢任何帮助。
最佳答案
我知道这是旧的,但我只是需要这个,所以我是这样做的。我确定的解决方案是 How to position datalabel at the base of bar series 的组合和 alba lions 示例,使用 stackLabels 而不是 dataLabels。
yAxis:{
stackLabels: {
style: {
color: 'white' // Make the labels white
},
enabled: true, // Enable stack labels
verticalAlign: 'middle', // Position them vertically in the middle
align: 'center', // Align them to the left edge of the bar
formatter: function() {
return categories[this.x];
}
}
}
参见 jsfiddle
关于javascript - 在 Highcharts 条形图中将数据标签居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10131575/