dev简单实现柱状图,曲线图
1、数据源代码:
DataTable dt = new DataTable(); dt.Columns.Add("A"); dt.Columns.Add("B", typeof(Int32)); for (int i = 0; i < 10; i++) { if (i % 2 == 0) { dt.Rows.Add("测试数据00" + i, 20 * i); } else { dt.Rows.Add("测试数据00" + i, 5 * i); } }
2、图表主要代码:
//根据选择显示不同的Char private void ShowChar(int index) { Series ss = null; switch (index) { case 0: ss = new Series("数值", ViewType.Bar); break; case 1: ss = new Series("数值", ViewType.Spline); break; } if (ss != null) { this.chartControl1.Series.Clear(); ss.DataSource = dt; ss.ArgumentDataMember = "A"; ss.ValueDataMembers[0] = "B"; this.chartControl1.Series.Add(ss); } }
3、效果图
4、源代码下载地址(无积分):http://download.csdn.net/detail/kehaigang29/9073883