I've been trying to implement dynamic 'callout' shape datalabels for donut chart using Highcharts javascript library, where notch of datalabels point to respective arc. something like this: https://imgur.com/yKhWKOu
I've created the 'callout' shape using highcharts renderer method, but unable to make it dynamic. This is what I'm getting right now: https://imgur.com/VMuVwdk My code is :
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div>
<script type="text/javascript" src="https://code.highcharts.com/highcharts.js"></script>
<script type="text/javascript">
(function(Highcharts) {
Highcharts.Renderer.prototype.symbols.callout = function(x, y, w, h) {
var arrowLength = 6,
halfDistance = 6,
r = Math.min(0, w, h),
safeDistance = r + halfDistance,
<!-- anchorX = options && options.anchorX,
//anchorY = options && options.anchorY,
path;
path = [
'M', x + r, y, //
'L', x + w - r, y, // top side
'C', x + w, y, x + w, y, x + w, y + r, // top-right corner
'L', x + w, y + h - r, // right side
'C', x + w, y + h, x + w, y + h, x + w - r, y + h, // bottom-right corner
'L', x + r, y + h, // bottom side
'C', x, y + h, x, y + h, x, y + h - r, // bottom-left corner
'L', x, y + r, // left side
'C', x, y, x, y, x + r, y // top-right corner
];
path.splice(23,
3,
'L',
w / 2 + halfDistance,
y + h,
w / 2,
y + h + arrowLength,
w / 2 - halfDistance,
y + h,
x + r,
y + h
);
return path;
};
}(Highcharts));
Highcharts.chart('container', {
plotOptions: {
pie: {
dataLabels: {
enabled: true,
style: {
fontWeight: 'bold',
color: 'white'
},
connectorWidth: 0,
distance: 10,
shape: 'callout',
backgroundColor: 'red',
<!-- backgroundColor: 'rgba(0, 0, 0, 0.75)', -->
style: {
color: '#FFFFFF',
textOutline: 'none'
}
},
startAngle: 0,
endAngle: 360,
center: ['50%', '50%']
}
},
series: [{
type: 'pie',
innerSize: '80%',
data: [
['Firefox', 10.38],
['IE', 56.33],
['Chrome', 24.03],
['Opera', 31.44]
]
}]
}, function(chart) {
});
</script>
</body>
</html>
'Thanks in advance'