score:2

Accepted answer

You can render the text once, then look at the bounding box of the Element to determine the width of the text, and then use this information to create a correctly positioned text by rendering it again.

For example:

var element = r.text('19% yoy increase ', 0 , 0)
.css({
    fontSize: '11px'
}).add();

var width = element.getBBox().width;
element.destroy();

r.text('19% yoy increase ', data[0].plotX + chart.plotLeft - (width/2) , startY)
.css({
    color: '#4572A7',
    fontSize: '11px'           
}).add();

See this JSFiddle for a demonstration.


Related Articles