单击按钮,启用或禁用Highcharts中饼图中显示的数据标签

Leo*_*Leo 6 highcharts

我有一个动态饼图.在单击按钮时dataLables,显示的数据标签 为true时显示数据点,何时为false,应隐藏.

plotOptions: {
    pie: {
        allowPointSelect: false,
        cursor: 'pointer',
        dataLabels: {
            enabled: false
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

Ste*_*veP 10

您可以使用API​​切换系列图选项,如下所示:

    var chart = $('#container').highcharts();
    var opt = chart.series[0].options;
    opt.dataLabels.enabled = !opt.dataLabels.enabled;
    chart.series[0].update(opt);
Run Code Online (Sandbox Code Playgroud)

例如http://jsfiddle.net/sYMcs/

chart.series [0] .options获取应用于系列0的选项.class.update修改当前选项,并重绘图表.