//plotgraph Temperature private void PoltGraphTemperature() { //set axis X and Y GraphPane myPane = Temper_Graph.GraphPane; myPane.XAxis.Scale.Min = 0; myPane.XAxis.Scale.Max = 500; myPane.YAxis.Scale.Min = 0; myPane.YAxis.Scale.MaxAuto = true; //set text title and text axis X,Y myPane.Title.Text = "Graph Temperature"; myPane.XAxis.Title.Text = "Time"; myPane.YAxis.Title.Text = "Celsius"; //set colorline and nameline temp = myPane.AddCurve("Temperature (c)", new RollingPointPairList(500), Color.Chocolate, SymbolType.None); temp.Line.IsSmooth = true; temp.Line.Width = 3F; Temper_Graph.AxisChange(); Temper_Graph.Invalidate(); IsEnable = true; }
//timer to plotgraph private void Timer1_Tick(object sender, EventArgs e) { timer1.Enabled = true; timer1.Start(); setTimesDisplay(); this._Weather_Info = DataPoints._Weather_Info; if (!IsEnable) { PoltGraphWindDirection(); PoltGraphWindSpeed(); PoltGraphTemperature(); PoltGraphHumidity(); } if (this._Weather_Info != null) { stopwatch.Start(); TimeSpan timeSpan = stopwatch.Elapsed; double timess = timeSpan.TotalSeconds; windDirRaw.AddPoint(timess, _Weather_Info.WindDirRaw); windDirKMF.AddPoint(timess, _Weather_Info.Wind_Dir); windSpRaw.AddPoint(timess, _Weather_Info.WindSpeedRaw); windSpKMF.AddPoint(timess, _Weather_Info.Wind_Speed); temp.AddPoint(timess, _Weather_Info.Temperature); humid.AddPoint(timess, _Weather_Info.Humidity); WindDir_Graph.GraphPane.XAxis.Scale.Max = timess + 1; WindSpeed_Graph.GraphPane.XAxis.Scale.Max = timess + 1; Temper_Graph.GraphPane.XAxis.Scale.Max = timess + 1; Humidity_Graph.GraphPane.XAxis.Scale.Max = timess + 1; if (windDirRaw.Points.Count < 500 && windDirKMF.Points.Count < 500 && windSpRaw.Points.Count < 500 && windSpKMF.Points.Count < 500 && temp.Points.Count < 500 && humid.Points.Count < 500) { WindDir_Graph.GraphPane.XAxis.Scale.Min = 1; WindSpeed_Graph.GraphPane.XAxis.Scale.Min = 1; Temper_Graph.GraphPane.XAxis.Scale.Min = 1; Humidity_Graph.GraphPane.XAxis.Scale.Min = 1; } else { WindDir_Graph.GraphPane.XAxis.Scale.Min = windDirRaw.Points[0].X; WindDir_Graph.GraphPane.XAxis.Scale.Min = windDirKMF.Points[0].X; WindSpeed_Graph.GraphPane.XAxis.Scale.Min = windSpRaw.Points[0].X; WindSpeed_Graph.GraphPane.XAxis.Scale.Min = windSpKMF.Points[0].X; Temper_Graph.GraphPane.XAxis.Scale.Min = temp.Points[0].X; Humidity_Graph.GraphPane.XAxis.Scale.Min = temp.Points[0].X; } WindDir_Graph.AxisChange(); WindDir_Graph.Invalidate(); WindSpeed_Graph.AxisChange(); WindSpeed_Graph.Invalidate(); Temper_Graph.AxisChange(); Temper_Graph.Invalidate(); Humidity_Graph.AxisChange(); Humidity_Graph.Invalidate(); } }