I'd guess that you don't have 30 real points, so when you are loading the
z
and
x
arrays you have leftover entries that contain 0.
Make the arrays exactly as large as required:
private void button3_Click(object sender, EventArgs e)
{
double[] z = new double[lines.Count];
double[] x = new double[lines.Count];
int h = 0;
try
{
foreach (double line in lines)
{
MessageBox.Show(line.ToString());
z[h] = line;
x[h] = (double)h;
h++;
}
}
catch
{
}
zedGraphControl1.GraphPane.CurveList.Clear();
GraphPane myPane = zedGraphControl1.GraphPane;
PointPairList spl1 = new PointPairList(x, z);
Using Linq, this could be further simplified:
private void button3_Click(object sender, EventArgs e)
{
double[] z = lines.ToArray();
double[] x = Enumerable.Range(0, lines.Count).ToArray();
zedGraphControl1.GraphPane.CurveList.Clear();
GraphPane myPane = zedGraphControl1.GraphPane;
PointPairList spl1 = new PointPairList(x, z);