Javascript 高图表标签显示值而不是名称
我有一个饼图和海图Javascript 高图表标签显示值而不是名称,javascript,highcharts,Javascript,Highcharts,我有一个饼图和海图 plotOptions: { pie: { allowPointSelect: true, cursor: 'pointer', dataLabels: { enabled: true, distance: -30 }, showInLegend
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
},
]
}]
当前在饼图标签中,数据的名称(即:债务人、供应商)是饼图中显示的名称
我希望改为显示值,但图例应保留名称 您需要启用该格式
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
},
]
}]
plotOptions:{
馅饼:{
allowPointSelect:true,
光标:“指针”,
数据标签:{
启用:对,
距离:-30,
格式:“{point.name}:{point.y:,.2f}”,
},
showInLegend:对
}
},
系列:[{
名称:'类型',
colorByPoint:对,
数据:[{
名称:'债务人',
y:10.38
}, {
名称:'供应商',
y:4.77
},
]
}]
jsiddle演示:如果我理解正确,您需要一个定制的工具提示,如下所示:
tooltip: {
formatter: function () {
return this.key + ' (<strong>' + this.y + '</strong>)';
}
}
工具提示:{
格式化程序:函数(){
返回this.key+'('+this.y+');
}
}
@GEOFFREY,如果您只想将值显示为数据标签:。