Enable or disable data shortcuts displayed in pie charts in Highcharts when you click

I have a dynamic pie chart. At the click of a button, data labels are displayed when dataLablestrue to show data points, and when it is false, it should be hidden.

plotOptions: {
    pie: {
        allowPointSelect: false,
        cursor: 'pointer',
        dataLabels: {
            enabled: false
        }
    }
}
+5
source share
1 answer

You can use the API to switch the parameters of the serial plot as follows:

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

eg. http://jsfiddle.net/sYMcs/

chart.series [0] .options gets the options applied to series 0. series.update changes the current parameters and redraws the chart.

+10
source

All Articles