【问题标题】:How to align datalabels in pie charts如何对齐饼图中的数据标签
【发布时间】:2014-03-11 10:21:39
【问题描述】:

我在 highcharts 中遇到了一点问题。我创建了具有数据标签的饼图。我的问题是当数据标签的长度很大时,它会移出区域并且其中的一部分会消失。 看看我的代码

HTML

<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>

杰奎蒂

$(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]
            ]
        }]
    });
});

这里是Fiddle

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

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

提前致谢

【问题讨论】:

    标签: php jquery highcharts pie-chart


    【解决方案1】:

    你可以

    • 缩小图表尺寸
    • 使用distance 范围。
    • 设置useHTML并通过css进行适配

    【讨论】:

    • 谢谢,但我已经尝试了所有方法,但可以解决问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-05
    • 2022-12-15
    • 1970-01-01
    相关资源
    最近更新 更多