Search code examples
highchartslegendpie-chartsliceadjustable

Highcharts: how to make slices readjust when disabling one?


Is this possible? I want the other slices in the pie chart to adjust to a full circle when one is disabled in the legend, rather than just making an empty slice..


Solution

  • If you change the behavior of the legendItemClick event handler you can remove the sector instead of hiding it.

        pie: {
             point: {
                events: {
                    legendItemClick: function (eventArgs) {
                        this.remove(); // Remove the point
                        eventArgs.preventDefault(); // Prevent the default behavior
                    }
                }
            },
            showInLegend: true
        }
    

    This will only get you half the way though. The problem is that you cannot get the point back since it will be removed from the legend as well.

    A way to get around this would be to add a reset button that brings back the original data set with series.setData(). See this jsfiddle example.