private void BindChartControl(DataTable dataTable,ChartControl chartControl,int[] columnNO,ViewType viewType) { chartControl.Series.Clear(); int num = columnNO.Length; List<Series> series=new List<Series>(); for (int i = 0; i < num; i++) { Series singleSeries = new Series(dataTable.Columns[columnNO[i]].Caption,viewType); series.Add(singleSeries); } foreach(DataRow dr in dataTable.Rows) { if (dr[0] != null) { for (int i = 0; i < columnNO.Length; i++) { SeriesPoint point = new SeriesPoint(dr[0].ToString()); point.Values = new double[] {Convert.ToDouble(dr[dataTable.Columns[columnNO[i]].Caption]) }; series[i].Points.Add(point); } } } chartControl.Series.AddRange(series.ToArray()); }
时间: 2024-11-05 08:13:56