C#NET使用DotNetCharting控件生成报表统计图总结_c

2020-02-27 其他工作总结 下载本文

C#NET使用DotNetCharting控件生成报表统计图总结由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“c”。

.NET使用DotNetCharting控件生成报表统计图总结

在做项目时要对数据进行统计分析,所以必须生成一些报表统计图(如柱形图、饼图、曲线图等),网上强烈推荐了使用DotNetCharting控件来实现,于是自己对DotNetCharting控件进行了简单的学习,下面先简单介绍一下DotNetCharting控件及其使用。

DotNetCharting是一个非常棒的.NET图表控件,对中文支持非常好,而且操作方便,开发快速,既有for webform 也有for winform的,而且.net1.1和2.0都有支持。它的官方地址是http://..dotnetcharting../

本站也提供了DotNetCharting破解版本下载: 附件: dotnetCHARTING.rar(下载 36 次)

强烈推荐一下DotNetCharting的demo地址:

这个是所有的 DEMO 演示

http://..dotnetcharting../demo.aspx

这个是 Online Documentation http://..dotnetcharting../documentation/v4_4/webframe.html 里面会有详细的说明和用法。

DotNetCharting的简单使用方法:

1.把bindotnetCHARTING.dll添加到工具箱,并且添加引用;

2.把控件拖到你的网页上,然后添加引用using dotnetCHARTING;就可以用了;

3.接下来是自己写的对DotNetCharting操作的封装类,以便于在程序里调用。

ShowData.cs 1.using System;2.using System.Data;3.using System.Text;4.using dotnetCHARTING;5.6.namespace FLX..plexQuery 7.{ 8./**////

9./// 彭建军

10./// 根据数据动态生成图形(柱形图、饼图、曲线图)11./// 2008-06-19 12./// 13.public cla ShowData 14.{ 15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.属性#region 属性

图片存放路径图片标题 图片x座标名称 图片y座标名称 图例名称 图片宽度 图片高度 图片数据源 图片存放路径

set{_phaysicalimagepath=value;} get{return _phaysicalimagepath;} 图片标题

set{_title=value;} get{return _title;} private string _phaysicalimagepath;// private string _title;// private string _xtitle;// private string _ytitle;// private string _seriesname;// private int _picwidth;// private int _pichight;// private DataTable _dt;// /**//// /// /// public string PhaysicalImagePath {

} /**//// /// /// public string Title { 41.} 42./**//// 43./// 图片标题 44./// 45.public string XTitle 46.{ 47.set{_xtitle=value;} 48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.get{return _xtitle;} 图片标题

set{_ytitle=value;} get{return _ytitle;} 图例名称

set{_seriesname=value;} get{return _seriesname;} 图片宽度

set{_picwidth=value;} get{return _picwidth;} } /**//// /// /// public string YTitle {

} /**//// /// /// public string SeriesName {

} /**//// /// /// public int PicWidth {

} 75./**//// 76./// 图片高度 77./// 78.public int PicHight 79.{ 80.set{_pichight=value;} 81.get{return _pichight;} 82.} 83./**//// 84./// 图片数据源 85./// 86.public DataTable DataSource 87.{ 88.set{_dt=value;} 89.get{return _dt;} 90.} 91.#endregion 92.93.构造函数#region 构造函数 94.public ShowData()95.{ 96.// 97.// TODO: 在此处添加构造函数逻辑 98.// 99.} 100.101.public ShowData(string PhaysicalImagePath,string Title,string XTitle,string YTitle,string SeriesName)102.103.104.105.106.{

_phaysicalimagepath=PhaysicalImagePath;

_title=Title;

_xtitle=XTitle;

_ytitle=YTitle;107.108.109.110.111.112.113.114.115._seriesname=SeriesName;

}

#endregion

输出柱形图#region 输出柱形图

/**////

/// 柱形图

///

/// 116.public void CreateColumn(dotnetCHARTING.Chart chart)117.118.119.120.{

chart.Title=this._title;

chart.XAxis.Label.Text=this._xtitle;

chart.YAxis.Label.Text=this._ytitle;121.chart.TempDirectory =this._phaysicalimagepath;

122.123.chart.Width = this._picwidth;

chart.Height = this._pichight;124.chart.Type = ChartType..bo;

125.chart.Series.Type =SeriesType.Cylinder;126.chart.Series.Name = this._seriesname;

127.128.chart.Series.Data = this._dt;

chart.SeriesCollection.Add();

129.chart.DefaultSeries.DefaultElement.ShowValue = true;

130.131.chart.ShadingEffect = true;

chart.Use3D = false;

132.chart.Series.DefaultElement.ShowValue =true;133.134.135.}

#endregion 136.137.138.139.140.输出饼图#region 输出饼图

/**////

/// 饼图

///

/// 141.public void CreatePie(dotnetCHARTING.Chart chart)142.143.{

chart.Title=this._title;

144.chart.TempDirectory =this._phaysicalimagepath;

145.146.chart.Width = this._picwidth;

chart.Height = this._pichight;147.chart.Type = ChartType.Pie;

148.chart.Series.Type =SeriesType.Cylinder;149.chart.Series.Name = this._seriesname;

150.151.152.chart.ShadingEffect = true;

chart.Use3D = false;

153.chart.DefaultSeries.DefaultElement.Transparency = 20;154.chart.DefaultSeries.DefaultElement.ShowValue = true;155.chart.PieLabelMode = PieLabelMode.Outside;

156.chart.SeriesCollection.Add(getArrayData());157.chart.Series.DefaultElement.ShowValue = true;158.159.160.161.}

private SeriesCollection getArrayData()

{ 162.SeriesCollection SC = new SeriesCollection();163.164.165.166.167.DataTable dt = this._dt;

for(int i=0;i

{

Series s = new Series();168.s.Name = dt.Rows[0].ToString();

169.170.171.172.173.174.175.Element e = new Element();

// 每元素的名称

e.Name = dt.Rows[0].ToString();

// 每元素的大小数值

176.e.YValue=Convert.ToInt32(dt.Rows[1].ToString());177.178.179.180.181.182.183.184.185.186.187.188.189.s.Elements.Add(e);

SC.Add(s);

}

return SC;

}

#endregion

输出曲线图#region 输出曲线图

/**////

/// 曲线图

///

/// 190.public void CreateLine(dotnetCHARTING.Chart chart)191.192.{

chart.Title=this._title;

193.194.chart.XAxis.Label.Text=this._xtitle;

chart.YAxis.Label.Text=this._ytitle;195.chart.TempDirectory =this._phaysicalimagepath;

196.197.chart.Width = this._picwidth;

chart.Height = this._pichight;198.chart.Type = ChartType..bo;

199.chart.Series.Type =SeriesType.Line;200.chart.Series.Name = this._seriesname;

201.202.chart.Series.Data = this._dt;

chart.SeriesCollection.Add();

203.chart.DefaultSeries.DefaultElement.ShowValue = true;

204.205.chart.ShadingEffect = true;

chart.Use3D = false;

206.chart.Series.DefaultElement.ShowValue =true;207.208.209.210.}

#endregion

调用说明及范例#region 调用说明及范例

211.//

在要显示统计图的页面代码直接调用,方法类似如下: 212.213.214.215.216.217.218.219.220.221.// //

ShowData show=new ShowData();//

show.Title =“2008年各月消费情况统计”;//

show.XTitle =“月份”;//

show.YTitle =“金额(万元)”;//

show.PicHight =300;//

show.PicWidth =600;//

show.SeriesName =“具体详情”;//

show.PhaysicalImagePath =“ChartImages”;//

show.DataSource =this.GetDataSource();222.223.224.225.226.//

show.CreateColumn(this.Chart1);

#endregion

} } 复制代码 效果图展示:

1、饼图

2、柱形图

3、曲线图

补充:

帖子发了一天,没人回答我多维统计图的实现方式,只好自己去dotnetcharting的官方网站下载了最新的dotnetcharting控件,在 dotnetcharting控件的使用说明文档中详细地介绍了各种多维统计图的实现方式。现把说明文档贴出来供大家下载

dotnetcharting使用说明文档:附件: dotnetcharting使用说明.rar(下载 38 次)

追加补充新内容:

1、解决“每运行一次DotNetCharting页面,就会生成一个图片,这样图片不是越来越多吗?请问怎样自动删除DotNetCharting生成的图片呢”的问题,参照 ASP.NET删除文件夹里的所有文件。

2、解决“(1)生成的图片带超链接导向官网,如何处理呀?(2)我使用这个控件后,图形可以显示出来。但是发现一个小问题。就是在图形的左上方和图形的下面都隐含了超链接,鼠标移动到这两个区域后,点击都会链接到http://..dotnetcharting../。很奇怪,这是和破解有管吗?”等类似的问题,参照 DotnetCharting控件的破解方法。

《C#NET使用DotNetCharting控件生成报表统计图总结.docx》
将本文的Word文档下载,方便收藏和打印
推荐度:
C#NET使用DotNetCharting控件生成报表统计图总结
点击下载文档
相关专题 c 控件 报表 统计图 c 控件 报表 统计图
[其他工作总结]相关推荐
    [其他工作总结]热门文章
      下载全文