LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with autoscaling after graph zoom

Solved!
Go to solution

Hello,

 

I am struggling to find my error in reasoning, but so far was unsuccessful and would be very grateful for assistance.

 

My problem seems to be very basic: I have a graph control with the zoom option enabled, say zoom to rectangle or zoom to y. There is a plot on the graph, zooming into part of the plot works as expected.

 

Now I would like to restore the graph, i.e. set it to full scale showing the full plot again, using SetAxisScalingMode.

 

Stupid enough it does not always seem to work, the axis is not adjusted properly, i.e. only the zoomed part of the plot is visible even after setting the axis to autoscale....?? I don't recall what I am missing here.

 

I have prepared a simple demo, based on the NI sample userint\GraphAnnotations.cws, attached below.

 

In this example, I have made two little changes: 1) I have added one button 'Restore' to set the x and y axes to autoscale. 2) In the UIR, I have changed the graph zoom style to Zoom to rectangle (or Zoom to y)

 

To reproduce the behavior, press 'Plot', zoom into the graph so that the maximum and minimum of the plot are not displayed. Press the restore button, which will show the full graph. Fine. But now zoom in a second time and again press the Restore button: Now it doesn't seem to do anything anymore.

 

Thanks!

0 Kudos
Message 1 of 6
(5,002 Views)

somehow I couldn't add the attachment the first time...?

0 Kudos
Message 2 of 6
(5,001 Views)
Solution
Accepted by Wolfgang

The problem is that when you set the scaling mode to auto the second time, it is already set to auto. Because no change was made, the graph does not need to recalculate the scaling. If you instead plotted a new data point, you would see the autoscaling come back into effect. A simple way to force it to recalculate the scaling would be to set the scaling to VAL_LOCK, then change it back to VAL_AUTOSCALE in the RestoreCallback. Because the attribute value is now changing, a redraw will occur that causes the autoscaling to be recalculated.

 

                        SetAxisScalingMode (panel, PANEL_GRAPH, VAL_LEFT_YAXIS, VAL_LOCK, 0.0,
								0.0);
			SetAxisScalingMode (panel, PANEL_GRAPH, VAL_BOTTOM_XAXIS, VAL_LOCK,
								0.0, 0.0);
			SetAxisScalingMode (panel, PANEL_GRAPH, VAL_LEFT_YAXIS, VAL_AUTOSCALE,
								0.0, 0.0);
			SetAxisScalingMode (panel, PANEL_GRAPH, VAL_BOTTOM_XAXIS,
								VAL_AUTOSCALE, 0.0, 0.0);

 

National Instruments
Message 3 of 6
(4,988 Views)

Thanks Darren,

 

that solved the problem!

0 Kudos
Message 4 of 6
(4,983 Views)
> I have added one button 'Restore'

Just a small comment:
I (and my users) have a hard time to remember how the various zooms
(rectangle, x, y, point, etc) work, so I always try to put a little help
string next to the graph, also saying [Ctrl-Space] to restore. Hence no need
for an extra button.
--
Guillaume Dargaud
http://www.gdargaud.net/
0 Kudos
Message 5 of 6
(4,971 Views)

The restore button was added specifically for the demonstration program to more clearly illustrate my problem Smiley Wink

 

Still: If you (or your users) have zoomed into a graph repeatedly it requires several steps back to restore the original scaling, so I prefer to also provide a popup menu with an entry allowing to restore the graph in a single mouse click. 

0 Kudos
Message 6 of 6
(4,969 Views)