当前位置:首页 > 商业/管理/HR > 管理学资料 > C#NET使用DotNetCharting控件生成报表统计图总结
.NET使用DotNetCharting控件生成报表统计图总结在做项目时要对数据进行统计分析,所以必须生成一些报表统计图(如柱形图、饼图、曲线图等),网上强烈推荐了使用DotNetCharting控件来实现,于是自己对DotNetCharting控件进行了简单的学习,下面先简单介绍一下DotNetCharting控件及其使用。DotNetCharting是一个非常棒的.NET图表控件,对中文支持非常好,而且操作方便,开发快速,既有forwebform也有forwinform的,而且.net1.1和2.0都有支持。它的官方地址是本站也提供了DotNetCharting破解版本下载:附件:dotnetCHARTING.rar(下载36次)强烈推荐一下DotNetCharting的demo地址:这个是所有的DEMO演示这个是OnlineDocumentation里面会有详细的说明和用法。DotNetCharting的简单使用方法:1.把\bin\dotnetCHARTING.dll添加到工具箱,并且添加引用;2.把控件拖到你的网页上,然后添加引用usingdotnetCHARTING;就可以用了;3.接下来是自己写的对DotNetCharting操作的封装类,以便于在程序里调用。ShowData.cs1.usingSystem;2.usingSystem.Data;3.usingSystem.Text;4.usingdotnetCHARTING;5.6.namespaceFLX.ComplexQuery7.{8./**////summary9.///彭建军10.///根据数据动态生成图形(柱形图、饼图、曲线图)11.///2008-06-1912.////summary13.publicclassShowData14.{15.16.属性#region属性17.privatestring_phaysicalimagepath;//图片存放路径18.privatestring_title;//图片标题19.privatestring_xtitle;//图片x座标名称20.privatestring_ytitle;//图片y座标名称21.privatestring_seriesname;//图例名称22.privateint_picwidth;//图片宽度23.privateint_pichight;//图片高度24.privateDataTable_dt;//图片数据源25.26./**////summary27.///图片存放路径28.////summary29.publicstringPhaysicalImagePath30.{31.set{_phaysicalimagepath=value;}32.get{return_phaysicalimagepath;}33.}34./**////summary35.///图片标题36.////summary37.publicstringTitle38.{39.set{_title=value;}40.get{return_title;}41.}42./**////summary43.///图片标题44.////summary45.publicstringXTitle46.{47.set{_xtitle=value;}48.get{return_xtitle;}49.}50./**////summary51.///图片标题52.////summary53.publicstringYTitle54.{55.set{_ytitle=value;}56.get{return_ytitle;}57.}58.59./**////summary60.///图例名称61.////summary62.publicstringSeriesName63.{64.set{_seriesname=value;}65.get{return_seriesname;}66.}67./**////summary68.///图片宽度69.////summary70.publicintPicWidth71.{72.set{_picwidth=value;}73.get{return_picwidth;}74.}75./**////summary76.///图片高度77.////summary78.publicintPicHight79.{80.set{_pichight=value;}81.get{return_pichight;}82.}83./**////summary84.///图片数据源85.////summary86.publicDataTableDataSource87.{88.set{_dt=value;}89.get{return_dt;}90.}91.#endregion92.93.构造函数#region构造函数94.publicShowData()95.{96.//97.//TODO:在此处添加构造函数逻辑98.//99.}100.101.publicShowData(stringPhaysicalImagePath,stringTitle,stringXTitle,stringYTitle,stringSeriesName)102.{103._phaysicalimagepath=PhaysicalImagePath;104._title=Title;105._xtitle=XTitle;106._ytitle=YTitle;107._seriesname=SeriesName;108.}109.#endregion110.111.输出柱形图#region输出柱形图112./**////summary113.///柱形图114.////summary115.///returns/returns116.publicvoidCreateColumn(dotnetCHARTING.Chartchart)117.{118.chart.Title=this._title;119.chart.XAxis.Label.Text=this._xtitle;120.chart.YAxis.Label.Text=this._ytitle;121.chart.TempDirectory=this._phaysicalimagepath;122.chart.Width=this._picwidth;123.chart.Height=this._pichight;124.chart.Type=ChartType.Combo;125.chart.Series.Type=SeriesType.Cylinder;126.chart.Series.Name=this._seriesname;127.chart.Series.Data=this._dt;128.chart.SeriesCollection.Add();129.chart.DefaultSeries.DefaultElement.ShowValue=true;130.chart.ShadingEffect=true;131.chart.Use3D=false;132.chart.Series.DefaultElement.ShowValue=true;133.}134.#endregion135.136.输出饼图#region输出饼图137./**////summary138.///饼图139.////summary140.///returns/returns141.publicvoidCreatePie(dotnetCHARTING.Chartchart)142.{143.chart.Title=this._title;144.chart.TempDirectory=this._phaysicalimagepath;145.chart.Width=this._picwidth;146.chart.Height=this._pichight;147.chart.Type=ChartType.Pie;148.chart.Series.Type=SeriesType.Cylinder;149.chart.Series.Name=this._seriesname;150.151.chart.ShadingEffect=true;152.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.privateSeriesCollectiongetArrayData()161.{162.SeriesCollectionSC=newSeriesCollection();163.DataTabledt=this._dt;164.165.for(inti=0;idt.Rows.Count;i++)166.{167.Seriess=newSeries();168.s.Name=dt.Rows[0].ToString();169.170.Elemente=newElement();171.172.//每元素的名称173.e.Name=dt.Rows[0].ToString();174.175.//每元素的大小数值176.e.YValue=Convert.ToInt32(dt.Rows[1].ToString());177.178.s.Elements.Add(e);179.SC.Add(s);180.}181.returnSC;182.}183.#endregion184.185.输出曲线图#region输出曲线图186./**////summary187.///曲线图188.////summary189.///returns/returns190.publicvoidCreateLine(dotnetCHARTING.Chartchart)191.{192.chart.Title=this._title;193.chart.XAxis.Label.Text=this._xtitle;194.chart.YAxis.Label.Text=this._ytitle;195.chart.TempDirectory=this._phaysicalimagepath;196.chart.Width=this._picwidth;197.chart.Height=this._pichight;198.chart.Type=ChartType.Combo;199.chart.Series.Type=SeriesType.Line;200.chart.Series.Name=this._seriesname;201.chart.Series.Data=this._dt;202.chart.SeriesCollection.Add();203.chart.DefaultSeries.DefaultElement.ShowValu
本文标题:C#NET使用DotNetCharting控件生成报表统计图总结
链接地址:https://www.777doc.com/doc-1059920 .html