C# 中 chart 表格同时显示多条曲线问题?
C#连接ACCESS数据库,显示到dataGridView表格中,利用数据在chart表格中显示3条曲线,结果只能最上面一条?这是什么原因,谢谢代码:
private void button1_Click(object sender, EventArgs e)
{
string strpath = (string)comboBox1.SelectedItem;
try
{
DataSet myds = new DataSet();
string ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Windows.Forms.Application.StartupPath.ToString() + "/土壤光谱数据信息库/" + strpath + ".mdb" + ";Persist Security Info=True";//创建OleDbConnection对象
OleDbConnection con = new OleDbConnection(ConStr);
//int selectNodeIndex = comboBox1.SelectedIndex + 2;
OleDbCommand mycmd = new OleDbCommand("Select * From 土壤光谱数据", con);
con.Open();
mycmd.Connection = con;
OleDbDataReader myReader = mycmd.ExecuteReader();
// OleDbDataReader myReader1= mycmd.ExecuteReader();
chart1.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
chart1.Series[1].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
chart1.Series[2].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
chart1.Series["Series1"].Points.DataBindXY(myReader, "波长", myReader, "DYT-01-1");
// chart1.Series["Series2"].Points.DataBindXY(myReader1, "波长", myReader1,"DYT-01-2");
chart1.Series["Series3"].Points.DataBindXY(myReader, "波长", myReader, "DYT-01-3");
//设置图表Y轴对应项
con.Close();
chart1.ChartAreas[0].AxisX.Minimum = 350;
chart1.ChartAreas[0].AxisX.Title = "波长";
chart1.ChartAreas[0].AxisY.Title = "反射率";
// chart1.ChartAreas[0].AxisY.Title = "DYT-01-2";
// chart1.ChartAreas[0].AxisY.Title = "DYT-01-3";
}
catch (Exception)
{
}
}