gpt4 book ai didi

javascript - Highcharts 标签显示值而不是名称

转载 作者:行者123 更新时间:2023-12-03 03:36:40 24 4
gpt4 key购买 nike

我有一个带有 Highcharts 的饼图

plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
distance: -30
},
showInLegend: true
}
},
series: [{
name: 'Types',
colorByPoint: true,
data: [ {
name: 'Debtors',
y: 10.38
}, {
name: 'Suppliers',
y: 4.77
},
]
}]

当前饼图中标签中的数据名称(即:债务人、 vendor )就是饼图中显示的内容

我希望显示值,但图例应保留名称。

最佳答案

您需要启用该格式。

plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
distance: -30,
format: '<b>{point.name}</b>: {point.y:,.2f}',
},
showInLegend: true
}
},
series: [{
name: 'Types',
colorByPoint: true,
data: [ {
name: 'Debtors',
y: 10.38
}, {
name: 'Suppliers',
y: 4.77
},
]
}]

Jsfiddle 演示:http://jsfiddle.net/powrcnf1/

关于javascript - Highcharts 标签显示值而不是名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45824522/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com