ZedGraph多个窗格

时间:2014-09-27 10:26:02

标签: c# graph plot live 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);

1 个答案:

答案 0 :(得分: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);