LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

GetGraphCursorIndex

At times I do not get the expected result when using GetGraphCursorIndex() at commit event with the cursor in snap mode unless I consciously move the position of the mouse directly over a plotted waveform before committing the cursor position.  Unexpected results also occur if the plotted data at the position of the committed cursor position is out of the Y-axis range of the graph.   How can I force the ability to find the nearest plot at the commited cursor position and attach to it?   A freeform style cursor seems better suited, but GetGraphCursorIndex() aways returns -1 in this mode, so I suspect it there is no attempt to attach to any plot while in freeform mode.  I am using 8.0.1.
0 Kudos
Message 1 of 2
(3,010 Views)

Howdy Steve,

I tried reproducing the behavior you described by working with our graphcursors shipping example that uses the GetGraphCursorIndex() function (Help >> Find Examples; Select the Browse tab and navigate to Building User Interfaces >> Displaying Data >> Graphs and Charts). 

All graph cursors have a cursor mode that specifies the behavior of the graph cursor.  Free-form cursors move to any location inside the plot area while snap-to-point cursors snap to the nearest point when released.

The GetGraphCursorIndex() function obtains the plot handle and array index of the point to which the cursor is currently attached. 

Obtains the plot handle and array index of the point to which the cursor is currently attached.  The plotHandle output will return the ID of the plot to which the cursor is attached.  If the cursor is not attached to the plot, the function will return -1.  The arrayIndex output will return the array index of the data point to which the cursor is attached. If the cursor is attached to a point plot, or if the cursor is not attached to a data point, the function will return a -1.   

If you change the Y-axis to be a smaller range that your data points, the snap-to-point cursor will simply find the nearest point to attach itself to at the top of the plot. 

Hope this helps clarify things!

Best Regards,

Jonathan N.
National Instruments
0 Kudos
Message 2 of 2
(2,983 Views)