如何在PIE图表高点的工具提示中显示其他数据



绑定以在饼图中添加额外的数据。我尝试过这种方式,但没有成功。该值不会显示在工具提示中。所以有可能在工具提示中添加额外的数据吗
chartData=[{"名称":"苹果","y":20,"附加数据":33$},
{"姓名":"桔子","y":40,"附加信息":20$},"additionalData":10$}]

Highcharts.chart('chartContainer', {
chart: {
// Edit chart spacing
spacingBottom: 15,
spacingTop: 10,
spacingLeft: 0,
spacingRight: 10,
width: 600,
height: 350
},
title: {
text: ''
},
xAxis: {
title: {
text: null
}
},
yAxis: {
min: 0,
title: {
text: ''
},
labels: {
overflow: 'justify'
}
},
tooltip: {
pointFormat:'<b>{point.y}<b><br> Cost: <b>{point.additionalData} </b>'
},

plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: false
},
point:{
events : {
legendItemClick: function(e){
e.preventDefault();
}
}
},
showInLegend: true
},
},
credits: {
enabled: false
},
series: [{
colorByPoint: true,
type: 'pie',
data:this.chartData
}]
})
}

additionalData属性中的值是数字,但它们包括欧元符号,因此您可能希望使用字符串,否则您将使用无效的json。

[{"name": "apples", "y": 20,"additionalData": "33$"},{"name": "oranges", "y": 40,"additionalData": "20$"},{"name": "bananas", "y": 50,"additionalData": "10$"}]

https://jsfiddle.net/0sacqubp/

最新更新