Home Forums WinForms controls Xceed Chart for WinForms Relate mouse click to data point

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #19160 |

    Hi all,

    I have a GridSurface chart. When the mouse is clicked, is it possible to find out the nearest data point to that click? The “Viewport to Scale” demo with “Clamp values to ruler” checked shows there is some support to take the nearest ‘point of interest’ from a click, but can you map that all the way back to the data source?

     Steve 

    Imported from legacy forums. Posted by Steve (had 1390 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Steve,

    There is a method that will return the data point informations when a mouse is right over the data point but there is no method built-in that would return the nearest point to a mouse click.  

    On the other hand, it is certainly possible through programming to determine what is the nearest data point when you click the mouse button.  Suppose you have 5 points in a 3D space, P(1)=[1,1,1], P(2)=[2,2,2], ….., P(5)=[5,5,5].  If you click your mouse on some plane, and that coordinate is P(M)=[2,3,4], you just have to scan through all the points P(n) and compute the Distance(n) = SquareRoot((P(M)[ X ]-P(n)[ X ])²+(P(M)[ Y ]-P(n)[ Y ])²+(P(M)[ Z ]-P(n)[ Z] )²). The smallest distance will tell you which point is the nearest to your mouse, in this case, D(3) = SquareRoot((2-3)²+(3-3)²+(4-3)²) = SQRT(2)

    Best regards,

    Imported from legacy forums. Posted by Ghislain (had 2044 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.