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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to find CGPoint of Marker in a Series

Thread ID:

Created:

Updated:

Platform:

Replies:

141333 Dec 6,2018 10:19 AM UTC Dec 11,2018 08:45 AM UTC Xamarin.iOS 3
loading
Tags: SfChart
Gavin Bryan
Asked On December 6, 2018 10:19 AM UTC

I have a created an SFChart with a SFChartTrackballBehavior instance and can this there is a "Show" method on it to call SFChartTrackballBehavior.Show(CGPoint) which I can call manually and can see it will draw a trackball line on my chart correctly when called if I pass in a random CGPoint in the boundaries of my chart. But I can't see any methods to allow me to determine the CGPoint of a Data Marker when I reference one in code so that I can pass this to SFChartTrackballBehavior.Show(CGPoint) so I can manually draw the TrackBall at the position. Is there a way of determining the CGPoint of a Marker / Data Point on the chart so I can draw the trackball there manually ? 



Michael Prabhu M [Syncfusion]
Replied On December 7, 2018 07:35 AM UTC

Hi Gavin Bryan, 

Greetings from Syncfusion. We have achieved your requirement by using ValueForPoint method in SFChart to convert the datapoint value to CGPoint. ValueForPoint method returns the corresponding CGPoint for individual chart axis. You can enable the trackball by passing the xvalue,yvalue to Show method which returns from the  ValueForPoint method with the corresponding DataPoint value. Please refer below code snippet. 

Code Snippet[C#] 

void Button_TouchUpInside(object sender, EventArgs e) 
{ 
            Model data = model.Data[2] as Model; 
            double xvalue = chart.PointForValue(data.XValue, chart.PrimaryAxis); 
            double yvalue = chart.PointForValue(data.YValue, chart.SecondaryAxis); 
 
            trackballBehavior.Show(new CoreGraphics.CGPoint(xvalue, yvalue)); 
 
} 

 

We have prepared sample for your requirement in NumericalAxis for PrimaryAxis. You can download the sample from the below link. 

Sample: 141333 

Note : 
1.      If you are using CategoryAxis or DateTimeCategoryAxis as PrimaryAxis , you can pass directly pass the xvalue as datapoint index instead of xvalue for PointForValue method. Please refer below code snippet. 

           Code Snippet[C#] 

void Button_TouchUpInside(object sender, EventArgs e) 
{ 
            Model data = model.Data[2] as Model; 
            double xvalue = chart.PointForValue(2,chart.PrimaryAxis); 
            double yvalue = chart.PointForValue(data.YValue, chart.SecondaryAxis); 
 
            trackballBehavior.Show(new CoreGraphics.CGPoint(xvalue, yvalue)); 
 
} 

 

2.      If you are using DateTimeAxis as PrimaryAxis , you have to convert the datetime value to double for PointForValue method. Please refer below code snippet. 

           Code Snippet[C#] 

void Button_TouchUpInside(object sender, EventArgs e) 
{ 
            Model data = model.Data[2] as Model; 
 
            double xvalue = chart.PointForValue(ToOADate (data.XValue),chart.PrimaryAxis); 
            double yvalue = chart.PointForValue(data.YValue, chart.SecondaryAxis); 
 
            trackballBehavior.Show(new CoreGraphics.CGPoint(xvalue, yvalue)); 
 
} 

DateTime BaseDate = new DateTime(1899, 12, 30);  
 public double ToOADate(DateTime time)  
{  
      return time.Subtract(BaseDate).TotalDays;  
}  


 

Thanks, 
Michael  


Gavin Bryan
Replied On December 11, 2018 08:38 AM UTC

Thanks Michael, have got that working from your example.

Michael Prabhu M [Syncfusion]
Replied On December 11, 2018 08:45 AM UTC

Hi Gavin, 
 
Glad we could help, feel free to contact us any time if you need any other assistance from us. 
 
Thanks, 
Michael 



CONFIRMATION

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

;