如何在饼图中对齐数据标签


How to align datalabels in pie charts

我在highcharts上遇到了点小问题。我已经创建了饼状图,其中有数据标签。我的问题是,当数据标签的长度很大,然后它移出的区域,它的某些部分消失。最后看看我的代码

<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

Jquety

$(function () {
    $('#container').highcharts({
        chart: {
            plotBackgroundColor: null,
            plotBorderWidth: null,
            plotShadow: false
        },
        title: {
            text: 'Browser market shares at a specific website, 2010'
        },
        tooltip: {
            pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: true,
                    color: '#000000',
                    connectorColor: '#000000',
                    format: '<b>{point.name}</b>: {point.percentage:.1f} %'
                },
                size:[40],
                    startAngle: -90,
                    endAngle: 90,
                    center: ['50%', '100%']
            }
        },
        series: [{
            type: 'pie',
                name: 'Amount',
                innerSize: '100%',
                colors: ['#50B432', '#ED561B','#24CBE5'],
                dataLabels: {
                    enabled: true,
                    rotation: 0,
                    color: '#666666',
                    align: 'top',
                    x: -10,
                    y: -10,
                    style: {
                        fontSize: '9px',
                        fontFamily: 'Verdana, sans-serif',
                        textShadow: '0 0 0px black'
                    }
                },
            data: [
                ['Firefox',   45.0],
                ['IE',       26.8],
                {
                    name: 'Chrome',
                    y: 12.8,
                    sliced: true,
                    selected: true
                },
                ['Safari',    8.5],
                ['Opera',     6.2],
                ['Others',   0.7]
            ]
        }]
    });
});

这里是小提琴

我想要它像Demo小提琴。在小提琴中,每个数据标签总是在图表区域中移动没有消失。

注意我已经解决了条形图和其他图表的问题。

Thanks in advance

你可以

  • 减小图表尺寸
  • 使用距离参数。
  • 设置useHTML并通过css调整