1.什么是MSChart
Chart: Microsoft Chart Controls for Microsoft .NET Framework 3.5
- 适用于.NET Framework 3.5 SP1 的ASP.NET和Windows Form图标控制项
- 开发商: 2007年Dundas 开发出收費的Chart控件 2008/9/8微软发布免費的MSChart控件
- Support Service: system :win2003 sp2 ,win2008,windows vista,winxp sp3 .net Framework: .NET Framework 3.5 SP1(VS2008)
- 处理器:400 MHz Pentium(最低);1GHz Pentium(建议) RAM:96 MB(最小)256MB(建议) Hard: 500MB可用磁盘空间
- 显卡: 800*600、256色(小) 1024*768、256色
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
(2)MSChart_VisualStudioAddOn.exe
(3)MSChartLP_chs.exe
(4)MSChart.exe
打开VS2008在工具中新增了Data Chart控件:
![](https://i-blog.csdnimg.cn/blog_migrate/63b1c8d06445044fadc3947b0a8c9689.png)
MSChart 图表类型
1.Bar and Column Charts 3D or 2D Bar or Column Charts like this page:
•
![](https://i-blog.csdnimg.cn/blog_migrate/e7c0fea421e3038525b3f758f6a89587.png)
![](https://i-blog.csdnimg.cn/blog_migrate/847d557bcb2e7d098cbd43b9d1d64311.png)
![](https://i-blog.csdnimg.cn/blog_migrate/68174a797976639a0e05b10cebf78ba0.png)
Stacked charts Bar and Column 3D Bar and Column
2.Line Charts
![](https://i-blog.csdnimg.cn/blog_migrate/36eced3622015a95f7b5422e7ca72900.png)
3. Range Charts
![](https://i-blog.csdnimg.cn/blog_migrate/7f4c715d46e2d05f78c22e9bfc489a5a.png)
4. Circular charts
![](https://i-blog.csdnimg.cn/blog_migrate/cc3a33671cec4ac2cca8186022c8073c.png)
5. Accumulation charts
![](https://i-blog.csdnimg.cn/blog_migrate/650f60ee77344a687d5723a44b2e39d4.png)
6. Area Chart
![](https://i-blog.csdnimg.cn/blog_migrate/0f21f0802f24ac840a5bcc5cc583be3a.png)
7. Pie and Doughnut charts
![](https://i-blog.csdnimg.cn/blog_migrate/4d768bcf0ac4b889a67817a17f46dbcf.png)
![](https://i-blog.csdnimg.cn/blog_migrate/56336d7e370af4e883e114ab2c1083fc.png)
9. Advanced Financial charts
![](https://i-blog.csdnimg.cn/blog_migrate/58a69c4e39e7e2a8432ad9a160a7b17d.png)
10. Combinational Charts
![](https://i-blog.csdnimg.cn/blog_migrate/9078ce408cc0368481213f0615ea7923.png)
3.MSChart 属性介绍
![](https://i-blog.csdnimg.cn/blog_migrate/369f7b069e85fce2fe28a485ae40da45.png)
这些属性在添加chart的时候会有。
开启VS2008 •新建网站ChartTest 打开工具列:
![](https://i-blog.csdnimg.cn/blog_migrate/c832f4a6f255a4f2eaaed66fa513da53.png)
点击Chart在页面中添加Chart图形,在属性栏中选择 Chart类型
![](https://i-blog.csdnimg.cn/blog_migrate/253f0ef3b3492403dea788002c7cf616.png)
4.MSChart inVS2008 实现
•查询数据结果对应到Chart的XY轴
![](https://i-blog.csdnimg.cn/blog_migrate/cdec0645add3fc3c328197dda5c76203.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/81178cc93a2a3bb5048d90d76e7ec935.gif)
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轴
![](https://i-blog.csdnimg.cn/blog_migrate/cdec0645add3fc3c328197dda5c76203.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/81178cc93a2a3bb5048d90d76e7ec935.gif)
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);
有错误的地方欢迎大家拍砖,希望交流和共享。