ProEssentials v9 Help .Net Reference

Chapter 6: Graph Object's X Axis

The Graph Object is designed to show a series of y values. Every point from 0 to (Points - 1) can have a label defined by PointLabels. If there is more than one subset, all subsets share the same point label.

Here is some simple example code.

 CreateSimpleGraph(); // from our demo Pego1.PeData.Subsets = 1; Pego1.PeData.Points = 4; Pego1.PeData.PointLabels[0] = "Label1"; Pego1.PeData.PointLabels[1] = "Label2"; Pego1.PeData.PointLabels[2] = "Label3"; Pego1.PeData.PointLabels[3] = "Label4";

Given a default Graph and the above code, the result is the following image. Note the labels below the x axis.

Now lets expand on this example by increasing the Points property to 50 and see what happens.

 Pego1.PeData.Points = 50; for (int p=0; p<50; p++)     Pego1.PeData.PointLabels[p] = "Label" + (p + 1).ToString(); Pego1.PeGrid.ForceVerticalPoints = ForceVerticalPoints.Vertical;

From the looks of the graph, it is now actually displaying point labels every 5th label, it started with the 5th label, and produced 10 point labels along the x axis. This x axis structure is the result of several properties which invokes an automatic, partially automatic, or manually controlled x axis structure.

AltFrequencies is the property that controls when the graph should abandon the idea of showing all point labels. The default value is 25, so anytime the graph's Points, or PointsToGraph property is larger than 25, it will invoke logic that only places a frequency of point labels rather than all point labels.

In the case of the above graph, since Points equals 50, not all point labels will be shown.

AltFrequencies is a property array which stores point label frequency restrictions. In other words, if this property is used, then the graph must choose from among these provided frequencies. If this property is not used, any frequency of point labels can be shown. If more than one frequency is provided, it chooses the frequency which will produce the number of x axis labels closest to the value defined by the TargetPointsToTable property.

In the case of the above graph, since AltFrequencies is not defined, any frequency can be chosen. The default value of TargetPointsToTable equals 10 so the graph will choose a frequency that produces the quantity of x axis labels closest to 10. 50 points divided by the target of 10 x axis labels produces a frequency of 5. Thus, the graph shows every fifth label.

FirstPtLabelOffset is a property that controls the location of the first label. The default value is 0, in which case the first label's position will match the frequency used to place labels.

In the case of the above graph, since FirstPtLabelOffset is not used, the first label shown is the 5th label which matches the frequency used to place labels.

To help understand the above properties, lets demonstrate some variations.

 Pego1.PeGrid.Configure.AltFreqThreshold = 51;

If AltFreqThreshold is increased to more than Points, all labels are shown.

To show how to define the frequency of labels and starting label position. Starting at first label, every 10.

 Pego1.PeData.Points = 50; for (int p=0; p<50; p++)     Pego1.PeData.PointLabels[p] = "Label" + (p + 1).ToString(); Pego1.PeGrid.Configure.FirstPtLabelOffset = 1; Pego1.PeGrid.Configure.AltFrequencies[0] = 10;

# ScrollBar and the X Axis

If PointsToGraph is set to a value less than Points, then only that quantity of points will be included in the image and a horizontal scroll bar will be shown to allow the user to pan left and right through data. If using PointsToGraph, you can control which data point plots first by setting the property HorzScrollPos. The available horizontal scrollbar positions will start with 1 and end with Points - PointsToGraph + 1. It is important that when setting HorzScrollPos, that the object first be initialized with PEreinitialize, or via PEactions = 0. This is because without initializing the object, the object will not have a scrollbar.

For example, if a Graph Object has 150 data points (Points = 150), then the following code can be used to set various starting data points. In this case, and with setting PointsToGraph = 35, possible HorzScrollPos values will be between 1 and 116. First we set to 1, and then show setting of 116.

 Pego1.PeData.Points = 150; for (int p=0; p<150; p++)     Pego1.PeData.PointLabels[p] = "Label" + (p + 1).ToString(); Pego1.PeGrid.Configure.AltFreqThreshold = 40; Pego1.PeGrid.PointsToGraph = 35; Pego1.PeFunction.ReinitializeResetImage(); // always init before setting HorzScrollPos Pego1.PeUserInterface.Scrollbar.HorzScrollPos = 1;

 Pego1.PeData.Points = 150; for (int p=0; p<150; p++)     Pego1.PeData.PointLabels[p] = "Label" + (p + 1).ToString(); Pego1.PeGrid.Configure.AltFreqThreshold = 40; Pego1.PeGrid.PointsToGraph = 35; Pego1.PeFunction.ReinitializeResetImage(); // always init before setting HorzScrollPos Pego1.PeUserInterface.Scrollbar.HorzScrollPos = 116;