LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

GetAxisScalingMode is updated only after graph is refreshed

Solved!
Go to solution

Hi,

 

on a xy graph, I am plotting several xy plots and a few (2 or 4) vertical lines to indicate certain regions of interest. For drawing these lines, I need to know the minimum and maximum y value of the graph. Hence I thought using GetAxisScalingMode (set to autoscaling) which would conveniently return the maximum value without the need of investigating the individual (large) data sets of the xy plots.

 

In principle, this approach works.

 

Now, in order to avoid flicker, I am using the following sequence:

1) SetCtrlAttribute ( panel, graph_control, ATTR_REFRESH_GRAPH, FALSE );

2) plot new xy plots

3) get ymin, ymax using GetAxisScalingMode

4) plot vertical lines using PlotLine

5) SetCtrlAttribute ( panel, graph_control, ATTR_REFRESH_GRAPH, TRUE );

 

Unfortunately, this does not work because the range of a graph axis is updated only after showing the graph.

First, this behavior seems a bit inconsistent to me because using e.g.. GetCtrlAttribute ( panel, graph_control, ATTR_NUM_PLOTS, &plot_handles ) returns the correct number of plots before refreshing the graph.

 

Second, does someone have a suggestion of how to achieve the goal of flicker free plotting both xy plots and vertical lines covering the complete y range?

 

Thanks!!

 

Wolfgang

0 Kudos
Message 1 of 18
(4,793 Views)

May be I should add that I had considered using cursors, set to indicator mode, and vertical line as cross hair style. For my application it doesn't help because besides these vertical lines I am using 2 or 4 annotations describing the vertical lines - and the vertical positions of the annotations need to be adjusted, too.

 

Wolfgang

0 Kudos
Message 2 of 18
(4,789 Views)

I can think of a few workarounds:

 

1.  Use a function like MaxMin1D to find what the min and max values of the data you are plotting, and use that to set the min/max values for the vertical lines.

 

2.  After plotting the x-y data turn the scaling from Auto to Manual, and draw the lines with extreme values for the endpoints that will always fall outside of the plotted data.

0 Kudos
Message 3 of 18
(4,785 Views)

Thanks for your feedback!

 

As vaguely mentioned in my first post, I do not really like your first suggestion of inspecting all the data sets due to their large sizes.

 

As added in my second post, your second suggestion is not applicable in my case: certainly this way I can plot vertical lines covering the complete y axis range, but I also need the y axis range to place the annotations: they should stay at say 10%, 20%... of the axis - and hence depend on axis range, too.

Changing the axis scaling mode from auto to manual back to auto also is only realized when the graph is refreshed.

 

In conclusion, it appears that so far the only possibility to achieve my goal is (1), i.e. prior analysis of the plot data - which may be quite time consuming.

 

Thanks again,

 

Wolfgang 

0 Kudos
Message 4 of 18
(4,769 Views)

Hi Wolfgan,

 

Maybe you can use second Y axis with constant range. You can select active axis(which is use by next plot function)

by SetCtrlAttribute(panelHandle,PANEL_GRAPH,ATTR_ACTIVE_YAXIS,VAL_RIGHT_YAXIS);//VAL_LEFT_YAXIS

0 Kudos
Message 5 of 18
(4,762 Views)

Hi,

 

thanks for the suggestion! Because I am visualizing several data sets (raw data, processed data, derivative...) I am already using the second x and y axes...

Moreover, the range of the right y axis also is updated only when the graph is refreshed...

 

Wolfgang

 

 

0 Kudos
Message 6 of 18
(4,760 Views)
Solution
Accepted by topic author Wolfgang

OK...finally!

 

Now I can confirm that this behavior is odd (I would even call it a bug...)

 

Here is a workaround:

 

The basic discovery is that the axis range gets updated if a plot property is set, even if the graph is not refreshed. Hence the procedure is:

 

1) SetCtrlAttribute ( panel, graph_control, ATTR_REFRESH_GRAPH, FALSE );

2) plot new xy plots

3) get ymin, ymax using GetAxisScalingMode  // does not work here due to CVI BUG

4) plot vertical lines using PlotLine

4a) GetCtrlAttribute ( panel, graph_control, ATTR_NUM_PLOTS, &plot_handles );

4b) SetCtrlAttribute ( panel, graph_control, ATTR_PLOT_ZPLANE_POSITION, plot_handles - 1 ); // these two lines are stupid here because the lines are delted later on but they update the graph axis range!!

4c) get ymin, ymax using GetAxisScalingMode // now it works

4d) delete vertical lines

4e) plot vertical lines using PlotLine // and the lines now have the correct length 

5) SetCtrlAttribute ( panel, graph_control, ATTR_REFRESH_GRAPH, TRUE );

 

Wolfgang

0 Kudos
Message 7 of 18
(4,754 Views)

Hm,

 

I am wondering if NI could investigate this behavior... and possibly file a CAR to allow for obtaining the axis range in this scenario...? Thanks,

 

Wolfgang 

0 Kudos
Message 8 of 18
(4,715 Views)

...still wondering if this behavior of not updating the axis range is intended or not...

0 Kudos
Message 9 of 18
(4,685 Views)

You're not going to let this go, are you? Smiley Wink

 

The reason you haven't received an answer yet is because we don't know yet whether it is a bug or not. My first reaction when I read your initial post was that it wasn't a bug. The reason being that when the graph axes are in autoscale mode, their range only changes when a plot is drawn. But because you're not drawing your plots right away, then the axis range also doesn't change right away.

 

But then I also would not have expected your workaround to work, and so I became less sure that there wasn't a bug in there somewhere. So this will take some looking into. However, I've been very busy with other coding, and so I haven't had time to look into it. Given that you had found the workaround and were no longer stuck, I wasn't considering this a high priority.

 

When I look into it I'll post an update here. It might take a while, though.

 

Luis

Message 10 of 18
(4,675 Views)