Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Strange quirk of Waveform Graph .NET control

When I create a .NET waveform graph, with X axis range set to (0, 100) the axis displays 6 major divisions and 5 minor (with the control size set to (259, 259) and major division labels not visible) but if I change X axis range from (0, 100) to (100, 200) I get 3 major divisions and 2 minor. All other settings are at defaults. What's up with that?


John Voltz
0 Kudos
Message 1 of 6
(4,832 Views)
John,

The WaveformGraph control contains XAxis and YAxis collections. Each XAxis and YAxis in the collection contains a property called AutoSpacing. By default, the AutoSpacing property is set to true. The property specifies if the axis automatically calculates the location of major and minor divisions. You can set AutoSpacing to false if you want more control over the number and frequency of divisions. If you set AutoSpacing to false, you will need to specify the Base and Interval values on the MajorDivisions and MinorDivisions of the axis. The Base and Interval of the divisions are used to calculate the placement of divisions when AutoSpacing is false.
Abhishek Ghuwalewala | Measurement Studio | National Instruments
0 Kudos
Message 2 of 6
(4,825 Views)
By default, the XAxis.AutoSpacing property is set to true, which means that it will attempt to pick the best setting for the number of major/minor divisions based on the size of the axis and the width of the labels. If you have a range from 0 to 100 and you're seeing 6 major divisions, that means that you have 1 label that's 1 character wide, 4 labels that are 2 characters wide, and 1 label that is 3 characters wide. If you change the range to 100 to 200 and still had 6 major divisions, you would have 6 labels that are 3 characters wide. If you see 3 major divisions after that change, it's because the axis is evaluating the size of the labels and how it will fit in the size of the axis and determing that the labels would be tightly squeezed together, so it reduces the number of major divisions. If you make the graph a little wider, you will see it automatically expand back out to 6 major divisions. If you would prefer to always have the same number of divisions, you can set AutoSpacing to false and manually configure the division spacing in the MajorDivisions/MinorDivisions properties of the axis.

- Elton
0 Kudos
Message 3 of 6
(4,815 Views)
I see now, thanks.

John Voltz
0 Kudos
Message 4 of 6
(4,812 Views)
Hello, I am having a similar problem but have some slight differences. In my application I am dynamically changing the waveform graph range (i.e. 0-1000, 0-900, 0-800, etc.). What I would like is to consistantly have 10 major divisons throughout all of my ranges. From the responses above it appears that this is possible by setting AutoFocus to False and manipultaing the Interval and Base properties of the X-Axis. I have made these changes but I am not seeing any difference in the way the graph chooses it's major divisions. I continue to get 10 major divisions for 0-1000, 9 major divisions for 0-900 and 8 major divisions for 0-800. I have also tried to increase the width of the graph since it appears that it's the labels that are causing the issue but with no success. Not sure if I am doing something wrong or it's just the nature of the graph control. Perhaps someone could better explain the use of the Interval and Base properties or provide an example. Any help would be greatly appreciated
0 Kudos
Message 5 of 6
(4,186 Views)

Hi kprovencher,

 

You should try setting the AutoSpacing property to false and the Mode property to Fixed Mode for the particular XAxis which you want to be configured, and whenever the range of the data changes, you should make sure that the Base and Interval proeprties of the MajorDivisions of the XAxis is correctly updated.

 

Meaning to say that, you should do the following at the beginning of the program,

waveformGraph1.Plots[0].XAxis.AutoSpacing = false;

waveformGraph1.Plots[0].XAxis.Mode = NationalInstruments.UI.AxisMode.Fixed;

 

and every time the data changes, (say, when your range changes from 0-1000 to 0-900)

waveformGraph1.Plots[0].XAxis.MajorDivisions.Base = waveformGraph1.Plots[0].XAxis.Range.Minimum;
waveformGraph1.Plots[0].XAxis.MajorDivisions.Interval = waveformGraph1.Plots[0].XAxis.Range.Interval / 10;

 

-Mahesh

-Mahesh
National Instruments
0 Kudos
Message 6 of 6
(4,144 Views)