Example 029: Graph showing Table Annotations, Table spaced

PegoGraph Objectintermediate

Table Annotations, Table spaced

Preview

ProEssentials Pego Graph Object - Graph showing Table Annotations, Table spaced
Click to enlarge

Source Code

Form2.cs
1//! This shows how to place extra text inside table and within an axis. //
2//! Maximize to allow room for textual data which is drawn as fixed font size. //
3
4// This example builds upon the basic CreateSimpleGraph '000' example chart //
5CreateSimpleGraph(Pego1);
6
7Pego1.PeColor.SubsetColors[0] = MainWindow.DemoColors[0];
8Pego1.PeColor.SubsetColors[1] = MainWindow.DemoColors[1];
9Pego1.PeColor.SubsetColors[2] = MainWindow.DemoColors[2];
10Pego1.PeColor.SubsetColors[3] = MainWindow.DemoColors[3];
11
12// Create two y axes //
13Pego1.PeGrid.MultiAxesSubsets[0] = 2;
14Pego1.PeGrid.MultiAxesSubsets[1] = 2;
15
16// Construct a simple table annotation //
17Pego1.PeAnnotation.Table.Working = 0;
18Pego1.PeAnnotation.Table.Rows = 6;
19Pego1.PeAnnotation.Table.Columns = 12; //! 12 is same number as PEP_nPOINTS
20
21// Pass the table text //
22Boolean b = false;
23
24Color dwColor;
25int r, c;
26for(r=0; r<6; r++)
27{
28 if(b)
29 dwColor = Color.FromArgb(255, 175, 175, 175);
30 else
31 dwColor = Color.FromArgb(255, 255, 255, 255);
32 b = !b;
33
34 for(c=0; c <12; c++)
35 {
36 Pego1.PeAnnotation.Table.Text[r, c] = String.Format("{0:###0.000}", ((Math.Sin(0.3 * c + 1) * 500.0) + ((float)(Rand_Num.NextDouble()) * 50)) );
37 Pego1.PeAnnotation.Table.Color[r, c] = dwColor;
38 }
39}
40
41// Set Table Location //
42Pego1.PeAnnotation.Table.Location = GraphTALocation.InsideAxis1;
43Pego1.PeAnnotation.Table.AxisLocation = GraphTAAxisLocation.BottomTableSpaced;
44
45// Other Table Related Properties ///
46Pego1.PeAnnotation.Table.Show = true;
47Pego1.PeAnnotation.Table.Border = TABorder.NoBorder;
48Pego1.PeAnnotation.Table.BackColor = Color.FromArgb(0,1,0,0); /* Empty Same as GraphBackColor in this instance */
49Pego1.PeAnnotation.Table.ForeColor = Color.FromArgb(0,1,0,0); /* Empty Same as GraphForeColor in this instance */
50
51// Construct a second simple table annotation //
52Pego1.PeAnnotation.Table.Working = 1;
53Pego1.PeAnnotation.Table.Rows = 6;
54Pego1.PeAnnotation.Table.Columns = 12;
55
56// Pass the table text //
57b = true;
58for(r=0; r<6; r++)
59{
60 if(b)
61 dwColor = Color.FromArgb(255, 175, 175, 175);
62 else
63 dwColor = Color.FromArgb(255, 255, 255, 255);
64 b = !b;
65 for(c=0; c<12; c++)
66 {
67 Pego1.PeAnnotation.Table.Text[r, c] = String.Format("{0:###0.000}",((Math.Sin(0.3 * c + 1) * 500.0) + ((float)(Rand_Num.NextDouble()) * 50)));
68 Pego1.PeAnnotation.Table.Color[r, c] = dwColor;
69 }
70}
71
72// Set Table Location //
73Pego1.PeAnnotation.Table.Location = GraphTALocation.InsideAxis0;
74Pego1.PeAnnotation.Table.AxisLocation = GraphTAAxisLocation.BottomTableSpaced;
75
76// Other Table Related Properties ///
77Pego1.PeAnnotation.Table.Show = true;
78Pego1.PeAnnotation.Table.Border = TABorder.NoBorder;
79Pego1.PeAnnotation.Table.BackColor = Color.FromArgb(0,1,0,0); // Same as GraphBackColor in this instance
80Pego1.PeAnnotation.Table.ForeColor = Color.FromArgb(0,1,0,0); // Colors.Empty; // Same as GraphForeColor in this instance
81
82// Construct a third simple table annotation //
83Pego1.PeAnnotation.Table.Working = 2;
84Pego1.PeAnnotation.Table.Rows = 2;
85Pego1.PeAnnotation.Table.Columns = 13; // 12 + extra header column
86
87// Pass the table text //
88for(r=0; r<=1; r++)
89{
90 for(c=1; c<=12; c++)
91 Pego1.PeAnnotation.Table.Text[r, c] = String.Format( "{0:###0.000}",(Math.Sin(0.3 * c + 1) * 500.0) + ((float)(Rand_Num.NextDouble()) * 50));
92}
93
94// Set Table Location //
95Pego1.PeAnnotation.Table.Location = GraphTALocation.InsideTable;
96Pego1.PeAnnotation.Table.AxisLocation = GraphTAAxisLocation.TopTableSpaced;
97
98// Other Table Related Properties ///
99Pego1.PeAnnotation.Table.Show = true;
100Pego1.PeAnnotation.Table.BackColor = Color.FromArgb(255, 0, 198, 198);
101Pego1.PeAnnotation.Table.HeaderColumn = true;
102
103// Set Text for Header Column //
104Pego1.PeAnnotation.Table.Text[0, 0] = "Table Annotation Line 1";
105Pego1.PeAnnotation.Table.Text[1, 0] = "Table Annotation Line 2";
106
107// Done setting Table Annotations ///
108
109// Set Various Other Properties ///
110Pego1.PeColor.BitmapGradientMode = true;
111Pego1.PeColor.QuickStyle = QuickStyle.DarkShadow;
112Pego1.PeData.Precision = 0;
113Pego1.PeTable.Show = GraphPlusTable.Both;
114Pego1.PeLegend.Style = LegendStyle.OneLineInsideAxis;
115Pego1.PeGrid.LineControl = GridLineControl.YAxis;
116Pego1.PePlot.MarkDataPoints = false;
117Pego1.PeFont.FontSize = FontSize.Small;
118Pego1.PePlot.DataShadows = DataShadows.Shadows;
119Pego1.PeLegend.Show = true;
120
121Pego1.PeGrid.WorkingAxis = 0;
122Pego1.PePlot.Method = GraphPlottingMethod.Bar;
123Pego1.PePlot.MethodII = GraphPlottingMethodII.PointsPlusLine;
124Pego1.PePlot.RYAxisComparisonSubsets = 1;
125Pego1.PeColor.RYAxis = Pego1.PeColor.SubsetColors[1];
126Pego1.PeString.YAxisLabel = "";
127Pego1.PeString.RYAxisLabel = "";
128
129Pego1.PeGrid.WorkingAxis = 1;
130Pego1.PePlot.Method = GraphPlottingMethod.Bar;
131Pego1.PePlot.MethodII = GraphPlottingMethodII.PointsPlusLine;
132Pego1.PePlot.RYAxisComparisonSubsets = 1;
133Pego1.PeColor.RYAxis = Pego1.PeColor.SubsetColors[3];
134Pego1.PeString.YAxisLabel = "";
135Pego1.PeString.RYAxisLabel = "";
136
137Pego1.PeUserInterface.Menu.ShowTableAnnotations = MenuControl.Show;
138Pego1.PeUserInterface.Menu.DataPrecision = MenuControl.Hide;
139
140// Set various export defaults //
141Pego1.PeSpecial.DpiX = 600;
142Pego1.PeSpecial.DpiY = 600;
143
144Pego1.PeFunction.ReinitializeResetImage();
145Pego1.Invalidate();
146// Optionally call Pego1.Refresh() if you are not seeing changes immediately
Tip: Uses property syntax like Pego1.PeData.Y[s, p]Click underlined properties to view documentation