使用循环代码添加ZedGraph曲线时出现问题 [英] Problem adding ZedGraph curves with looping code

查看:86
本文介绍了使用循环代码添加ZedGraph曲线时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我是vb.net&的新手。 zedgraph所以请温柔...

我有以下非常简化的代码,可以根据数组添加一些zedgraph曲线,但它似乎清除了每个''for''的曲线循环?

如果我注释掉zg1ppl.clear()它会产生一条曲线,但显然它会积累所有曲线上的所有PointPairs。

任何想法为什么这样正在发生什么?

(为清晰起见,下面的代码大大简化了)

  Dim  LabelArr() As   String  = {  FSinDay  FSoutDay  APinDay  APoutDay} 
Dim zg1ppl As PointPairList
' 循环通过标签数组
对于 c = 0 UBound(labelArr)
' 在pointpairlist中生成一组点对象
对于 d = 0 10
zg1ppl.Add(d,d + c + 1)
Next
' 根据pointpairlist添加曲线
myCurve = myPane.AddCurve(LabelArr(c),zg1ppl,Color.Green,SymbolType.Square)
myCurve.Symbol.Fill = 填充(Color.White)
' 清除指向下一条曲线的pointpairlist
zg1ppl.Clear()
下一步

解决方案

您好,



如何将代码更改为某些内容如下所示。请查看此处的[ ^ ]文章。 CodeProject上。

  Dim  LabelArr() As  字符串 = {  FSinDay   FSoutDay  APinDay  APoutDay} 
Dim zg1ppl As PointPairList
Dim x 作为 Double
Dim y 作为 Double
Dim rand 作为 new Random()
' 循环标签数组
对于 c = 0 UBound(labelArr)
' 生成一组点对pointpairlist
zg1ppl = new PointPairList()
对于 d = 0 10
x = ( double )d + 10;
y =(rand.NextDouble()* 5 )+ Math.Sin(( double ) d * 0 2 );
zg1ppl.Add(x,y)
下一步
' 根据pointpairlist添加曲线
myCurve = myPane.AddCurve(LabelArr(c),zg1ppl,Color.Green,SymbolType.Square)
myCurve.Symbol.Fill = 填充(Color.White)
下一步


Hello all, I am new to vb.net & zedgraph so please be gentle...
I have the following very simplified code to add a number of zedgraph curves based on an array, but it appears to be clearing the curve on each ''for'' loop?
If I comment out the zg1ppl.clear() it will generate a curve but then obviously it will accumulate all the PointPairs from all curves.
Any idea why this is happening?
(code below is muchly simplified for clarity)

Dim LabelArr() As String = {"FSinDay", "FSoutDay", "APinDay", "APoutDay"}
Dim zg1ppl As New PointPairList
'loop through label array
For c = 0 To UBound(labelArr)
     'generate a set of pointpairs in the pointpairlist
     For d = 0 To 10
           zg1ppl.Add(d,d+c+1)
     Next
     'add a curve based on the pointpairlist
     myCurve = myPane.AddCurve(LabelArr(c), zg1ppl,Color.Green, SymbolType.Square)
     myCurve.Symbol.Fill = New Fill(Color.White)
     'clear the pointpairlist ready for next curve
     zg1ppl.Clear()
Next

解决方案

Hello,

How about changing your code to something as shown below. Please have a look at this[^] article, available here on CodeProject.

Dim LabelArr() As String = {"FSinDay", "FSoutDay", "APinDay", "APoutDay"}
Dim zg1ppl As PointPairList
Dim x As Double
Dim y As Double
Dim rand As new Random()
'loop through label array
For c = 0 To UBound(labelArr)
    ' generate a set of pointpairs in the pointpairlist
    zg1ppl = new PointPairList()
    For d = 0 To 10
        x = (double) d + 10;
        y = (rand.NextDouble() * 5) + Math.Sin( (double) d * 0.2);
        zg1ppl.Add(x, y)
     Next
     'add a curve based on the pointpairlist
     myCurve = myPane.AddCurve(LabelArr(c), zg1ppl, Color.Green, SymbolType.Square)
     myCurve.Symbol.Fill = New Fill(Color.White)
Next


这篇关于使用循环代码添加ZedGraph曲线时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆