Highcharts Demo
author(s):
Torstein Hønsi
HTML
<script src="https://code.highcharts.com/highcharts.src.js"></script>
<div id="container"></div>
JavaScript
Highcharts.chart('container', {
chart: {
events: {
render: function() {
var chart = this,
series = chart.series[0],
renderer = chart.renderer;
series.points.forEach(function(p) {
var dl = p.dataLabel,
x = dl.x + chart.plotLeft,
y = dl.y + chart.plotTop,
chartCenterX = chart.chartWidth / 2,
chartCenterY = chart.chartHeight / 2,
anchorX,
anchorY;
// destroy the old label
if (dl.customLabel) {
dl.customLabel.destroy();
}
// definitions for all the directions
if (x < chartCenterX && y < chartCenterY) { // right bottom corner chevron
anchorX = x + 30;
anchorY = y + 50;
} // more should be added here
// create custom label
dl.customLabel = renderer.label(p.name, x, y, 'callout', anchorX, anchorY).attr({
fill: 'blue'
}).css({
color: 'white'
}).add();
});
}
}
},
plotOptions: {
pie: {
dataLabels: {
enabled: true,
style: {
fontWeight: 'bold',
color: 'white'
},
connectorWidth: 0,
distance: 40,
format: ''
},
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]
]
}]
});