Screen position of a datapoint in winform

5 posts, 0 answers
  1. rk
    rk avatar
    3 posts
    Member since:
    Feb 2020

    Posted 11 Jun 2020 Link to this post

    Hi, I need to get screen display position of a scatterseries datapoint say (3,5) in windows form. I am unable to find any conversion api similar to wpf which has methods to do that. How to get actual position on screen for a point. Any help will be greatly appreciated.
  2. Nadya
    Admin
    Nadya avatar
    510 posts

    Posted 12 Jun 2020 Link to this post

    Hello,

    You can get screen coordinates of the ScatterDataPoint by using the HitTest method:

     private void RadChartView1_MouseMove(object sender, MouseEventArgs e)
     {
         var point = this.radChartView1.Area.View.Renderer.HitTest(e.X, e.Y);
    
         if (point is ScatterDataPoint)
         {
             Console.WriteLine("Coordinates: X: {0}, Y: {1} ", e.X, e.Y);
         }
     }

    I hope this helps. If you have further questions do not hesitate to contact me.

    Regards,
    Nadya
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
  3. rk
    rk avatar
    3 posts
    Member since:
    Feb 2020

    Posted 15 Jun 2020 Link to this post

    Hi, My requirement is not on mouse  events. I want these locations just as these points are created very first time.So which event to use for that purpose is my problem.
  4. rk
    rk avatar
    3 posts
    Member since:
    Feb 2020

    Posted 15 Jun 2020 in reply to Nadya Link to this post

    Hi, My requirement is not on mouse  events. I want these locations just as these points are created very first time.So which event to use for that purpose is my problem.
  5. Nadya
    Admin
    Nadya avatar
    510 posts

    Posted 17 Jun 2020 Link to this post

    Hello,

    You can use the CreatePointElement event that occurs when a DataPointElement is created. You can get the data point location and convert it to screen coordinates with the PointToScreen method. Please refer to the following code snippet:

    private void ChartElement_CreatePointElement(object sender, ChartViewCreatePointElementEventArgs e)
    {
        ScatterDataPoint point = e.DataPoint as ScatterDataPoint;
        RadPoint location = point.LayoutSlot.Location;
        Point pointScreen = radChartView1.PointToClient(new Point((int)location.X, (int)location.Y));
        Console.WriteLine(pointScreen);
    }

    I hope this helps. Let me know if you have other questions.

    Regards,
    Nadya
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top