ProEssentials v9 Help .Net Reference

Chapter 6: Multiple Y Axes

If new to ProEssentials, before reviewing this content, please review demo example 000 or one of the Walkthroughs.  Next review Chapter 6 Comparison Subsets.

#### MultiAxesSubsets

You will use the MultiAxesSubsets property to subdivide your subsets among multiple axes. When not using OverlapMultiAxes, only two y axes (one left, and one right) can share the same graph real-estate. When MultiAxesSubsets are defined, resulting (right/left) axes-pairs are stacked vertically top to bottom.

We will discuss OverlapMultiAxes later in this section. You first need to understand MultiAxesSubsets before you can use or understand OverlapMultiAxes. Let's start with an example.

For example: a graph has 5 subsets and you want to divide these 5 subsets among 3 y axes.

The first (top) y axis will have 1 subset,
the second (middle) y axis will have 2 subsets, and
the third and final y axis (bottom) will have 2 subsets.

 Pego1.PeData.Subsets = 5; Pego1.PeData.Points = 4; for (int s = 0; s < 5; s++) {   for (int p = 0; p < 4; p++)      Pego1.PeData.Y[s, p]=5.0F+(float)Rand_Num.NextDouble()*25.0F; } // Divide 5 subsets between 3 axes Pego1.PeGrid.MultiAxesSubsets[0] = 1; Pego1.PeGrid.MultiAxesSubsets[1] = 2; Pego1.PeGrid.MultiAxesSubsets[2] = 2; Pego1.PeGrid.Option.MultiAxisStyle = MultiAxisStyle.SeparateAxes; Pego1.PeLegend.Style = LegendStyle.OneLineTopOfAxis;

Note that when we add up all the MultiAxesSubsets values (1, 2, 2) they equate to 5 the same value we set for the Subsets property. This should always be the case.

The above code produces the following graph.

To expand on this example, lets make an adjustment so that the middle y axis has 1 subset plotted with respect to the left y axis and the second subset plotted with respect to the right y axis. We also want to label the left and right y axes and plot the second subset as a Bar and the third subset as Points plus Spline.

 Pego1.PeData.Subsets = 5; Pego1.PeData.Points = 4; for (int s = 0; s < 5; s++) {   for (int p = 0; p < 4; p++)   {     if (s == 2) // Make 3rd subset larger magnitude        Pego1.PeData.Y[s, p] = 5.0F + (float)Rand_Num.NextDouble() * 250.0F;     else        Pego1.PeData.Y[s, p] = 5.0F + (float)Rand_Num.NextDouble() * 25.0F;   } } // Dividing Subsets Among 3 Y Axes Pego1.PeGrid.MultiAxesSubsets[0] = 1; Pego1.PeGrid.MultiAxesSubsets[1] = 2; Pego1.PeGrid.MultiAxesSubsets[2] = 2; Pego1.PeGrid.Option.MultiAxisStyle = MultiAxisStyle.SeparateAxes; Pego1.PeLegend.Style = LegendStyle.OneLineTopOfAxis; // Set some attributes of middle axis Pego1.PeGrid.WorkingAxis = 1; // 1 = zero based index of middle axis Pego1.PePlot.Method = GraphPlottingMethod.Bar; Pego1.PePlot.RYAxisComparisonSubsets = 1; Pego1.PePlot.MethodII = GraphPlottingMethodII.PointsPlusSpline; Pego1.PeGrid.WorkingAxis = 0; //good practice to reset when done using

The above code produces the following graph. Note how setting WorkingAxis = 1 controls those subsets and y axes defined by MultiAxesSubsets(1). Also note that RYAxisComparisonSubsets no longer represents the number of subsets at the end of data, but the number of subsets at the end of data for a particular MultiAxesSubsets.

Note that we use the term middle axis, but in fact, the middle axis has two axes, one left and one right. To reiterate, each MultiAxesSubsets is a section of the chart which can contain one left and/or one right y axis.

MultiAxesSubsets has a limitation of 16 sections. Each section containing one left and/or one right y axis. Thus, you will only use indices (0) through (15) with this property array. This also means the WorkingAxis property only has valid values between 0 and 15.

### OverlapMultiAxes

Now lets discuss OverlapMultiAxes. This property array lets you subdivide your MultiAxesSubsets as MultiAxesSubsets lets you subdivide your Subsets. In other words, you can subdivide your MultiAxesSubsets among overlapping multiple axis sections. Like MultiAxesSubsets, these overlapping sections start at the top and grow downward. Again, it's easier to visualize in an example.

Lets expand on the above example one more time. This time we want the middle and bottom y axes to overlap, using the same chart real-estate.

All we do is add the two following lines of code...

 // Dividing MultiAxesSubsets into overlapping sections Pego1.PeGrid.OverlapMultiAxes[0] = 1; Pego1.PeGrid.OverlapMultiAxes[1] = 2;

To further discuss...

 Pego1.PeGrid.OverlapMultiAxes[0] = 1;

The above line of code tells ProEssentials that the first overlapping section will have one multi-axis. Thus, there really is no overlapping taking place in this first section.

 Pego1.PeGrid.OverlapMultiAxes[1] = 2;

The above line of code tells ProEssentials that the second overlapping section will have two multi-axes. This causes the last two MultiAxesSubsets defined to overlap each other.

Now, note that when we add up all the OverlapMultiAxes values (1, 2) they equate to 3 the same number of MultiAxesSubsets elements we defined ...

 1) Pego1.PeGrid.MultiAxesSubsets[0] = 1 2) Pego1.PeGrid.MultiAxesSubsets[1] = 2 3) Pego1.PEGrid.MultiAxesSubsets[2] = 2

This should always be the case in your code.

Below is a final example setting overlapping axes and attributes of bottom axis...

 Pego1.PeData.Subsets = 5; Pego1.PeData.Points = 4; for (int s = 0; s < 5; s++) {   for (int p = 0; p < 4; p++)   {     if (s == 2) // Make 3rd subset larger magnitude        Pego1.PeData.Y[s, p] = 5.0F + (float)Rand_Num.NextDouble() * 250.0F;     else        Pego1.PeData.Y[s, p] = 5.0F + (float)Rand_Num.NextDouble() * 25.0F;   } } // Dividing Subsets Among 3 Y Axes Pego1.PeGrid.MultiAxesSubsets[0] = 1; Pego1.PeGrid.MultiAxesSubsets[1] = 2; Pego1.PeGrid.MultiAxesSubsets[2] = 2; // Dividing MultiAxesSubsets into overlapping sections Pego1.PeGrid.OverlapMultiAxes[0] = 1; Pego1.PeGrid.OverlapMultiAxes[1] = 2; Pego1.PeGrid.Option.MultiAxisStyle = MultiAxisStyle.SeparateAxes; Pego1.PeLegend.Style = LegendStyle.OneLineTopOfAxis; // Set some attributes of middle axis Pego1.PeGrid.WorkingAxis = 1; // 1 = zero based index of middle axis Pego1.PePlot.Method = GraphPlottingMethod.Bar; Pego1.PePlot.RYAxisComparisonSubsets = 1; Pego1.PePlot.MethodII = GraphPlottingMethodII.PointsPlusSpline; // Set label of bottom left axis Pego1.PeGrid.WorkingAxis = 2; // 2 = zero based index for third axes Pego1.PeString.YAxisLabel = "Bottom Left"; Pego1.PeGrid.WorkingAxis = 0; //good practice to reset when done using

Note how the Bottom Left axis is now along side the Mid Left axis, Axis #2. All four subsets making up MultiAxesSubsets(1) and MultiAxesSubsets(2) are plotted in the second overlapping section.

### MultiAxesProportions

One final topic related to multi-axes and overlapping-multi-axes is the property MultiAxesProportions. This property will allow you to control the size of each of the Multi-Axes sections, or Overlapping-Multi-Axes sections.

#### MultiAxesSubsets

When you are only using MultiAxesSubsets (not overlapping), you define the same number of elements of MultiAxesProportions as used in MultiAxesSubsets.

In the above example without overlapping axes, we had...

 // Dividing Subsets Among 3 Y Axes Pego1.PeGrid.MultiAxesSubsets[0] = 1; //first/top axis 1 subset Pego1.PeGrid.MultiAxesSubsets[1] = 2; //second/middle axis 2 subsets Pego1.PeGrid.MultiAxesSubsets[2] = 2; //last/bottom axis 2 subsets

Thus you will also have three elements of proportions like...

 // Controlling size of each multi-axis Pego1.PeGrid.MultiAxesProportions[0] = .15F; //top axis uses 15% Pego1.PeGrid.MultiAxesProportions[1] = .35F; //next axis uses 35% Pego1.PeGrid.MultiAxesProportions[2] = .50F; //last axis uses 50%

Note how 15 + 35 + 50 = 100. The values of MultiAxesProportions will always add up to 100 percent.

#### OverlapMultiAxes

When you are using OverlapMultiAxes, then you define the same number of elements of MultiAxesProportions as used in the OverlapMultiAxes.

For the above example where you are overlapping axes, you added...

 // Dividing MultiAxesSubsets into overlapping sections Pego1.PeGrid.OverlapMultiAxes[0] = 1; Pego1.PeGrid.OverlapMultiAxes[1] = 2;

Since you are using Overlapping-Multi-Axes, you will have only two elements of proportions like...

 // Controlling size of each overlapping multi-axis Pego1.PeGrid.MultiAxesProportions[0] = .40F; //top section uses 40% Pego1.PeGrid.MultiAxesProportions[1] = .60F; //next section uses 60%

TIP:

First ignore OverlapMultiAxes and MultiAxesProportions and initially implement only MultiAxesSubsets. After you have all the individual axes looking as desired, then add the OverlapMultiAxes property to overlap the desired axes. Finally, if needed add MultiAxesProportions to contain the same number of elements as OverlapMultiAxes. Note that when implementing MultiAxesSubsets, the subsets have to be in the order that you want them allocated to axes. The same goes for OverlapMultiAxes and the axes have to be in the order that you want them allocated to overlap.

If you change the structure of these properties, it's best to start by clearing all property arrays like...

 Pego1.PeGrid.MultiAxesSubsets.Clear(); Pego1.PeGrid.OverlapMultiAxes.Clear(); Pego1.PeGrid.MultiAxesProportions.Clear();

Look in the example projects for examples 012, 013, 103 and 104 on how multiple and overlapped y axes are implemented.

 ©2022 Gigasoft, Inc. | All rights reserved. Gigasoft is a registered trademark, and ProEssentials a trademark of Gigasoft, Inc.