How to disable pointers in pie chart in highcharts

时间:2017-08-01 23:44:44

标签: javascript highcharts pie-chart

Pie Chart in highcharts, How to disable the line pointing outside pie-chart

enter image description here

饼图示例

Highcharts.chart('container', {
    chart: {
        plotBackgroundColor: null,
        plotBorderWidth: null,
        plotShadow: false,
        type: 'pie'
    },
    title: {
        text: 'Browser market shares January, 2015 to May, 2015'
    },
    tooltip: {
        pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
    },
    plotOptions: {
        pie: {
            allowPointSelect: true,
            cursor: 'pointer',
            dataLabels: {
                enabled: true,
                format: '<b>{point.name}</b>: {point.percentage:.1f} %',
                style: {
                    color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                }
            }
        }
    },
    series: [{
        name: 'Brands',
        colorByPoint: true,
        data: [{
            name: 'Microsoft Internet Explorer',
            y: 56.33
        }, {
            name: 'Chrome',
            y: 24.03,
            sliced: true,
            selected: true
        }, {
            name: 'Firefox',
            y: 10.38
        }, {
            name: 'Safari',
            y: 4.77
        }, {
            name: 'Opera',
            y: 0.91
        }, {
            name: 'Proprietary or Undetectable',
            y: 0.2
        }]
    }]
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>

<div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div>
fiddle

2 个答案:

答案 0 :(得分:2)

通过查看Highcharts API,您可以找到问题的答案,特别是您想要plotOptions.pie.dataLabels.connectorWidth

甚至有一个预先制作的例子,正是你要问的问题:jsfiddle example。 他们添加connectorWidth: 0

的地方
plotOptions: {
    pie: {
        dataLabels: {
            connectorWidth: 0
        }
    }
}

答案 1 :(得分:0)

其中一个选项是禁用标签。检查以下设置:


     plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: false,
                    format: '{point.name}: {point.percentage:.1f} %',
                    style: {
                        color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                    }
                }
            }
        },

或者为了实现没有连接器使用下面的代码。 距离:0 将解决目的

C:/Users/Kevin/Desktop/Python\email.py