Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Axis Labeling

Is there an easy way of custom axis labeling? I saw a LabVIEW application that was labeling frequency on a logarithmic scale like:

10Hz, 100Hz, 1kHz, 10kHz, 100kHz, 1MHz, 10MHz

instead of:

10, 100, 1000, 10000, 100000, 1000000, 10000000

Can this be done with the .NET version?

Thanks in advance!
Derek
0 Kudos
Message 1 of 4
(4,208 Views)
It sounds like you're looking for engineering formatting with SI units. There is no direct support for this in the Measurement Studio 7.0 version of the graph, but you could get the desired appearance in the axis by setting the axis.MajorDivisions.LabelVisible, axis.MajorDivisions.TickVisible, and axis.MinorDivisions.TickVisible properties to false, then adding custom divisions to the axis.CustomDivisions collection with the appropriate values and labels. This could be done at design-time, but here's some sample code that demonstrates how to do this at run-time:

class MyForm : Form
{
private NationalInstruments.UI.WindowsForms.WaveformGraph waveformGraph1;
private NationalInstruments.UI.XAxis xAxis1;
private NationalInstruments.UI.YAxis y
Axis1;
private NationalInstruments.UI.WaveformPlot waveformPlot1;

// ...

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);

xAxis1.MajorDivisions.LabelVisible = false;
xAxis1.MajorDivisions.TickVisible = false;
xAxis1.MinorDivisions.TickVisible = false;
xAxis1.Range = new Range(10, 10000000);
xAxis1.ScaleType = ScaleType.Logarithmic;

xAxis1.CustomDivisions.Add(new AxisCustomDivision(10, "10Hz"));
xAxis1.CustomDivisions.Add(new AxisCustomDivision(100, "100Hz"));
xAxis1.CustomDivisions.Add(new AxisCustomDivision(1000, "1kHz"));
xAxis1.CustomDivisions.Add(new AxisCustomDivision(10000, "10kHz"));
xAxis1.CustomDivisions.Add(new AxisCustomDivision(100000, "100kHz"));
xAxis1.CustomDivisions.Add(new AxisCustomDivision(1000000, "1MHz"));
xAxis1.CustomDivisions.Add(new AxisCustomDivision(10000000, "10MHz"));

// Axis should now appe
ar as specified once the form loads.
}
}

- Elton
Message 2 of 4
(4,208 Views)
Hi Elton,

Thanks again for the help! Do you know if these changes are persisted when changing the scale to linear and/or zooming?


Thanks,
Derek
0 Kudos
Message 3 of 4
(4,208 Views)
I'm not sure what you mean by "... if these changes are persisted ..." If you set properties on the axis or add custom divisions to the axis CustomDivisions collections, those properties will retain their values until you explicitly change them or remove the custom divisions.

Are you asking if these settings will continue to appear in the axes if the scale type changes or the graph zooms? If so, the answer is yes. Regarding the scale type, I changed it to logarithmic in the sample code because the example values that you provided looked like a logarithmic scale, but you can change the scale type and it would still work. Regarding zooming, the custom divisions will be displayed as long as the values for the custom divisions are within the c
urrent axis range.

- Elton
0 Kudos
Message 4 of 4
(4,208 Views)