我知道可以通过更改plotOptions.pie.dataLabels.distance将饼图标签放在饼图内部或外部。我想弄清楚是否有可能逐点改变:
如果切片小于15%,请在切片内放置标签
其他将标签放在切片
之外
在Highcharts中这可能吗?以下是我的尝试之一,但不起作用;普通的jsfiddle在这里:http://jsfiddle.net/supertrue/q6bQP/
plotOptions: {
pie: {
dataLabels: {
distance: -30,
color: 'white',
formatter: function() {
if (this.y < 15 ) {
this.point.dataLabels.color = 'red';
this.point.dataLabels.distance = 20;
return this.point.name;
} else {
return this.point.name;
}
}
},
答案 0 :(得分:2)
这篇文章可以帮助您完成工作:
Is it possible to position Highcharts dataLabels depending on the value?
$.each(chart.series[0].data, function(i, point) {
// using the value or calculating the percent
if(point.percentage < 30) {
point.dataLabel.attr({y:20});
}
});
答案 1 :(得分:0)