标签:
//这是仿你的DataTable
//-----开始---------
DataTable dataTable1 = new System.Data.DataTable();
dataTable1.Columns.Add("网别", typeof(string));
dataTable1.Columns.Add("日期", typeof(DateTime));
dataTable1.Columns.Add("日发展", typeof(double));
DataTable dataTable2 = dataTable1.Clone();
DataTable dataTable3 = dataTable1.Clone();
dataTable1.Rows.Add("网别1", new DateTime(2014, 1, 1), 12.0);
dataTable1.Rows.Add("网别11", new DateTime(2014, 2, 1), 14.0);
dataTable2.Rows.Add("网别2", new DateTime(2014, 1, 1), 5.0);
dataTable2.Rows.Add("网别2", new DateTime(2014, 2, 1), 10.0);
dataTable3.Rows.Add("网别3", new DateTime(2014, 1, 1), 7.0);
dataTable3.Rows.Add("网别31", new DateTime(2014, 2, 1), 18.0);
//---------结束-------------
chart1.Series.Clear();//清空表中的数据
//第一个表中的数据
Series dataTable1Series = new Series("dataTable1");
dataTable1Series.Points.DataBind(dataTable1.AsEnumerable(), "日期", "日发展", "");
dataTable1Series.XValueType = ChartValueType.DateTime; //设置X轴类型为时间
dataTable1Series.ChartType = SeriesChartType.Line; //设置Y轴为折线
chart1.Series.Add(dataTable1Series);
//第二个表中的数据
Series dataTable2Series = new Series("dataTable2");
dataTable2Series.Points.DataBind(dataTable2.AsEnumerable(), "日期", "日发展", "");
dataTable2Series.XValueType = ChartValueType.DateTime;//设置X轴类型为时间
dataTable2Series.ChartType = SeriesChartType.Line; //设置Y轴为折线
chart1.Series.Add(dataTable2Series);
//第三个表中的数据
Series dataTable3Series = new Series("dataTable3");
dataTable3Series.Points.DataBind(dataTable3.AsEnumerable(), "日期", "日发展", "");
dataTable3Series.XValueType = ChartValueType.DateTime;//设置X轴类型为时间
dataTable3Series.ChartType = SeriesChartType.Line; //设置Y轴为折线
chart1.Series.Add(dataTable3Series);
标签:
原文地址:http://www.cnblogs.com/gosteps/p/5289910.html