private void UpdateGraph() { // Make up some data points based on the Sine function var roundTripList = new PointPairList(); var avgList = new PointPairList(); const Int32 topPad = 8; Int32 x = 0; Int64 yMax = topPad; Int64 sum = 0; foreach (PingReplyData p in pingList) { if (p.RoundTripTime > yMax) { yMax = p.RoundTripTime + topPad; } roundTripList.Add(x, p.RoundTripTime); sum += p.RoundTripTime; avgList.Add(x, (Int32)(sum / (x + 1))); x++; } myPane.Title.Text = String.Format("Ping results for {0}", this.TextHost.Text); // Manually set the axis range myPane.YAxis.Scale.Min = 0; myPane.YAxis.Scale.Max = yMax; myPane.XAxis.Scale.Min = 0; myPane.XAxis.Scale.Max = x; myPane.CurveList.Clear(); LineItem myCurve = myPane.AddCurve(this.TextHost.Text, roundTripList, Color.Blue, SymbolType.Circle); myPane.AddCurve("Average", avgList, Color.Red, SymbolType.Square); // Fill the symbols with white myCurve.Symbol.Fill = new Fill(Color.White); // Associate this curve with the Y2 axis //myCurve.IsY2Axis = true; // Tell ZedGraph to calculate the axis ranges // Note that you MUST call this after enabling IsAutoScrollRange, since AxisChange() sets // up the proper scrolling parameters ZGraph.AxisChange(); // Make sure the Graph gets redrawn ZGraph.Invalidate(); }
private void UpdateGraph() { // Make up some data points based on the Sine function PointPairList list = new PointPairList(); PointPairList avgList = new PointPairList(); Int32 x = 1; Int64 yMax = 0; Int64 sum = 0; foreach (TraceRouteHopData p in hopList) { if (p.RoundTripTime > yMax) { yMax = p.RoundTripTime; } list.Add(x, p.RoundTripTime, p.Address.ToString()); sum += p.RoundTripTime; avgList.Add(x, (Int32)(sum / x)); x++; } myPane.Title.Text = String.Format("Trace Route results for {0}", this.TextHost.Text); // Manually set the axis range myPane.YAxis.Scale.Min = 0; myPane.YAxis.Scale.Max = yMax; myPane.XAxis.Scale.Min = 0; myPane.XAxis.Scale.Max = x; myPane.CurveList.Clear(); LineItem myCurve = myPane.AddCurve(this.TextHost.Text, list, Color.Blue, SymbolType.Diamond); LineItem avgCurve = myPane.AddCurve("Average", avgList, Color.Red, SymbolType.Diamond); // Fill the symbols with white myCurve.Symbol.Fill = new Fill(Color.White); // Fill the symbols with white myCurve.Symbol.Fill = new Fill(Color.White); // Associate this curve with the Y2 axis myCurve.IsY2Axis = true; // Tell ZedGraph to calculate the axis ranges // Note that you MUST call this after enabling IsAutoScrollRange, since AxisChange() sets // up the proper scrolling parameters ZGraph.AxisChange(); // Make sure the Graph gets redrawn ZGraph.Invalidate(); }