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

Get the CGPoint location in chart.frame of any bar

3 Answers 29 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.
Miguel
Top achievements
Rank 1
Miguel asked on 23 Dec 2015, 01:04 PM

Hi, 

I need to draw a small image at the left of each horizontal bar outside of the chart. 

To get a good align with the bars, I want to know the location of any bar in the chart.frame. (See the attached file).

Who can I get it?

Thanks!

3 Answers, 1 is accepted

Sort by
0
Accepted
Jack
Telerik team
answered on 23 Dec 2015, 03:14 PM
Hi Miguel,

You can use the locationOfPoint method in TKChartSeriesRender class to get exact coordinates for each point in TKChart. Use the renderForSeries method in TKChartPlotView to get the series render. Here is an example:
TKChartSeriesRender *render = [_chart.plotView renderForSeries:_chart.series[0]];
CGPoint pt = [render locationOfPoint:_chart.series[0].items[1] inSeries:_chart.series[0]];
NSLog(@"%f, %f", pt.x, pt.y);

Please note that this method will return correct results only when TKChart is visible on screen. So, you can't call this method in viewDidLoad method. Use the viewDidAppear method instead.

Feel free to contact us if you have further questions.

Regards,
Jack
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
Miguel
Top achievements
Rank 1
answered on 23 Dec 2015, 05:10 PM

Hi!, thank you

But finally I do this:

TKChartPlotView *plotView = _chart.subviews[1];
CALayer *layerGrid = plotView.layer.sublayers.firstObject;
_hGrid = layerGrid.frame.size.height;
NSLog(@"frame: %@",NSStringFromCGRect(layerGrid.frame));
_pntOgrid = [self.view convertPoint:CGPointZero fromView:plotView];
NSLog(@"ptoOrigen: %@", NSStringFromCGPoint(_pntOgrid));
//. . .

Regards

0
Adrian
Telerik team
answered on 28 Dec 2015, 09:15 AM
Hello, Miguel,

Thank you for this update. I am glad to understand that the issue is solved.
In case you need further assistance, do not hesitate to contact us.

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
Miguel
Top achievements
Rank 1
Answers by
Jack
Telerik team
Miguel
Top achievements
Rank 1
Adrian
Telerik team
Share this question
or