我需要最简单的现实一个统计表效果,谢谢分享。

解决方案 »

  1.   


    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;using System.Data.SqlClient;
    using Dundas.Charting.WebControl;
    using System.Drawing;
    using System.Text;
    using System.Data.OleDb;
    using dotnetCHARTING;namespace CheckSys.Web.Query
    {
        public partial class ChartZZT : System.Web.UI.Page
        {
            DataSet dataS = new DataSet();        public string commandText = "";
            public string str = "";
            protected void Page_Load(object sender, System.EventArgs e)
            {
                if (!IsPostBack)
                {
                    str = @"select shi,count(shi) as num from sdzjbxx group by shi ";
                    DataTable dt = CheckSys.DAO.NHibernate.SqlHelper.ExecuteDataset(CheckSys.DAO.NHibernate.SqlHelper.ConnectionString, CommandType.Text, str).Tables[0];
                    //ShowChart();
                    ShowData show = new ShowData();
                    show.Title = "广东省各市电站统计";
                    show.XTitle = "地区";
                    show.YTitle = "电站个数(宗)";
                    show.PicHight = 400;
                    show.PicWidth = 700;
                    show.SeriesName = "电站统计";
                    show.PhaysicalImagePath = "../ChartImg";
                    show.DataSource = dt;
                    show.CreateColumn(this.Chart1);
                }
            }        /// <summary>    
            /// 朱龙
            /// 根据数据动态生成图形(柱形图、饼图、曲线图)
            /// 2008-06-19
            /// </summary>
            public class ShowData
            {            #region 属性
                private string _phaysicalimagepath;//图片存放路径
                private string _title; //图片标题
                private string _xtitle;//图片x座标名称
                private string _ytitle;//图片y座标名称
                private string _seriesname;//图例名称
                private int _picwidth;//图片宽度
                private int _pichight;//图片高度
                private DataTable _dt;//图片数据源            /**/
                /// <summary>
                /// 图片存放路径
                /// </summary>
                public string PhaysicalImagePath
                {
                    set { _phaysicalimagepath = value; }
                    get { return _phaysicalimagepath; }
                }
                /**/
                /// <summary>
                /// 图片标题
                /// </summary>
                public string Title
                {
                    set { _title = value; }
                    get { return _title; }
                }
                /**/
                /// <summary>
                /// 图片标题
                /// </summary>
                public string XTitle
                {
                    set { _xtitle = value; }
                    get { return _xtitle; }
                }
                /**/
                /// <summary>
                /// 图片标题
                /// </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 DataTable DataSource
                {
                    set { _dt = value; }
                    get { return _dt; }
                }
                #endregion            #region 构造函数
                public ShowData()
                {
                    //
                    // TODO: 在此处添加构造函数逻辑
                    //
                }            public ShowData(string PhaysicalImagePath, string Title, string XTitle, string YTitle, string SeriesName)
                {
                    _phaysicalimagepath = PhaysicalImagePath;
                    _title = Title;
                    _xtitle = XTitle;
                    _ytitle = YTitle;
                    _seriesname = SeriesName;
                }
                #endregion            #region 输出柱形图
                /**/
                /// <summary>
                /// 柱形图
                /// </summary>
                /// <returns></returns>
                public void CreateColumn(dotnetCHARTING.Chart chart)
                {
                    chart.Title = this._title;
                    chart.XAxis.Label.Text = this._xtitle;
                    chart.YAxis.Label.Text = this._ytitle;
                    chart.TempDirectory = this._phaysicalimagepath;
                    chart.Width = this._picwidth;
                    chart.Height = this._pichight;
                    chart.Type = ChartType.Combo;
                    chart.Series.Type = SeriesType.Cylinder;
                    chart.Series.Name = this._seriesname;
                    chart.Series.Data = this._dt;
                    chart.SeriesCollection.Add();
                    chart.DefaultSeries.DefaultElement.ShowValue = true;
                    chart.ShadingEffect = true;
                    chart.Use3D = true;
                    //chart.TitleBox.Position = TitleBoxPosition.FullWithLegend;
                    //chart.TitleBox.Position = TitleBoxPosition.FullWithLegend;
                                    chart.SeriesCollection[0].DefaultElement.Color = Color.Blue;
                    chart.SeriesCollection[0].DefaultElement.Color = Color.FromArgb(49, 255, 49);                chart.Series.DefaultElement.ShowValue = true;
                }            #endregion            #region 调用说明及范例
                //        在要显示统计图的页面代码直接调用,方法类似如下:
                //
                //        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();
                //        show.CreateColumn(this.Chart1);    
                #endregion        }
        }
       
    }
      

  2.   

    <%@ Register assembly="dotnetCHARTING" namespace="dotnetCHARTING" tagprefix="dotnetCHARTING" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>广东省各市电站统计</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
             <dotnetCHARTING:Chart ID="Chart1" runat="server">
       </dotnetCHARTING:Chart>    </div>
        </form>
    </body>
    </html>
      

  3.   

    http://www.carlosag.net/Tools/WebChart/sampleCode.aspx