我正在尝试在甜甜圈之外实现甜甜圈图的注释位置。我尝试了距离、x 和 y 属性,但它们没有提供所需的结果。有什么方法可以定位甜甜圈图的注释吗?Jsfiddle 链接为:http: //jsfiddle.net/83dhb04j/5/
代码是:
Highcharts.chart('container', {
title: {
text: 'Highcharts Annotations'
},
subtitle: {
text: 'Annotation label shapes'
},
plotOptions: {
series: {
dataLabels: {
enabled: false
}
}
},
series: [{
type: 'pie',
innerSize: '90%',
keys: ['y', 'id'],
data: [
[29.9, '0'],
[71.5, '1'],
[106.4, '2'],
[129.2, '3'],
[144.0, '4'],
[176.0, '5']
]
}],
tooltip: {
enabled: false
},
annotations: [{
labels: [{
point: '0',
shape: 'callout',
y: -65,
useHTML:true,
formatter: function() {
return "<span onclick='getVal("+this.y+")' style='cursor: pointer'>$" + this.y+"</span>"
}
}, {
point: '1',
shape: 'callout',
useHTML:true,
y: -50,
formatter: function() {
return "<span onclick='getVal("+this.y+")' style='cursor: pointer'>$" + this.y+"</span>"
}
}, {
point: '2',
shape: 'callout',
useHTML:true,
y: -50,
x: 10,
formatter: function() {
return "<span onclick='getVal("+this.y+")' style='cursor: pointer'>$" + this.y+"</span>"
}
}, {
point: '3',
shape: 'callout',
useHTML:true,
y: 70,
formatter: function() {
return "<span onclick='getVal("+this.y+")' style='cursor: pointer'>$" + this.y+"</span>"
}
}, {
point: '4',
shape: 'callout',
useHTML:true,
y: 80,
formatter: function() {
return "<span onclick='getVal("+this.y+")' style='cursor: pointer'>$" + this.y+"</span>"
}
}, {
point: '5',
shape: 'callout',
useHTML:true,
y: -60,
formatter: function() {
return "<span onclick='getVal("+this.y+")' style='cursor: pointer'>$" + this.y+"</span>"
}
}]
}]
});
function getVal(obj){
alert("value of y is $"+ obj)
}
如果使用 datalabel 属性可以做到这一点,请也提出该解决方案。