ASP.NET(C#)版柱形立方统计图生成类VML方法之一

发布时间:2010年05月28日      浏览次数:397 次
HistoGram.cs类代码:
=======================================
using System;
using System.Collections.Generic;
using System.Web;
using System.Text;
namespace Dev.Utilities.PubCls
{
/// <summary>
/// 柱形立方统计图 V1.0.0
/// </summary>
/// <remarks>By Gavin Si 2005-5-27 3:01 AM</remarks>
public class HistoGram
{
#region 域
private string[,] _StatData = new string[0, 0];
private int _X = 0;
private int _Y = 0;
private int _RectangleThickness = 22;//30;
private int _RectangleWidth = 30;//40;
private int _Width = 450;//600;
private int _Height = 375;//500;
private HistogramType _DiagramType = HistogramType.PortraitSample;
private string[,] _RectangleColor = new string[0, 0];
private bool _EnableZoomIn = false;
private string _DiagramTitle = string.Empty;
private int _FontSize = 9;
private bool _EnableSelect = false;
private bool _EnableContextMenu = false;
private string _ParentControlName = string.Empty;
#endregion
#region 属性
#region 统计数据 public string[,] StatData
/// <summary>
/// 统计数据
/// </summary>
public string[,] StatData
{
set
{
for (int i = 0; i < value.GetUpperBound(0) + 1; i++)
{
if (!common.IsNumeric(value[i, 0]))
{
throw new Exception("输入的统计数据不正确!");
}
value[i, 0] = Convert.ToString(Math.Round(Double.Parse(value[i, 0]), 0));
}
this._StatData = value;
}
get
{
return this._StatData;
}
}
#endregion
#region 统计图位置横向坐标 public int X
/// <summary>
/// 统计图位置横向坐标
/// </summary>
/// <remarks>默认为:0</remarks>
public int X
{
set
{
this._X = value;
}
get
{
return this._X;
}
}
#endregion
#region 统计图纵向坐标 public int Y
/// <summary>
/// 统计图纵向坐标
/// </summary>
/// <remarks>默认为:0</remarks>
public int Y
{
set
{
this._Y = value;
}
get
{
return this._Y;
}
}
#endregion
#region 柱形的厚度 public int RectangleThickness
/// <summary>
/// 柱形的厚度
/// </summary>
/// <remarks>默认为:22</remarks>
public int RectangleThickness
{
set
{
this._RectangleThickness = value;
}
get
{
return this._RectangleThickness;
}
}
#endregion
#region 柱形的宽度 public int RectangleWidth
/// <summary>
/// 柱形的宽度
/// </summary>
/// <remarks>默认为:30</remarks>
public int RectangleWidth
{
set
{
this._RectangleWidth = value;
}
get
{
return this._RectangleWidth;
}
}
#endregion
#region 图表的宽 public int Width
/// <summary>
/// 图表的宽
/// </summary>
/// <remarks>默认为:450</remarks>
public int Width
{
set
{
this._Width = value;
}
get
{
return this._Width;
}
}
#endregion
#region 图表的高 public int Height
/// <summary>
/// 图表的高
/// </summary>
/// <remarks>默认为:375</remarks>
public int Height
{
set
{
this.Height = value;
}
get
{
return this._Height;
}
}
#endregion
#region 柱状图的方向 public HistogramType DiagramType
/// <summary>
/// 柱状图的方向
/// </summary>
/// <remarks>默认为横向柱状图</remarks>
public HistogramType DiagramType
{
set
{
this._DiagramType = value;
}
get
{
return this._DiagramType;
}
}
#endregion
#region 允许双击放大 public bool EnableZoomin
/// <summary>
/// 允许双击放大
/// </summary>
/// <remarks>默认为不允许放大</remarks>
public bool EnableZoomin
{
set
{
this._EnableZoomIn = value;
}
get
{
return this._EnableZoomIn;
}
}
#endregion
#region 统计图窗口标题 public string DiagramTitle
/// <summary>
/// 统计图窗口标题
/// </summary>
public string DiagramTitle
{
set
{
this._DiagramTitle = value;
}
get
{
return this._DiagramTitle;
}
}
#endregion
#region 字体大小 public int FontSize
/// <summary>
/// 字体大小
/// </summary>
/// <remarks>默认大小为9pt</remarks>
public int FontSize
{
set
{
this._FontSize = value;
}
get
{
return this._FontSize;
}
}
#endregion
#region 是否允许选择图表 public bool EnableSelect
/// <summary>
/// 是否允许选择图表
/// </summary>
/// <remarks>默认不允许选择</remarks>
public bool EnableSelect
{
set
{
this._EnableSelect = value;
}
get
{
return this._EnableSelect;
}
}
#endregion
#region 是否允许右键菜单 public bool EnableContextMenu
/// <summary>
/// 是否允许右键菜单
/// </summary>
/// <remarks>默认为否</remarks>
public bool EnableContextMenu
{
set
{
this._EnableContextMenu = value;
}
get
{
return this._EnableContextMenu;
}
}
#endregion
#region 上级容器控件ID public string ParentControlName
/// <summary>
/// 上级容器控件ID
/// </summary>
/// <example>
/// 例:
/// 在上级页面里添加如下代码
/// <table>
/// <tr>
/// <td width=10 height=10 id="Stat">
/// <iframe frameBorder=no marginHeight=0 marginWidth=0 src=HistoGram.aspx width=100% height=100%></iframe>
/// </td>
/// </tr>
/// </table>
/// <table>
///
/// 在统计图生成页面HistoGram.aspx则要设置这个属性为:
/// HistoGram a = new HistoGram();
/// string[,] Total = new string[8,2];
/// Total[0,0] = "105.888";
/// Total[0,1] = "A类";
/// Total[1,0] = "170";
/// Total[1,1] = "B类";
/// Total[2,0] = "300";
/// Total[2,1] = "C类";
/// Total[3,0] = "310";
/// Total[3,1] = "D类";
/// Total[4,0] = "500.88";
/// Total[4,1] = "E类";
/// Total[5,0] = "130";
/// Total[5,1] = "F类";
/// Total[6,0] = "200";
/// Total[6,1] = "G类";
/// Total[7,0] = "270";
/// Total[7,1] = "H类";
/// a.StatData = Total;
/// a.ParentControlName = "Stat"
/// a.DiagramType = HistoGram.HistogramType.LandscapeSample;
/// StringBuilder B = a.FlushDiagram();
/// Response.Write(B.ToString());
/// Response.End();
/// 这样做可以允许上级页面添加相应的说明文字,并使统计图的输出页面不出现滚动条
/// </example>
public string ParentControlName
{
set
{
this._ParentControlName = value;
}
get
{
return this._ParentControlName;
}
}
#endregion
#endregion
#region 类型定义
#region 柱状图形状 public static enum HistogramType
/// <summary>
/// 柱状图形状
/// </summary>
public enum HistogramType
{
/// <summary>
/// 横向图
/// </summary>
LandscapeSample,
/// <summary>
/// 纵向图
/// </summary>
PortraitSample
}
#endregion
免责声明:本站相关技术文章信息部分来自网络,目的主要是传播更多信息,如果您认为本站的某些信息侵犯了您的版权,请与我们联系,我们会即时妥善的处理,谢谢合作!