Doughnut chart : Event for segment item click

Dear Concern,

I'm using sfChart Doughnut control. I would like to know the details of the segment when i click on one, but as of now always i'm getting selected index as -1 and selected segment as null.

It would be very helpful for me if you can sent a sample to get the detials of the selected segment of the doughnut chart.

Thanking in Anticipation.

Regards,

Tirumaleswara Reddy.

Attachment: doughnut_screenshot_1a7f71e4.zip

3 Replies

DS Durgadevi Selvaraj Syncfusion Team November 23, 2017 10:00 AM UTC

  
Thanks for contacting Syncfusion Support. 
You can achieve your requirement using SelectionChanged event of chart as like in the below code, 
  
Code Snippet[XAML]: 
  
  
<chart:SfChart Header="Communication Medium" SelectionChanged="SfChart_SelectionChanged"> 
  
<chart:SfChart.Behaviors> 
<chart:ChartSelectionBehavior/> 
</chart:SfChart.Behaviors> 
  
  
Code Snippet [C#]: 
  
private void SfChart_SelectionChanged(object sender, ChartSelectionChangedEventArgs e) 
{ 
      var index = e.SelectedIndex; 
  
      if (index == -1) 
          return; 
  
      ChartSegment selectedSegment = e.SelectedSegment; 
      text.Text = index.ToString(); 
      text1.Text = "XData: " + (selectedSegment.Item as Model).XValue.ToString() + "\n"  
           + "YData: " + (selectedSegment.Item as Model).YValue.ToString(); 
} 
  
Please find the output screenshot below, 
 
  
We have prepared a sample based on this requirement and it can be downloaded from the below link, 
  
  
Regards,  
Durgadevi S 



TR Tirumaleswara Reddy K November 24, 2017 07:41 AM UTC

Hi thanks for your response. It helped me a lot. 


DS Durgadevi Selvaraj Syncfusion Team November 27, 2017 05:07 AM UTC

Hi Tirumaleswara, 
 
Thanks for your update. 
 
Please let us know if you required any further assistance on this. 
 
Regards, 
Durgadevi S 


Loader.
Up arrow icon