We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

SelectedSegment set to null when SelectionChanged is triggered on a point in a SplineAreaSeries

Thread ID:





142982 Feb 27,2019 02:16 PM UTC Mar 1,2019 07:11 AM UTC Xamarin.Android 3
Tags: SfChart
Bardi Golriz
Asked On February 27, 2019 02:16 PM UTC

I'm using a SplineAreaSeries and have set an event handler to catch a data point change: 
chart.SelectionChanged += chart_SelectionChanged

The aim of this call is to show a bespoke tooltip. Unfortunately when the event is triggered, ((SfChart.SelectionChangedEventArgs) e).P1.SelectedSegment is set to null and therefore I can't access its X1 and Y1 properties to determine where to place the tooltip (e.P1 is otherwise populated correctly/as expected). This isn't an issue when working with a SplineSeries.

Any guidance is most appreciated.

Bharathiraja K [Syncfusion]
Replied On February 28, 2019 08:58 AM UTC

Hi Bardi, 
Greetings from Syncfusion. We have analyzed your query and we would like to let you know that the Line and Spline series type will draw path for each segment and the SelectedSegment value will return the segment value. But for the Area series type like SplineAreaSeries or AreaSeries the path will draw for the entire chart area. Due to this reason SelectedSegment value will return null for the SplineAreaSeries.  
We can achieve your requirement to get the X1 and Y1 position of the selected segment as a workaround by using the SelectedDataPointIndex and the chart ValueToPoint() method of the ChartAxis to get the screen position of the selected segment. 
Please refer the below code snippet. 
Code Snippet [C#]: 
private void Chart_SelectionChanged(object sender, SfChart.SelectionChangedEventArgs e) 
      var currentIndex = e.P1.SelectedDataPointIndex; 
      var items = e.P1.SelectedSeries.ItemsSource; 
      var data = items as ObservableCollection<Model1>; 
      if (data != null) 
           var yVal = data[currentIndex].YValue; 
           var xVal = data[currentIndex].XValue; 
           var X1 = e.P0.PrimaryAxis.ValueToPoint(xVal); //Here can get the X1 value 
           var Y1 = e.P0.SecondaryAxis.ValueToPoint(yVal); //Here can get the Y1 value 
Please refer the below ug document for more details 
Use the ValueToPoint(axis,value) method available in SfChart to convert the screen point for the chart area and the ValueToPoint(value) method available in ChartAxis, to convert the screen point within the rendered area of the series. 
We have prepared a sample for your requirement and you can download the sample form the below link. 

Bardi Golriz
Replied On February 28, 2019 10:38 AM UTC

Brilliant, thanks!

Bharathiraja K [Syncfusion]
Replied On March 1, 2019 07:11 AM UTC

Hi Bardi, 
We are glad that the provided solution resolved your requirement. Please let us know if you have any other queries. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon