javascript - 是否可以在高图中将百分比放在列的中间?
问题描述
我正在使用 Highchart 创建一个如下图的柱形图,但是我很难将百分比放在列中,我想将百分比放在列的中间,如下图。请提出您的建议。
链接:https ://jsfiddle.net/dhitiacahya/po8j7sub/7/
Highcharts.chart('container', {
title: {
text: 'column'
},
xAxis: {
categories: ['Apples', 'Oranges', 'Pears', 'Bananas', 'Plums']
},
labels: {
items: [{
html: 'Total fruit consumption',
style: {
left: '50px',
top: '18px',
color: ( // theme
Highcharts.defaultOptions.title.style &&
Highcharts.defaultOptions.title.style.color
) || 'black'
}
}]
},
series: [{
type: 'column',
name: 'Jane',
data: [3, 2, 1, 3, 4]
}, {
type: 'column',
name: 'John',
data: [2, 3, 5, 7, 6]
},]
});
解决方案
添加下图所示的plotOptions
plotOptions: {
series: {
dataLabels: {
enabled: true,
formatter: function() {
return this.y + "%";
}
}
},
bar: {
dataLabels: {
enabled: true
}
},
column: {
dataLabels: {
enabled: true
}
}
},
推荐阅读
- python - 将 rgb 蒙版图像转换为 coco json 多边形格式
- reactjs - 如何对yup中的单个值进行多次验证?
- python - 如何在 python 中找出 Nifti 文件的通道号?
- javascript - 使用 JavaScript 合并 2 个数组并将其导出到 xls 文件
- c++ - 如何在类中创建线程?
- android - 无法从 C:\Program Files (x86)\Microsoft XDE\10.0.10586.0 中的位置打开 xde.exe
- flutter - 在内部使用带有 Cupertino 导航栏的小部件
- wso2 - 使用预打包的 wso2 身份服务器作为 wso2 api 管理器的密钥管理器时无法验证令牌
- c# - MSVisio 字符自定义颜色
- java - 弹出时在顶部打开另一个 fxml