private void btn_Click(object sender, EventArgs e) { DBHelper db = new DBHelper(); DataSet ds = db.GetDataList(); this.dataGridView1.DataSource = ds.Tables[0]; DataSet ds1 = db.GetResportLine(); DataSet ds2 = db.GetResportLine2(); DataSet ds3 = db.GetResportLine3(); DataTable dt1 = ds1.Tables[0]; DataTable dt2 = ds2.Tables[0]; DataTable dt3 = ds3.Tables[0]; //chart1.ChartAreas[0].AxisX.Maximum = 1000;//设定x轴的最大值 //chart1.ChartAreas[0].AxisY.Maximum = 100;//设定y轴的最大值 //chart1.ChartAreas[0].AxisX.Minimum = 1;//设定x轴的最小值 //chart1.ChartAreas[0].AxisY.Minimum = 0;//设定y轴的最小值 //第一条数据 Series ss = new Series("dt1"); //这里 dt1 ,dt2 任意取名称,但要唯一 ss.Points.DataBind(dt1.AsEnumerable(), "xzhou", "yzhou", ""); ss.XValueType = ChartValueType.DateTime; //设置X轴 ss.ChartType = SeriesChartType.Spline; //设置Y轴为折线 chart1.Series.Add(ss); //第二条数据 Series ss2 = new Series("dt2"); ss2.Points.DataBind(dt2.AsEnumerable(), "xzhou2", "yzhou2", ""); ss2.XValueType = ChartValueType.DateTime; //设置X轴 ss2.ChartType = SeriesChartType.Spline; //设置Y轴为折线 chart1.Series.Add(ss2); //第三条数据 Series ss3 = new Series("dt3"); ss3.Points.DataBind(dt3.AsEnumerable(), "xzhou2", "yzhou2", ""); ss3.XValueType = ChartValueType.DateTime; //设置X轴 ss3.ChartType = SeriesChartType.Spline; //设置Y轴为折线 chart1.Series.Add(ss3); }