ShivaRam1989
Posts: 54
Joined: Wed Oct 23, 2019 6:17 pm

Data label update font family on click

Hi Team ,

I am looking for a solution to update the data label fontfamily and font size on click of button.
Could you pls help me providing a demo for the same ?
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Data label update font family on click

Hello,

You can use chart.update() method to dynamically update chart options.

Demo: https://jsfiddle.net/BlackLabel/oznvqxpm/
API: https://api.highcharts.com/class-refere ... art#update

Let me know if you have any further questions!
Best regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/
ShivaRam1989
Posts: 54
Joined: Wed Oct 23, 2019 6:17 pm

Re: Data label update font family on click

Hi ,
Thanks for your response .
I have updated the fiddle to show the issue i am facing when updating data labels dynamically.
In this fiddle https://jsfiddle.net/shivaram1989/Lkpo2m3s/14/ , you can see when i update the data label font family by clicking on the button 'font family'.
The text in the data label is not aligned to center and sometimes it gets out of box when trying to change font family to Verdana etc.
I want the data labels to be always aligned at center even on changing the format or font size or font family.
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Data label update font family on click

Hi,

If you add the fontSize property during the update, it will cause the font to be repositioned. If in this case you do not want to resize font you can set the value to 11 as it is by default.

Demo: https://jsfiddle.net/BlackLabel/ufk69bLs/

Feel free to ask any further questions!
Best regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/
ShivaRam1989
Posts: 54
Joined: Wed Oct 23, 2019 6:17 pm

Re: Data label update font family on click

Thanks for the response , but still the text is not center aligned in the example you shared .
datalabel.PNG
datalabel.PNG (20.69 KiB) Viewed 1299 times
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Data label update font family on click

Hello,

It is positioned, but the font you are using has a typeface where the numbers are of a different size than the regular text, so if you display only numbers somewhere it seems like they are positioned wrongly.

In the demo you can see a comparison of this font with another.
Demo: https://jsfiddle.net/BlackLabel/gya8mzo7/

Feel free to ask any further questions!
Best regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/
ShivaRam1989
Posts: 54
Joined: Wed Oct 23, 2019 6:17 pm

Re: Data label update font family on click

Yes , but I have to change the font family in run time . And that includes the fonts such as Constantia , Sergei Print etc. In these cases the text is not positioning well
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Data label update font family on click

Hello,

This is a bug in the code that does not redraw the labels for some reason.
You can report it as a bug on GitHub, or if there is already a similar thread, write it there.
https://github.com/highcharts/highchart ... new/choose

I couldn't find any workarounds.

​If you have further inquiries, you may reach out to me at any time.
Best regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/

Return to “Highcharts Stock”