How to get information from Trackball in Xamarin Charts (SfChart)?

I use SfChart.Please help me.How to get information from trackball.

Trackball will be activated once you long-press anywhere on the chart area and when I move my finger the information in trackball changed.How can I get it?Because I want to write it in Label.Text




1 Reply

YP Yuvaraj Palanisamy Syncfusion Team July 8, 2021 07:18 AM UTC

Hi Maria, 
 
Greetings from Syncfusion. 
 
We would like to let you know that you can get the trackball label text by using TrackballCreated event in SfChart as per the below code example. 
 
CodeSnippet: 
<chart:SfChart TrackballCreated="SfChart_TrackballCreated" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"> 
 
. . . 
 
</chart:SfChart> 
 
private void SfChart_TrackballCreated(object sender, ChartTrackballCreatedEventArgs e) 
{ 
    foreach(var trackballInfo in e.ChartPointsInfo) 
    { 
        // Get or set the trackball label text 
        var trackballLabelText = trackballInfo.Label; 
        trackballInfo.Label += "%"; 
 
    } 
 
    rectangleAnnotation.X1 = (e.ChartPointsInfo[0] as ChartPointInfo).XPosition;       
    if (!rectangleAnnotation.IsVisible) 
    { 
        rectangleAnnotation.IsVisible = true; 
        var seriesBounds = (sender as SfChart).SeriesBounds; 
        rectangleAnnotation.Y1 = seriesBounds.Top; 
        rectangleAnnotation.Y2 = seriesBounds.Bottom; 
        rectangleAnnotation.X2 = seriesBounds.Right; 
    } 
} 
 
Also, we have attached the sample for your reference. Please find the sample from the below link. 
 
 
For more details, please refer the below link 
 
Regards, 
Yuvaraj. 


Loader.
Up arrow icon