chech29
Posts: 7
Joined: Sat Apr 27, 2024 10:30 am

Adaptive legend size in pie chart

Hi all. The question arises: Is it possible to make the height of the legend adaptive, which changes depending on the size of the diameter of the circle? I set the size of the circle using size in %, so that the user can select a number from 0 to 100 and set the size of the circle independently. I need the maxHeight of the legend to be a large number for a small circle, and a small number for a large one, so that the legend does not intersect with the circle. More details in the screenshots, thanks in advance
Attachments
Screenshot_6.png
Screenshot_6.png (40.67 KiB) Viewed 688 times
Screenshot_5.png
Screenshot_5.png (63.98 KiB) Viewed 688 times
kamil
Posts: 124
Joined: Mon Mar 04, 2024 8:26 pm

Re: Adaptive legend size in pie chart

Hi there,
Thank you for reaching out to us!

Please check out the article about responsive options in Highcharts: https://www.highcharts.com/docs/chart-c ... responsive
It looks like a perfect solution for your case.

Please let us know if you have any further questions,
Best regards!
Kamil Kulig
Highcharts Developer
chech29
Posts: 7
Joined: Sat Apr 27, 2024 10:30 am

Re: Adaptive legend size in pie chart

Hello! Thanks for the answer. I think this solution will not work, because in addition to the diameter of the diagram, there is also the size of the window in which the diagram is located and the font size for the legend. All this is set by the user and, accordingly, there are too many rules
kamil
Posts: 124
Joined: Mon Mar 04, 2024 8:26 pm

Re: Adaptive legend size in pie chart

Have you considered updating the chart dynamically? You can use chart.legend.update function for that.
Here's a simple demo: https://jsfiddle.net/BlackLabel/nqk8go6f/
API reference: https://api.highcharts.com/class-refere ... rts.Legend
Kamil Kulig
Highcharts Developer

Return to “Highcharts Usage”