How to make bar deselect after user click on it to drill down

Hi,

Can you show me an example of how to deselect the bar after I click on one of the bars to drill down to the next donut chart page?





1 Reply

DD Devakumar Dhanapoosanam Syncfusion Team June 20, 2022 01:54 PM UTC

Hi Jake,


We can use the SelectionChanging event and restrict the selection by setting the e.cancel event argument property as true as per the below code example.


<chart:SfChart HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"

                SelectionChanging="SfChart_SelectionChanging">

   

</chart:SfChart>


private void SfChart_SelectionChanging(object sender, ChartSelectionChangingEventArgs e)

{

    if (e.SelectedDataPointIndex > -1)

    {

        var data = e.SelectedSeries.ItemsSource as ObservableCollection<Model>;

        Navigation.PushAsync(new DrillDownPage() { Item = data[e.SelectedDataPointIndex] });

    }

    e.Cancel = true;

}


Please refer the below link for more details

https://www.syncfusion.com/kb/8704/how-to-navigate-to-other-page-with-data-point-information-of-selected-data-in-xamarin-forms

https://help.syncfusion.com/xamarin/charts/selection#events


Please check and let us know if you need any further assistance.


Regards,

Devakumar D


Loader.
Up arrow icon