作者:MR_ke 来源:博客园 发布时间:2010-02-25 15:22 阅读:2081 次 原文链接 [收藏]
1.什么是MSChart
Chart: Microsoft Chart Controls for Microsoft .NET Framework 3.5
2.MSchart安装
•安装完成VS2008(.NET Framework 3.5 SP1)下载地址
•
1) dotnetfx35setup.exe
2) MSChart.exe
3) MSChart_VisualStudioAddOn.exe
4) MSChartLP_chs.exe
安装顺序:
(1)dotnetfx35setup.exe
(2)MSChart_VisualStudioAddOn.exe
(3)MSChartLP_chs.exe
(4)MSChart.exe
打开VS2008在工具中新增了Data Chart控件:
MSChart 图表类型
1.Bar and Column Charts 3D or 2D Bar or Column Charts like this page:
•
Stacked charts Bar and Column 3D Bar and Column
2.Line Charts
3. Range Charts
4. Circular charts
5. Accumulation charts
6. Area Chart
7. Pie and Doughnut charts
8. Point charts
9. Advanced Financial charts
10. Combinational Charts
3.MSChart 属性介绍
这些属性在添加chart的时候会有。
开启VS2008 •新建网站ChartTest 打开工具列:
点击Chart在页面中添加Chart图形,在属性栏中选择 Chart类型
4.MSChart inVS2008 实现
查询数据结果对应到Chart的XY轴
1 1) string strSql = "SELECT Top 5 empid, COUNT(*) AS lNum FROM log where empid <> '' GROUP BY empid ORDER BY empid";
2 DataSet ds = SqlHelper.ExecuteDataset(strConnISPD, CommandType.Text, strSql);
3 DataView dv = new DataView(ds.Tables[0]);
4 Chart1.Series["login"].Points.DataBindXY(dv, "empid", dv, "lNum");
5 2) SqlCommand cd = new SqlCommand(strSql, conn);
6 SqlDataAdapter da = new SqlDataAdapter();
7 da.SelectCommand = cd;
8 DataSet ds = new DataSet();
9 da.Fill(ds, "log");
10 DataView dv = new DataView(ds.Tables[0]);
11 dv.Sort="empid";
12 Chart1.Series["login"].Points.DataBindXY(dv, "empid", dv, "lNum");
使用现有数组数据到Chart的XY轴
1 double[] yValues = {12, 67, 45, double.NaN, 67, 89, 35, 12, 78, 54};
2 double[] xValues = {1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999};
3 Chart1.Series["Series1"].Points.DataBindXY(xValues, yValues);