Example 027: Graph showing Table Annotations, Stacked

PegoGraph Objectintermediate

Table Annotations, Stacked

Preview

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

Source Code

Form2.cs
1// This example builds upon the basic CreateSimpleGraph '000' example chart //
2CreateSimpleGraph(Pego1);
3
4/////////////////////////////////////////
5// Construct a simple table annotation //
6/////////////////////////////////////////
7Pego1.PeAnnotation.Table.Working = 0;
8Pego1.PeAnnotation.Table.Rows = 1;
9Pego1.PeAnnotation.Table.Columns = 2;
10Pego1.PeAnnotation.Table.TextSize = 85;
11
12// Pass the table text //
13Pego1.PeAnnotation.Table.Text[0, 0] = "Category 1";
14Pego1.PeAnnotation.Table.Text[0, 1] = "Category 2";
15
16// Set column widths //
17Pego1.PeAnnotation.Table.ColumnWidth[0] = 28;
18Pego1.PeAnnotation.Table.ColumnWidth[1] = 28;
19Pego1.PeAnnotation.Table.Justification[0, 0] = TAJustification.Center;
20Pego1.PeAnnotation.Table.Justification[0, 1] = TAJustification.Center;
21
22Pego1.PeAnnotation.Table.Show = true;
23Pego1.PeAnnotation.Table.Location = GraphTALocation.InsideAxis0;
24Pego1.PeAnnotation.Table.AxisLocation = GraphTAAxisLocation.TopLeft;
25Pego1.PeAnnotation.Table.Border = TABorder.SingleLine;
26Pego1.PeAnnotation.Table.BackColor = Color.FromArgb(55, 255, 255, 255);
27Pego1.PeAnnotation.Table.GradientStyle = PlotGradientStyle.Vertical;
28
29/////////////////////////////////////////
30// Construct a simple table annotation //
31/////////////////////////////////////////
32Pego1.PeAnnotation.Table.Working = 1;
33Pego1.PeAnnotation.Table.Rows = 1;
34Pego1.PeAnnotation.Table.Columns = 4;
35Pego1.PeAnnotation.Table.TextSize = 85;
36
37Pego1.PeAnnotation.Table.Text[0, 0] = "Sub Cat 1";
38Pego1.PeAnnotation.Table.Text[0, 1] = "Sub Cat 2";
39Pego1.PeAnnotation.Table.Text[0, 2] = "Sub Cat 3";
40Pego1.PeAnnotation.Table.Text[0, 3] = "Sub Cat 4";
41Pego1.PeAnnotation.Table.ColumnWidth[0] = 14;
42Pego1.PeAnnotation.Table.ColumnWidth[1] = 14;
43Pego1.PeAnnotation.Table.ColumnWidth[2] = 14;
44Pego1.PeAnnotation.Table.ColumnWidth[3] = 14;
45Pego1.PeAnnotation.Table.Justification[0, 0] = TAJustification.Center;
46Pego1.PeAnnotation.Table.Justification[0, 1] = TAJustification.Center;
47Pego1.PeAnnotation.Table.Justification[0, 2] = TAJustification.Center;
48Pego1.PeAnnotation.Table.Justification[0, 3] = TAJustification.Center;
49
50Pego1.PeAnnotation.Table.BackColor = Color.FromArgb(55, 240, 240, 240);
51Pego1.PeAnnotation.Table.GradientStyle = PlotGradientStyle.Vertical;
52
53Pego1.PeAnnotation.Table.Show = true;
54
55Pego1.PeAnnotation.Table.Location = GraphTALocation.InsideAxis0;
56Pego1.PeAnnotation.Table.AxisLocation = GraphTAAxisLocation.TopLeft + Convert.ToInt32(GraphTAAxisLocation.NewRow);
57
58Pego1.PeAnnotation.Table.Border = TABorder.SingleLine;
59
60/////////////////////////////////////////
61// Construct a simple table annotation //
62/////////////////////////////////////////
63Pego1.PeAnnotation.Table.Working = 2;
64Pego1.PeAnnotation.Table.Rows = 4;
65Pego1.PeAnnotation.Table.Columns = 8;
66Pego1.PeAnnotation.Table.TextSize = 85;
67
68// Set Column Widths //
69Pego1.PeAnnotation.Table.ColumnWidth[0] = 7;
70Pego1.PeAnnotation.Table.ColumnWidth[1] = 7;
71Pego1.PeAnnotation.Table.ColumnWidth[2] = 7;
72Pego1.PeAnnotation.Table.ColumnWidth[3] = 7;
73Pego1.PeAnnotation.Table.ColumnWidth[4] = 7;
74Pego1.PeAnnotation.Table.ColumnWidth[5] = 7;
75Pego1.PeAnnotation.Table.ColumnWidth[6] = 7;
76Pego1.PeAnnotation.Table.ColumnWidth[7] = 7;
77
78// Pass the table text //
79int r;
80int c;
81for(r=0; r<4; r++)
82{
83 for(c=0; c <8; c++)
84 {
85 Pego1.PeAnnotation.Table.Text[r, c] = String.Format( "{0:###.00}",(System.Math.Sin(0.3 * c + 1) * 500.0) + ((float)(Rand_Num.NextDouble()) * 50));
86
87 if( c > 5)
88 Pego1.PeAnnotation.Table.Color[r, c] = Color.FromArgb(255, 0, 148, 0);
89 else if( c > 3 )
90 Pego1.PeAnnotation.Table.Color[r, c] = Color.FromArgb(255, 148, 148, 0);
91 else if( c > 1 )
92 Pego1.PeAnnotation.Table.Color[r, c] = Color.FromArgb(255, 0, 148, 148);
93 else
94 Pego1.PeAnnotation.Table.Color[r, c] = Color.FromArgb(255, 198, 0, 0);
95 Pego1.PeAnnotation.Table.Justification[r, c] = TAJustification.Center;
96 }
97}
98
99// Other Table Related Properties ///
100Pego1.PeAnnotation.Table.Show = true;
101
102Pego1.PeAnnotation.Table.Location = GraphTALocation.InsideAxis0;
103Pego1.PeAnnotation.Table.AxisLocation = GraphTAAxisLocation.TopLeft + (Convert.ToInt32(GraphTAAxisLocation.NewRow) * 2);
104Pego1.PeAnnotation.Table.Border = TABorder.SingleLine;
105
106Pego1.PeAnnotation.Table.BackColor = Color.FromArgb(255, 200, 200, 200);
107
108// Done setting Table Annotations ///
109
110// Set Various Other Properties ///
111Pego1.PeColor.BitmapGradientMode = true;
112Pego1.PeColor.QuickStyle = QuickStyle.LightInset;
113Pego1.PeGrid.LineControl = GridLineControl.Both;
114Pego1.PeData.Precision = 0;
115Pego1.PeGrid.Option.AxisNumberSpacing = 1.5;
116Pego1.PePlot.Method = GraphPlottingMethod.Bar;
117Pego1.PePlot.Option.BarGlassEffect = false;
118Pego1.PePlot.DataShadows = DataShadows.ThreeDimensional;
119
120Pego1.PeFunction.ReinitializeResetImage();
121Pego1.Invalidate();
122// 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