Example 117: Scientific Graph showing real-time 3

PesgoScientific Graph Objectadvanced

Real-time 3

Preview

ProEssentials Pesgo Scientific Graph Object - Scientific Graph showing real-time 3
Click to enlarge

Source Code

Form3.cs
1//! Chart fills 100 points but x axis is initially
2//! manually scaled. Once 100 point have been passed,
3//! the chart switches to autoscaling the x axis.
4
5Pesgo1.PeData.Subsets = 1;
6Pesgo1.PeData.Points = 100;
7
8// Set Manual Y scale //
9Pesgo1.PeGrid.Configure.ManualScaleControlY = ManualScaleControl.MinMax;
10Pesgo1.PeGrid.Configure.ManualMinY = 1;
11Pesgo1.PeGrid.Configure.ManualMaxY = 100;
12
13// Set Manual X scale//
14Pesgo1.PeGrid.Configure.ManualScaleControlX = ManualScaleControl.MinMax;
15Pesgo1.PeGrid.Configure.ManualMinX = 1;
16Pesgo1.PeGrid.Configure.ManualMaxX = 100;
17
18// Clear out default data //
19Pesgo1.PeData.X[0, 0] = 0;
20Pesgo1.PeData.X[0, 1] = 0;
21Pesgo1.PeData.X[0, 2] = 0;
22Pesgo1.PeData.X[0, 3] = 0;
23Pesgo1.PeData.Y[0, 0] = 0;
24Pesgo1.PeData.Y[0, 1] = 0;
25Pesgo1.PeData.Y[0, 2] = 0;
26Pesgo1.PeData.Y[0, 3] = 0;
27
28// Set Various Other Properties ///
29Pesgo1.PeColor.BitmapGradientMode = true;
30Pesgo1.PeColor.QuickStyle = QuickStyle.DarkShadow;
31
32// Set various properties //
33Pesgo1.PeString.MainTitle = "Scientific Real-Time Example";
34Pesgo1.PeString.SubTitle = "";
35Pesgo1.PeUserInterface.Dialog.RandomPointsToExport = true;
36Pesgo1.PeUserInterface.Allow.FocalRect = false;
37Pesgo1.PePlot.Allow.Bar = false;
38Pesgo1.PeUserInterface.Allow.Popup = false;
39Pesgo1.PeConfigure.PrepareImages = true;
40Pesgo1.PeConfigure.CacheBmp = true;
41Pesgo1.PeFont.Fixed = true;
42Pesgo1.PeColor.SubsetColors[0] = Color.FromArgb(255, 200, 158, 0);
43
44Pesgo1.PeConfigure.TextShadows = TextShadows.BoldText;
45Pesgo1.PeFont.MainTitle.Bold = true;
46Pesgo1.PeFont.SubTitle.Bold = true;
47Pesgo1.PeFont.Label.Bold = true;
48Pesgo1.PePlot.Option.LineShadows = true;
49Pesgo1.PeFont.FontSize = FontSize.Large;
50Pesgo1.PeFont.SizeGlobalCntl = 1.4F;
51
52Pesgo1.PePlot.SubsetLineTypes[0] = LineType.MediumThickSolid;
53Pesgo1.PePlot.Method = SGraphPlottingMethod.PointsPlusBestFitLine;
54Pesgo1.PeGrid.Configure.AutoMinMaxPaddingX = 0;
55// Not ideal for real-time, but nice for presentation/demonstration
56Pesgo1.PePlot.Option.PointGradientStyle = PlotGradientStyle.VerticalAscentInverse;
57Pesgo1.PeColor.PointBorderColor = Color.FromArgb(100, 0, 0, 0);
58
59Pesgo1.PeConfigure.ImageAdjustLeft = 50;
60Pesgo1.PeConfigure.ImageAdjustRight = 0;
61
62// Set various export defaults //
63Pesgo1.PeSpecial.DpiX = 600;
64Pesgo1.PeSpecial.DpiY = 600;
65
66Pesgo1.PeConfigure.RenderEngine = RenderEngine.Direct2D;
67Pesgo1.PeConfigure.AntiAliasText = true;
68Pesgo1.PeConfigure.AntiAliasGraphics = true;
69
70Pesgo1.PeFunction.ReinitializeResetImage();
71
72// Initialize Counters and Timer //
73MainWindow.m_nRealTimeCounter = 1;
74MainWindow.m_nSinCounter = 1;
75
76MainWindow.Timer1.Interval = 25;
77MainWindow.Timer1.Start();
78
79/*
80/////////////////////////
81// Example Timer Event //
82/////////////////////////
83private void Timer1_Tick(object sender, System.EventArgs e)
84{
85 float[] newx = { 0.0f };
86 float[] newy = { 0.0f };
87
88 // New y value and x value //
89 newy[0] = (float)(50 + (Math.Sin(m_nSinCounter * 0.075) * 30) + (Rand_Num.NextDouble() * 15));
90 newx[0] = m_nRealTimeCounter;
91
92 // Append new values //
93 Pesgo1.PeData.Y.AppendData(newy, 1);
94 Pesgo1.PeData.X.AppendData(newx, 1);
95
96 // Increment counter ///
97 m_nRealTimeCounter = m_nRealTimeCounter + 1;
98
99 // Switch to AutoScaling x axis after receiving 100 data points ///
100 if (m_nSinCounter == 100)
101 Pesgo1.PeGrid.Configure.ManualScaleControlX = ManualScaleControl.None;
102
103 // SinCounter is only to produce sin wave data ///
104 m_nSinCounter = m_nSinCounter + 1;
105
106 if (m_nSinCounter > 30000)
107 m_nSinCounter = 1;
108
109 // Update image and force paint //
110 Pesgo1.PeFunction.ReinitializeResetImage();
111 Pesgo1.Refresh();
112}
113*/
Tip: Uses property syntax like Pego1.PeData.Y[s, p]Click underlined properties to view documentation