How to make highcharts pie datalabels always in the center of each slice?

I really want to know how to make datalabels always in the center of each fragment in a pie chart.

The normal state looks like this (you can also see this example here )

enter image description here

$('#container').highcharts({
    chart: {
        type: 'pie'
    },

    plotOptions: {
        pie: {
            center:  ["50%", "50%"],
            dataLabels: {
                distance: -50
            }
        },
        series:{
            events:{
                load:function(){
                    console.log(this.chartWidth, this.chartHeight);   
                }
            }
        }
    },

    series: [{
        data: [
            ['Firefox',   44.2],
            ['IE7',       26.6],
            ['IE6',       20],
            ['Chrome',    3.1],
            ['Other',    5.4]
        ]
    }]
});

But, when I reduce the width or height of this chart, datalabels are combined that look like the image below. I think this is a property problem distance. I tried to change the distance dynamically, but could not.

enter image description here

As a result, I want to find datalabels always in the center of each slice, even reducing / increasing the size of the chart.

+4
source share
1

. ( ) . , , () , .

, / , (. http://www.highcharts.com/demo/bar-stacked).

, !

0

Source: https://habr.com/ru/post/1614388/


All Articles