Allow selection of only one point across multiple series

I have a graph with multiple series, but I want the user to only be able to select a single point on the graph at a time. This means that if the user has selected a point in one series,  and then selectes a point in another series, the first point need to be deselected.  I've tried to programatically set the SelectedIndex of all the other series to -1 when a point is selected, but that doesn't seem to have had an effect. Have I missed a step, or is there another way to ensure that only a single point is selected


3 Replies 1 reply marked as answer

DD Devakumar Dhanapoosanam Syncfusion Team February 10, 2022 12:53 PM UTC

Hi Michelle Barnett, 
 
We have achieved your requirement by using the SelectionChanging event of the chart and SelectedIndex property of the series as per the below code example.  
 
<chart:SfChart x:Name="chart" 
               SelectionChanging="chart_SelectionChanging"> 
   
    <chart:SfChart.Behaviors> 
        <chart:ChartSelectionBehavior/> 
    </chart:SfChart.Behaviors> 
</chart:SfChart> 
 
private void chart_SelectionChanging(object sender, ChartSelectionChangingEventArgs e) 
{ 
    foreach (var series in chart.Series) 
    { 
        //Check condition based on the series added in Chart SeriesCollection 
        if (series != e.SelectedSeries as LineSeries) 
        { 
            (series as LineSeries).SelectedIndex = -1; 
        } 
    } 
} 
 
 
Please refer the below link for more details 
 
Please let us know if you need any further assistance on this. 
 
Regards, 
Devakumar D 


Marked as answer

MB Michelle Barnett February 10, 2022 05:26 PM UTC

Thanks, that fixed it.



DD Devakumar Dhanapoosanam Syncfusion Team February 11, 2022 05:52 AM UTC

Hi Michelle Barnett, 
 
We are glad to know that the given solution works. Please let us know if you need any further assistance on this. 
 
Regards, 
Devakumar D 


Loader.
Up arrow icon