Re: XForms: XYPlot reports back wrong cursor position.

From: Steve Lamont (
Date: Fri Dec 22 2000 - 11:57:28 EST

  • Next message: Bill Unruh: "XForms: XYplot xmapping report seems to be off."

    # To subscribers of the xforms list from Steve Lamont <> :

    > This is a test file which displays a sum of sin()s and allows you to
    > click on the curve. The line where you clicked is then displayed.
    > Although along parts of the curve this works fine, at the minima and
    > maxima of the curve it displays the same problems-- a displacement of
    > the red marker from where you actually clicked on the curve.

    There clearly is a problem in how fl_get_xyplot() finds the point for
    your application. The XYPlot mouse handler simply searches for the
    *first* point which falls inside a square area surrounding the pointer
    and not for the *closest* point.

    It works okay if the points are relatively widely dispersed but when
    the points are packed closely together, it breaks, as it does in your

    Arguably, it should minimize the Euclidean distance from the cursor to
    the data point but it doesn't.

    The workaround is to use fl_get_win_mouse() to fetch the actual
    location of the cursor, then use fl_xyplot_s2w() to get the X-Y grid
    coordinate in your data units. Depending on your data, you can binary
    search for the closest X-Y pair or a brute-force linear search scheme
    if X is not monotonic.


    To unsubscribe, send the message "unsubscribe" to or see
    XForms Home Page:
    List Archive:

    This archive was generated by hypermail 2b29 : Fri Dec 22 2000 - 12:00:33 EST