| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3466 人关注过本帖
标题:C# 中 chart 表格同时显示多条曲线问题?
只看楼主 加入收藏
WYC910220
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2014-7-22
收藏
 问题点数:0 回复次数:0 
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)
            {
   
            }





        }
搜索更多相关主题的帖子: private 数据库 
2014-08-01 15:50
快速回复:C# 中 chart 表格同时显示多条曲线问题?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.042528 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved