rouven
Posts: 7
Joined: Tue Dec 10, 2013 1:45 pm

Bar Chart: Data Label not centred when font size is set via label Formatter Function.

Demo https://jsfiddle.net/ar4oygu5/

If I want to change the font size of a single data label and use the formatter function, the value is no longer aligned in the middle. Is there a solution for this?
Attachments
hs.png
hs.png (12.6 KiB) Viewed 370 times
pawelys
Posts: 962
Joined: Wed Sep 02, 2020 10:37 am

Re: Bar Chart: Data Label not centred when font size is set via label Formatter Function.

Hi! Thanks for contacting us with your question! The reason, that the datalabel isn't centered is probably because you are defining font-size in other place, in datalabels object. So the font-size is the option, that makes the div, in which the datalabel is placed, assume the size of the text based on this option. Check this demo, where I changed the font-size in dataLabel options definition to be equal to the size, where you define it only for the first bar. https://jsfiddle.net/BlackLabel/zxf5brqc/

I think, that it is better to manage the datalabels configuration through the options object.
In case of any further questions feel free to contact us again!
Kind regards,
Paweł Lysy
Highcharts Developer

Return to “Highcharts Usage”