I use Highcharts.js to draw a do-nut chart.
Here I need legends, just to the right of the chart and "span" outside the container (svg) in the center of the chart. Legends work correctly, and "span" does not align in the center of the chart in a responsive way.
JSFIDDLE
var chartDiv = document.getElementById('container');
var textX = $(chartDiv).width()/2;
var textY = $(chartDiv).height()/2 ;
var span = '<span id="pieChartInfoText" style="position:absolute;text-align:center;">';
span += '<span class="centerText">'+Math.round((response.engagement / response.traffic || 0) * 100) + '%</span><br></span>';
$("#addText").append(span);
span = $('#pieChartInfoText');
span.css('left', textX + (span.width() * -0.5));
span.css('top', textY + (span.height() * -0.5));
source
share