首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

ZedGraph 怎么清空曲线

2012-01-13 
ZedGraph 如何清空曲线VS2005+ZedGraph 5.1.5 Winform我用下面的方法加了两条参考线C# codeprivate PointP

ZedGraph 如何清空曲线
VS2005+ZedGraph 5.1.5 Winform

我用下面的方法加了两条参考线

C# code
        private PointPairList lstStart1 = new PointPairList();        private PointPairList lstStart2 = new PointPairList();        private void draw()        {           lstStart1.Add(5.00, 2.0);            lstStart1.Add(9.00, 2.0);            lstStart1.Add(9.00, 1.0);            myCurve1 = myPane.AddCurve("Min", lstStart1, Color.Red, SymbolType.None);            lstStart2.Add(5.00, 2.60);            lstStart2.Add(9.00, 2.60);            myCurve2 = myPane.AddCurve("Max", lstStart2, Color.Yellow, SymbolType.None);       }


然后我用一个循环继续往图表里画线
C# code
                    if (i <= 36)                    {                        double x = i;                        double y = 1.5 + Math.Sin(i * 0.2);                        y = Math.Round(y, 3);                        list1.Add(x, y);                        myCurve = myPane.AddCurve("", list1, Color.White, SymbolType.None);                         zedGraphControl1.GraphPane = myPane;                        zedGraphControl1.AxisChange();                        zedGraphControl1.Refresh();                        Application.DoEvents();                                            }

问题如下:

如果我最后不加myPane.CurveList.Clear();这句的话,绘制曲线会越来越慢(一个循环10毫秒),所以我想达到的要求是,当循环绘制的曲线超过10条的时候,清除最早的一条,也就是说图中只保留最新的10条曲线,但不能清除事先画好的参考线(清除了,重画也可以,但不能把所有曲线都一次清除了,要保留最新的10条)

[解决办法]
Refresh()方法可以强制控件进行重绘
先清除
zedChart.GraphPane.CurveList.Clear();
zedChart.GraphPane.GraphItemList.Clear();
重新绘制
zedChart.AxisChange();
zedChart.Refresh();

热点排行