代码如下。
SqlDataReader dr = cmd.ExecuteReader();
chart1.DataSource = dr;
chart1.Series.Add(i.ToString());
chart1.Series[i.ToString()].XValueMember = "Hour";
chart1.Series[i.ToString()].YValueMembers = "A";
chart1.Series[i.ToString()].BorderWidth = 3;
chart1.Series[i.ToString()].Label = "#VAL";
chart1.Series[i.ToString()].ChartType = SeriesChartType.Line;
chart1.Series[i.ToString()].AxisLabel = "#VALX点";
chart1.DataBind();
i=i+1;
dr.Close();
运行结果:
问题:点击 添加 按钮时能添加新的series。但是之前的添加的series的数据会变成与新添加的series的数据相同。如图所示