LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Graph: Get Right Y-Axis value with GetGraphCursor

Hello,

 

I'm currently developing an application for a customer which contains data being evaluated in a graph control.

There are different scalings of data so I use the left y-axis for digital data and right x-axis for analog data.

 

Now I want to add an annotation marker with the current X and Y value being displayed, when the user clicks into the graph.

 

I use those two functions to determine the position and affected plot of the marker:

 GetGraphCursor(tabHandle2, TABPANEL_2_GRAPH, 1, &x, &y);
 GetGraphCursorIndex(tabHandle2, TABPANEL_2_GRAPH, 1, &plotHandle, &plotIndex);

 

Now this works fine for the left y-axis, but I can't seem to find a way to get the y-axis value of the right side plot.

 

I figure plotHandle and plotIndex should help me to get this data, but sadly I don't know how to use this information.

0 Kudos
Message 1 of 6
(4,046 Views)

Hi,

 

changing the active axis can be done with SetCtrlAttribute ( panel_handle, control_id, ATTR_ACTIVE_YAXIS,  active_axis ); for active_axis you can select either VAL_LEFT_YAXIS or VAL_RIGHT_YAXIS.

 

Hth, Wolfgang

Message 2 of 6
(4,039 Views)

Thanks for the reply.

 

This is a step in the right direction. But I'm still not sure how to utilize this if I have both left and right y-axis plots in the graph and the user clicks on any of them.

 

The help file states the following for ATTR_ACTIVE_YAXIS:

Determines which of the two y-axes on a graph or strip chart is used in plotting, setting a y-axis attribute, and setting the y-axis range. For graphs, the value of this attribute at the time you create a graph cursor determines which y-axis the cursor is associated with.

 

It seems to work if I set the active y axis before creating the cursor (with annotation).

 

But in case the user clicks on a left y axis plot and then on a right y axis plot, I would need to delete and remake the cursor. But then I would lose the point on which the cursor was set.

 

Am I missing something here?

0 Kudos
Message 3 of 6
(4,003 Views)

Hello again,

 

I am sorry but I did not understand


But in case the user clicks on a left y axis plot and then on a right y axis plot, I would need to delete and remake the cursor. But then I would lose the point on which the cursor was set.


 

Does the user create cursors during the run or are there always two cursors, one associated with the left and one with the right axis? Or, phrased differently, why do you want ot delete and recreate the cursor?

 

0 Kudos
Message 4 of 6
(3,997 Views)

Ok to clarify:
I have a graph with plot values on the left and right y axis. Some plots use the left and some the right side.

 

On default there is no cursor in this graph. But I want to provide the option for the user to enable a cursor.

When the cursor is enabled it snaps on to the closest plot and an annotation shows the respective x and y values of the plot point.

 

The problem is, when the left y axis is active and the cursor snapped onto a right y axis plot, the displayed y value is wrong (since the left scale is used).

 

By left clicking into the graph, the user is able to snap the cursor onto another plot.

 

So the main problem is, when clicking on a plot, the active axis has to change according to the plots respective axis.

 

I can easily make this decision since the plot styles are different (left side is VAL_FAT_STEP, right side is VAL_FAT_LINE), but for the axis switch to take effect on the cursor, I would need to delete and add the cursor again. But in this process I lose positioning of the cursor and it snaps to a different plot again.

0 Kudos
Message 5 of 6
(3,992 Views)

If I understood you correctly you should be able to obtain the y axis associated with your cursor using

 

GetCursorAttribute (, , 1, ATTR_CURSOR_YAXIS, );

 

Similarly, you could set the association using SetCursorAttribute without the need to delete and recreate the cursor

 

Wolfgang

0 Kudos
Message 6 of 6
(3,990 Views)