Getting canvas X,Y for Point

Thread is closed for posting
2 posts, 0 answers
  1. Nicu
    Nicu avatar
    1 posts
    Member since:
    Jan 2017

    Posted 27 Feb Link to this post

    Is there a possibility to get Canvas coordinate(top-left coordinate in Chart View) for given Point(x,y) from chart ? 
  2. Todor
    Admin
    Todor avatar
    798 posts

    Posted 01 Mar Link to this post

    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.
Back to Top