03-04-2012 03:58 AM
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!
Solved! Go to Solution.
03-04-2012 03:59 AM
somehow I couldn't add the attachment the first time...?
03-05-2012 01:46 PM - edited 03-05-2012 01:47 PM
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);
03-05-2012 01:58 PM
Thanks Darren,
that solved the problem!
03-08-2012 05:40 AM
03-08-2012 06:08 AM
The restore button was added specifically for the demonstration program to more clearly illustrate my problem
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.