From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple, unit-different Y-axis in NI Graph using VS2013/.NET

Solved!
Go to solution

Hi

 

Is there a way to make tow different Y axis from both the right and left sides of the graph, with different scal, sharing the same X axis?

How does one refer in code to these?

 

Thanks

0 Kudos
Message 1 of 9
(6,084 Views)

Hi Gabe 1977,

 

You can edit the Y Axes on your graph by right-clicking the graph and selecting "Edit YAxes...". Here, you can add multiple axes and, under Layout in the Properties tab, you can edit the CaptionPosition and Position of each axis. You can set the these properties to Left for one axis and Right for the other.

 

Hope this helps!

Julia P.
0 Kudos
Message 2 of 9
(6,051 Views)

Hi Jupiter02

 

First, thanks.

I am talking about visual studio. I couldn't find the properties you wrote about...

0 Kudos
Message 3 of 9
(6,021 Views)
Solution
Accepted by topic author Gabe1977

Julia's response correctly describes how to configure the Windows Forms graph control in Visual Studio. If you are using the WPF graph control, the procedure is a little different:

 

WPF Graph axis configuration in Visual Studio

  1. Select the graph in the Visual Studio designer.
  2. In the Properties window, open the dialog to edit Axes.
  3. At the bottom of the collection editor dialog, select "Vertical AxisDouble" and Add two instances.
  4. Configure the Location of each axis to the Near or Far side of the graph.
  5. Configure the Label and Range to distinguish the two axes.
  6. Set a unique Name if you want to refer to the axis in code.

You can also add multiple axes in XAML or code, as described in the Configure Measurement Studio WPF Graph Control Axes and Cursors how-to topic (it is the last example in the Axes table).

~ Paul H
0 Kudos
Message 4 of 9
(5,994 Views)

Thanks!

0 Kudos
Message 5 of 9
(5,980 Views)

Hi Paul,

I have 2 ni:AxisDouble but I'm not sure how distribute data between them.

My data object is double[4][] and I'd like to apply the 4th data set to the Far axis.

Could you please let me know how this works?  At the moment they are all related to the main axis.

Thanks!

0 Kudos
Message 6 of 9
(4,481 Views)

To associate a plot with a particular vertical scale, you will need to set the VerticalScale property on that plot. For your case, where you want to associate the fourth plot with the second vertical axis, you can setup your XAML like this:

 

    <ni:Graph ...>
        <ni:Graph.Axes>
            <ni:AxisDouble x:Name="v1" Orientation="Vertical" ... />
            <ni:AxisDouble x:Name="v2" Orientation="Vertical" ... />
        </ni:Graph.Axes>
        <ni:Graph.Plots>
            <ni:​Plot Label="First Plot" />
            <ni:​Plot Label="Second Plot" />
            <ni:​Plot Label="Third Plot" />
            <ni:​Plot Label="Fourth Plot" VerticalScale="{Binding ElementName=v2}" />
        </ni:Graph.Plots>
    </ni:Graph>

~ Paul H
Message 7 of 9
(4,478 Views)

Thank you!

0 Kudos
Message 8 of 9
(4,473 Views)

Hello.

I understand how to assign a plot to a second axis (e.g. on the right side of the graph) at design time using the property page. However, I require making the assignment at run time. I have 2 Y Axes, index values 0 and 1 from the YAxis property pages at design time. The following code does not work (everything is plotted on YAxis1 (index 0):

For i = 1 To gintNumStripChartItems
'Sets the line color for each sensor on the chart
Strip.Plots.Item(i - 1).LineColor = gaStripChartItem(i).Color
'Sets the line width for each sensor on the chart
Strip.Plots.Item(i - 1).LineWidth = 2
''Assign a plot to the proper Y axis (left or right, since there are only 2)
Strip.Plots.Item(i - 1).YAxis = Strip.YAxes.Item(gaStripChartItem(i).TrackID)
Next

 

The variable gaStripChartItem(i).TrackID has the values 0 or 1 only.

 

What am I doing wrong here ?

 

Thank you

0 Kudos
Message 9 of 9
(3,343 Views)