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
Note:
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.
Regards,
Bharathi.