I would like to place a title in the center of a pie/donut chart in HighCharts.
I don\'t see anything in the chart options that would directly enable this, so I\'m t
The best solution is to rely on series center, instead of plotHeight
or plotWidth
.
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'pie'
},
plotOptions: {
pie: {
//innerSize: '60%'
}
},
title: {
text: ''
},
series: [{
data: [
['Firefox', 2262],
['IE7', 3800],
['IE6', 1000],
['Chrome', 1986]
]}]
},
function(chart) { // on complete
var textX = chart.plotLeft + (chart.series[0].center[0]);
var textY = chart.plotTop + (chart.series[0].center[1]);
var span = '<span id="pieChartInfoText" style="position:absolute; text-align:center;">';
span += '<span style="font-size: 32px">Upper</span><br>';
span += '<span style="font-size: 16px">Lower</span>';
span += '</span>';
$("#addText").append(span);
span = $('#pieChartInfoText');
span.css('left', textX + (span.width() * -0.5));
span.css('top', textY + (span.height() * -0.5));
});
Working demo: http://jsfiddle.net/4dL9S/