您的位置:首页 > 其它

net使用DotNetCharting控件生成报表统计图

2013-02-02 21:22 483 查看
最近项目中需要用到统计图,上网查了查!还这发现有个DotNetCharting控件挺好用的!在这里和大家分享一下!以及具体的使用方法(先看看效果):




DotNetCharting破解版本下载: http://files.cnblogs.com/dreamof/dotnetcharting.rar
DotNetCharting的简单使用方法:

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

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

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

using System;

using System.Collections.Generic;

using System.Text;

using System.Data ;

using dotnetCHARTING;

namespace XXXX

{

public class Charting

{

///<summary>

/// 图片存放路径

///</summary>

public string PhaysicalImagePath

{

set { _phaysicalimagepath = value; }

get { return _phaysicalimagepath; }

}

///<summary>

/// 图片标题

///</summary>

public string Title

{

set { _title = value; }

get { return _title; }

}

///<summary>

/// 图片x座标名称

///</summary>

public string XTitle

{

set { _xtitle = value; }

get { return _xtitle; }

}

///<summary>

/// 图片y座标名称

///</summary>

public string YTitle

{

set { _ytitle = value; }

get { return _ytitle; }

}

///<summary>

/// 图例名称

///</summary>

public string SeriesName

{

set { _seriesname = value; }

get { return _seriesname; }

}

///<summary>

/// 图片宽度

///</summary>

public int PicWidth

{

set { _picwidth = value; }

get { return _picwidth; }

}

///<summary>

/// 图片高度

///</summary>

public int PicHight

{

set { _pichight = value; }

get { return _pichight; }

}

///<summary>

/// 统计图类型(柱形,线形等)

///</summary>

public SeriesType Type

{

set { _type = value; }

get { return _type; }

}

///<summary>

/// 是否将输出的图片显示成三维

///</summary>

public bool Use3D

{

set { _use3d = value; }

get { return _use3d; }

}

///<summary>

/// 对比图形数据源

///</summary>

public DataTable DataSource

{

set { _dt = value; }

get { return _dt; }

}

///<summary>

/// 生成统计图片的名称

///</summary>

public string FileName

{

set { _filename = value; }

get { return _filename; }

}

/// <summary>

/// 生成单一统计图片

///</summary>

///<param name="chart"></param>

///<param name="type">图形类别,如柱状,折线型</param>

public void CreatePie(dotnetCHARTING.Chart chart)

{

chart.Title = this.Title;

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

chart.YAxis.Label.Text = this.YTitle;

chart.TempDirectory = this.PhaysicalImagePath;

chart.FileManager.FileName = this.FileName;

chart.Width = this.PicWidth;

chart.Height = this.PicHight;

chart.Type = ChartType.Combo;

chart.Series.Type = this.Type;

chart.Series.Name = this.SeriesName;

chart.Series.Data = this.DataSource;

chart.SeriesCollection.Add();

chart.DefaultSeries.DefaultElement.ShowValue = true;

chart.ShadingEffect = true;

chart.Use3D = this.Use3D;

chart.Series.DefaultElement.ShowValue = true;

}

}

}

类写好后!在需要的页面中调用并配置其参数,主要是数据源 ,根据需求整合好datatable!就行了!

注意事项:

1.在需要生成的统计图片中,如果想得到多个实例,像饼图中的多个颜色表示的图例一样!那么就需要根据情况,来多次调用!Charting中的CreatePie();

2.在生成统计的图片后,右上角和下角,都有官方的链接网址,非常的不好!这里提供一个简单的解决方案:在这个页面中的控件上面加一个“透明的DIV”

层,来遮挡住;(透明div就不在此说了,不懂的话可以查一下!)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: