Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I add custom Y-axis tick values

I would like to change the Y-axis label to a custom string label. I have a waveform that consists of binary data - 0 or 1. When it's 0 it's OFF and when it's 1 it's ON. I would like to change the Y-axis to OFF and ON for 0 and 1, respectively.
0 Kudos
Message 1 of 7
(4,068 Views)
You should be able to do this with value pairs. Try the following steps:



  • Right-click on the graph in the form editor and click on "Properties ..." to bring up the property pages.

  • Click on the "Value Pairs" tab.

  • In the Axis drop-down, select the y axis you would like to apply custom labels to ("YAxis-1" by default).

  • Click "Add" twice and set the first value pair's name to Off with the value set to 0 and the second value pair's name to On with the value set to 1.

  • You may want to also go to the Ticks tab to make further adjustments. For example, if these value pairs are the only ticks and labels you want to appear, you may want to change the tick spacing to "By Units" and set major, minor, and base to 0.




Hope this helps.

- Elton
0 Kudos
Message 2 of 7
(4,068 Views)
Thanks - that worked great! Do you know if this can be done at run-time?
0 Kudos
Message 3 of 7
(4,068 Views)
Sure. Here's an example where I dropped a graph and a button on the form, and then executed this code on the button's click event:

Private Sub SetupAxisLabels_Click()

Dim yAxis As CWAxis

' Note the first axis in the collection is the x axis
Set yAxis = CWGraph1.Axes(2)

Dim offValuePair As CWValuePair
Dim onValuePair As CWValuePair

Set offValuePair = yAxis.ValuePairs.Add
Set onValuePair = yAxis.ValuePairs.Add

With offValuePair
.Name = "Off"
.Value = 0
End With

With onValuePair
.Name = "On"
.Value = 1
End With

With yAxis.Ti
cks
.MajorUnitsBase = 0
.MajorDivisions = 0
.MajorUnitsInterval = 0
.MinorDivisions = 0
.MinorUnitsInterval = 0
End With

End Sub

You can then run this application, click the button, and see the changes take effect.

- Elton
0 Kudos
Message 4 of 7
(4,068 Views)
Have you tried this in C# or VB.NET? I am trying to do this in C# and have been successful in creating a simple form with a CWGraph object. However, I don't see the CWAxis exposed. I only see the following objects exposed:
* CWButton, CWGraph, CWKnob, CWNumEdit, CWSlide

Any suggestions?
0 Kudos
Message 5 of 7
(4,068 Views)
Take a look at your project references after you add the graph to the form in a C# or VB.NET project. You'll notice that there are two interop assemblies in the references - AxCWUIControlsLib and CWUIControlsLib. CWUIControlsLib is the interop assembly that contains .NET versions of all of the interfaces from the type library in cwui.ocx, and AxCWUIControlsLib has some wrapper classes for the actual control objects and it uses the interfaces from CWUIControlsLib. Take a look at the interfaces that are contained in CWUIControlsLib and you'll see it has CWAxis as well as the rest of the sub objects.

To get the example working in C#, add this to the top of the source file:

using CWUIControlsLib;

The C# translation of
the VB example above would look like this:

private void OnSetupAxisLabelsClick(object sender, System.EventArgs e)
{
CWAxis yAxis = axCWGraph1.Axes.Item(2);

CWValuePair offValuePair = yAxis.ValuePairs.Add();
offValuePair.Name = "Off";
offValuePair.Value = 0;

CWValuePair onValuePair = yAxis.ValuePairs.Add();
onValuePair.Name = "On";
onValuePair.Value = 1;

CWTicks ticks = yAxis.Ticks;
ticks.MajorUnitsBase = 0;
ticks.MajorDivisions = 0;
ticks.MajorUnitsInterval = 0;
ticks.MinorDivisions = 0;
ticks.MinorUnitsInterval = 0;
}

- Elton
0 Kudos
Message 6 of 7
(4,068 Views)
You da man! I was so close! I was having trouble finding the correct namespace. Thanks for all your help.
0 Kudos
Message 7 of 7
(4,068 Views)