PieCharts icon indicating copy to clipboard operation
PieCharts copied to clipboard

Deselecting slices upon selecting new slice

Open Brandon-316 opened this issue 7 years ago • 2 comments

Is there a way to deselect other selected slices when selecting a new one? I'm trying to make the last selected slice animate back into the pie chart when I select another.

Brandon-316 avatar Dec 24 '17 06:12 Brandon-316

Hi, did you find any solution for you question?

davidhsu1115 avatar Feb 08 '19 17:02 davidhsu1115

Hi guys, got the same problem and solved it within the onSelected delegate of PieChartDelegate protocol:

    var selectedSlice: PieSlice?

    func onSelected(slice: PieSlice, selected: Bool)
    {
        // avoid multiple selection
        let isPreviousSliceOpen = selectedSlice?.view.selected ?? false
        if (selected && isPreviousSliceOpen)
        {
            selectedSlice?.view.selected = false // close previously selected slice
        }
        
        selectedSlice = selected ? slice : nil
    }

fabiomartignoni avatar Mar 01 '19 13:03 fabiomartignoni