09-23-2010 11:46 AM
I'm writing a program where I'm trying to set the x-position of two cursors (with a snap-to-point mode). What I'd like to do is click, have it determine the x-position of my cursor and find the y-value which corresponds to that x point and set the cursor there. Snap-to-point mode seems to take into account the y-position of my mouse, so if I click at the base of a peak, it will jump to either side of the peak rather than the top. One way I've found to do it would be to pull the x position, read out my data, read the value at the x position and then set the cursor there, but that requires reading out a fairly large array to get at a single data point.
Is there either a mode which ignores the y-position of cursors or a function that reads a single data point from a plot?
09-23-2010 01:57 PM
Hello -
There's not a mode or single function that provides this, but I think there may be an easier way than iterating through the entire data array. I've attached some example code that uses GetGraphCoordsFromPoint to obtain the x data value from a mouse click, and then uses this value in SetGraphCursorIndex to set a cursor to that particular index (this assumes an x increment of 1). Once the cursor is set, I can get the y value associated with the x value of the mouse click.
NickB
National Instruments