2014-09-27 43 views
0

我正在使用ZedGraph。我只有一個控件包含三個窗格。我像這樣初始化它們:ZedGraph多個窗格

private void GraphIt() 
    { 
     MasterPane master = zedGraphControl1.MasterPane; 
     master.PaneList.Clear(); 

     // Display the MasterPane Title, and set the outer margin to 10 points 
     master.Title.IsVisible = true; 
     master.Title.Text = "Angles"; 
     master.Margin.All = 10; 

     // Create some GraphPane's (normally you would add some curves too 
     GraphPane pane1 = new GraphPane(); 
     GraphPane pane2 = new GraphPane(); 
     GraphPane pane3 = new GraphPane(); 

     // Add all the GraphPanes to the MasterPane 
     master.Add(pane1); 
     master.Add(pane2); 
     master.Add(pane3); 

     pane1.XAxis.Scale.MinorStep = pane2.XAxis.Scale.MinorStep = pane3.XAxis.Scale.MinorStep = 1; 
     pane1.XAxis.Scale.MajorStep = pane2.XAxis.Scale.MajorStep = pane3.XAxis.Scale.MajorStep = 50; 

     PointPairList dummylist = new PointPairList(); 
     myCurve1 = pane1.AddCurve("Angle X", dummylist, Color.Red); 
     myCurve2 = pane2.AddCurve("Angle Y", dummylist, Color.Blue); 
     myCurve3 = pane3.AddCurve("Angle Z", dummylist, Color.Green); 
     myCurve1.Line.Width = myCurve2.Line.Width = myCurve3.Line.Width = 5; 
     myCurve1.Symbol.Size = myCurve2.Symbol.Size = myCurve3.Symbol.Size = 0; 

     // Refigure the axis ranges for the GraphPanes 
     zedGraphControl1.AxisChange(); 

     // Layout the GraphPanes using a default Pane Layout 
     using (Graphics g = this.CreateGraphics()) 
     { 
      master.SetLayout(g, PaneLayout.SquareColPreferred); 
     } 
    } 

我想在一個窗格中繪製每條實時曲線。我在程序運行期間添加點並刷新圖形。除了每條曲線的點也被添加到其他曲線之外,一切都是完美的。 例如:

myCurve1.AddPoint(Time, 10); 
myCurve2.AddPoint(Time, 5); 
myCurve3.AddPoint(Time, 1); 

我這樣做是爲了補充我的觀點。什麼情況是,每條曲線上,如果我這樣做是增加了三點:

myCurve1.AddPoint(Time, 10); 
myCurve1.AddPoint(Time, 5); 
myCurve1.AddPoint(Time, 1); 

myCurve2.AddPoint(Time, 10); 
myCurve2.AddPoint(Time, 5); 
myCurve2.AddPoint(Time, 1); 

myCurve3.AddPoint(Time, 10); 
myCurve3.AddPoint(Time, 5); 
myCurve3.AddPoint(Time, 1); 

回答

2

更改此:

PointPairList dummylist = new PointPairList(); 
myCurve1 = pane1.AddCurve("Angle X", dummylist, Color.Red); 
myCurve2 = pane2.AddCurve("Angle Y", dummylist, Color.Blue); 
myCurve3 = pane3.AddCurve("Angle Z", dummylist, Color.Green); 

這樣:

PointPairList dummylist = new PointPairList(); 
myCurve1 = pane1.AddCurve("Angle X", dummylist, Color.Red); 
dummylist = new PointPairList(); 
myCurve2 = pane2.AddCurve("Angle Y", dummylist, Color.Blue); 
dummylist = new PointPairList(); 
myCurve3 = pane3.AddCurve("Angle Z", dummylist, Color.Green);