KIMSAMPYO
Posts: 14
Joined: Thu Jul 16, 2020 12:31 am

How do you fix data labels on a pie chart?

dear highchart.

In a pie chart, I want to anchor the data labels to the center of the chart. How do I fix that?

thanks :)
Attachments
pie.jpg
pie.jpg (21.52 KiB) Viewed 137 times
kamil.k
Posts: 458
Joined: Thu Oct 06, 2022 12:49 pm

Re: How do you fix data labels on a pie chart?

Hello KIMSAMPYO!

Thanks for contacting us again!

First, I'd like to recommend using solidgauge chart type as for this type the center label position is set by default. I've created a similar chart to what you showed, take a look: https://jsfiddle.net/BlackLabel/7twd1r5v/.

If you'd like to stick with the pie type, you can create a custom SVG label element and set the exact center position on every chart's rerender, see: https://jsfiddle.net/BlackLabel/4xcazdLp/. Alternatively, you can set a fixed property using the distance property.

API:
- https://api.highcharts.com/highcharts/c ... nts.render
- https://api.highcharts.com/class-refere ... erer#label
- https://api.highcharts.com/highcharts/s ... s.distance

Let me know if any of these solutions work for you,
Kind Regards!
Kamil Kubik
Highcharts Developer

Return to “Highcharts Usage”