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

最近项目中需要用到统计图,上网查了查!还这发现有个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就不在此说了,不懂的话可以查一下!)

 

 



 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值