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

Getting canvas X,Y for Point

1 Answer 67 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.
Nicu
Top achievements
Rank 1
Nicu asked on 27 Feb 2017, 09:57 AM
Is there a possibility to get Canvas coordinate(top-left coordinate in Chart View) for given Point(x,y) from chart ? 

1 Answer, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 01 Mar 2017, 12:11 PM
Hello Nicu,

Thank you for your interest in Chart for Android.

I'm not sure what exactly you mean by getting coordinates for a point with coordinates x and y. You have also posted a support ticket where you reference conversation about getting the coordinates in terms of pixels for a data point in terms of point in a series. If you need to get the coordinates where a data point (for example a bar in a BarSeries) is drawn, then here's how:

((CategoricalDataPoint)((BarSeries)chart.getSeries().get(0)).model().dataPoints().get(1)).getCenter();

That is, you get the series that you're interested in (the first series in the example), you take its model which contains the data points that are drawn, you take the point whose coordinates you seek (the second point in this example) and then you take its center which is a point the coordinates of the center of the point.

If this is not what you are looking for, please explain in more details you scenario and what coordinates you would expect.

Regards,
Todor
Telerik by Progress
Want to go cross-platform with C# for iOS, Android, and UWP. With UI for Xamarin you can creating beautiful apps for these mobile platforms using a single shared C# codebase.
Tags
Chart
Asked by
Nicu
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or