02-25-2014 04:36 AM
Hi
Is there a way to reset an horizontal axis to the origin (0)?
I already used ResetZoomPan(), but this set only Pan and Zoom to its initial state.
I would like to reset the graph as appears in the first loading.
Thanks to everyone for the help.
Solved! Go to Solution.
02-25-2014 12:48 PM
There is nothing in the graph that keeps track of the history of axis values outside of interactions.
If you want to reset the graph to how it appears when data is first loaded, then you can use the ZoomToFit
method. If you want to reset the graph to the default range, then you can update the Range
property on the axes.
02-26-2014 04:58 AM
Thanks Paul for your suggestion.
Can you give me a clue how to reset the Range of a single Axis (lets say the first)?
02-26-2014 09:37 AM
Assuming your graph is setup similar to the example below:
<ni:Graph x:Name="graph" ...>
<ni:Graph.Axes>
<ni:AxisDouble x:Name="xAxis" Orientation="Horizontal" ... />
</ni:Graph.Axes>
...
</ni:Graph>
You can set the range using the named axis element:
xAxis.Range = new Range
Or by casting the first item in the Axes
collection, if it is unnamed:
((Axis<double>)graph.Axes[0]).Range = new Range
02-26-2014 05:18 PM
That was my final solution:
Graph.ResetZoomPan();
((Axis<Int32>)Graph.Axes[0]).Range = new NationalInstruments.Controls.Range<Int32>(0, 5000);
Thanks for your help.
07-18-2014 01:24 PM
I have tried this many way without success.
<ni:AxisDouble x:Name="V2y" Adjuster="FitExactly" LabelVisibility="Hidden" Orientation="Vertical" Range="-2, 2, System.Double" Visibility="Hidden" />
V2y.Range = Range(-2.0, 2.0) result in error,
Error 1 'Range' is ambiguous, imported from the namespaces or types 'NationalInstruments.Controls, NationalInstruments.UI'. U:\PB\Intelitool\WpfApplication1\WpfApplication1\Page1.xaml.vb 254 25 WpfApplication1
I can not remove the ui reference as this is part of a large winform project
V2y.Range = New NationalInstruments.Controls.Range(-2, 2) result in error
Error 2 Type 'NationalInstruments.Controls.Range' has no constructors. U:\PB\Intelitool\WpfApplication1\WpfApplication1\Page1.xaml.vb 255 25 WpfApplication1
What else should I do?
Thanks in advance
07-18-2014 01:49 PM
You are missing the type arguments on the generic Range<TData>
type. You can create a new range in VB using New Range(Of Double)( -2.0, 2.0 )
, or by calling Range.Create( -2.0, 2.0 )
on the static Range
helper class.
07-18-2014 02:13 PM
Hi Paul
Thank you the code
AxisXzz.Range = NationalInstruments.Controls.Range.Create(-2000.0, 2000.0)
worked great.
Thanks
George