This is a migrated thread and some comments may be shown as answers.

Chart get point by value

5 Answers 64 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Flash
Top achievements
Rank 1
Flash asked on 22 Mar 2016, 02:31 PM

Please help,

i need to know point on chart for specific value, and other way i want to tap on chart and get exact values for this point.

5 Answers, 1 is accepted

Sort by
0
Adrian
Telerik team
answered on 25 Mar 2016, 02:16 PM
Hi,

Thank you for writing.

You can get the location of data point in the chart by using locationOfPoint:inSeries method of TKChartSeriesRender. Consider the code below:
TKChartSeriesRender *render = [[TKChartSeriesRender alloc] init];
CGPoint point = [render locationOfPoint:dataPoint inSeries:series];

I am not sure if I understand correctly the second part of the question. Could you please explain if you need the tap point coordinates on the chart's plot area or you need the data point that is on that location?
I am looking forward to your reply.

Regards,
Adrian
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Stephen
Top achievements
Rank 1
answered on 05 Apr 2016, 02:37 PM

I've not been able to get this to work.  The point returned is always at location 0:0.  Could you post the swift version of this code?  Perhaps I'm translating incorrectly.

 

Thank you,

-Stephen

0
Adrian
Telerik team
answered on 08 Apr 2016, 01:58 PM
Hi, Stephen,

You are correct. It returns point at location 0:0 because the render's bounds are zero rectangle. To fix this you should set its bounds property:
let render = TKChartSeriesRender(chart: chart)
render.bounds = chart.plotView.bounds
let point = render.locationOfPoint(dataPoints[0], inSeries: series)

Regards,
Adrian
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Stephen
Top achievements
Rank 1
answered on 08 Apr 2016, 02:25 PM

Thanks Adrian.  This works much better!  

However one of the instances where I'll use this functionality is to draw a custom marker on a specific point when the chart first appears.  I've found this solution will still return 0,0 unless I add a delay.  Perhaps because the renderer hasn't completed its work yet.... Is there a way to tell when the chart is finished drawing?

Thanks,

-Steve

0
Adrian
Telerik team
answered on 13 Apr 2016, 12:04 PM
Hello, Stephen,

TKChart does not notify when it is rendered on the screen, however you can use UIViewController's viewDidAppear method where the chart will be on screen. You can also take a look at annotations in TKChart in our documentation. Maybe using annotations would be easier to achieve your scenario.
I hope this helps.

Regards,
Adrian
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Chart
Asked by
Flash
Top achievements
Rank 1
Answers by
Adrian
Telerik team
Stephen
Top achievements
Rank 1
Share this question
or