using System;
using System.Collections;
using System.Data;
using BP.DA;
using BP.En;
using BP.Web;
using BP.Sys;
using BP.Difference;
namespace BP.Pub
{
///
/// 显示类型.
///
public enum DBAChartType
{
Table,
Column,
Pie,
Line
}
///
/// 柱状图显示类型
///
public enum ColumnChartShowType
{
///
/// 不显示
///
None,
///
/// 横向
///
HengXiang,
///
/// 竖向
///
ShuXiang,
///
/// 横向叠加
///
HengXiangAdd,
///
/// 竖向叠加
///
ShuXiangAdd
}
///
/// 折线图图显示类型
///
public enum LineChartShowType
{
///
/// 不显示
///
None,
///
/// 横向
///
HengXiang,
///
/// 竖向
///
ShuXiang
}
///
/// 数据报表
///
public class Rpt2Attr
{
///
/// 数据报表
///
public Rpt2Attr()
{
}
#region 基本属性.
///
/// 子标题
///
public string SubTitle = "SubTitle:子标题没有设置";
///
/// 统计纬度
///
public string TongJiWeiDu = "TongJiWeiDu:统计维度,属性没有设置.";
private string _Title = "";
///
/// 标题
///
public string Title
{
get
{
if (DataType.IsNullOrEmpty(_Title))
return "";
if (_Title.Contains("@") == false)
return _Title;
string title = _Title.Clone() as string;
title = title.Replace("@WebUser.No", BP.Web.WebUser.No);
title = title.Replace("@WebUser.Name", BP.Web.WebUser.Name);
title = title.Replace("@WebUser.FK_Dept", BP.Web.WebUser.DeptNo);
title = title.Replace("@WebUser.FK_DeptName", BP.Web.WebUser.DeptName);
if (title.Contains("@") == false)
return title;
//foreach (string key in Glo.Request.QueryString)
//{
// title = title.Replace("@" + key, Glo.Request.QueryString[key]);
//}
if (title.Contains("@") == false)
return title;
if (title.Contains("@") == false)
return title;
AtPara ap = new AtPara(this.DefaultParas);
foreach (string key in ap.HisHT.Keys)
title = title.Replace("@" + key, ap.GetValStrByKey(key));
return title;
}
set
{
_Title = value;
}
}
///
/// 左侧菜单标题
///
public string LeftMenuTitle = "";
///
/// 编码数据源
///
public string DBSrc = "";
///
/// 详细信息(可以为空)
///
public string DBSrcOfDtl = "";
///
/// 左边的菜单.
///
public string LeftMenu = "";
///
/// 高度.
///
public int H = 420;
///
/// 默认宽度
///
public int W = 900;
#endregion 基本属性.
///
/// 底部文字.
///
public string xAxisName = "";
///
/// 右边文字
///
public string yAxisName = "";
///
/// 数值列的前缀
///
public string numberPrefix = "";
///
/// 图标的横向的参照线的条数.
///
public int numDivLines = 8;
///
/// 默认显示的数据图表.
///
public DBAChartType DefaultShowChartType = DBAChartType.Column;
///
/// 是否启用table.
///
public bool ItIsEnableTable = true;
///
/// 柱图显示类型.
///
private ColumnChartShowType _ColumnChartShowType = ColumnChartShowType.ShuXiang;
public ColumnChartShowType ColumnChartShowType
{
get
{
return _ColumnChartShowType;
}
set
{
_ColumnChartShowType = value;
}
}
///
/// 是否显示饼图
///
public bool ItIsEnablePie = true;
///
/// 是否显示柱图
///
public bool ItIsEnableColumn = true;
///
/// 是否显示折线图
///
public bool ItIsEnableLine = true;
///
/// 折线图显示类型.
///
public LineChartShowType LineChartShowType = LineChartShowType.HengXiang;
///
/// 默认参数.
///
public string DefaultParas = "";
///
/// y最大值.
///
public double MaxValue = 0;
///
/// y最小值.
///
public double MinValue = 0;
///
/// 最底部的信息制表等信息.
///
public string ChartInfo = null;
///
/// 字段关系表达式
///
public string ColExp = "";
///
/// 说明
///
public string DESC = "";
//---------------------------------------------------------------
///
/// 设置图表背景的颜色
///
public string canvasBgColor = "FF8E46";
///
/// 设置图表基部的颜色
///
public string canvasBaseColor = "008E8E";
///
/// 设置图表基部的高度
///
public string canvasBaseDepth = "5";
///
/// 设置图表背景的深度
///
public string canvasBgDepth = "5";
///
/// 设置是否显示图表背景
///
public string showCanvasBg = "1";
///
/// 设置是否显示图表基部
///
public string showCanvasBase = "1";
//---------------------------------------------------------------
///
/// 数据源.
///
public DataTable _DBDataTable = null;
public DataTable DBDataTable
{
get
{
if (_DBDataTable == null)
{
//获得数据表.
// 执行SQL.
string sql = this.DBSrc;
sql = sql.Replace("@WebUser.FK_Dept", BP.Web.WebUser.DeptNo);
sql = sql.Replace("@WebUser.No", BP.Web.WebUser.No);
sql = sql.Replace("@WebUser.Name", BP.Web.WebUser.Name);
foreach (string k in HttpContextHelper.RequestParamKeys)
sql = sql.Replace("@" + k, HttpContextHelper.RequestParams(k));
if (sql.Contains("@") == true)
{
AtPara ap = new AtPara(this.DefaultParas);
foreach (string k in ap.HisHT.Keys)
{
sql = sql.Replace("@" + k, ap.HisHT[k].ToString());
}
}
_DBDataTable = DBAccess.RunSQLReturnTable(sql);
}
return _DBDataTable;
}
set
{
_DBDataTable = value;
}
}
///
/// 转化成Json
///
/// string
public string ToJson()
{
DataTable dt = this.DBDataTable;
//图示列数据.
string series_Data = "[";
foreach (DataRow dr in dt.Rows)
{
series_Data += ",'" + dr[1].ToString() + "'";
}
series_Data += "]";
series_Data = series_Data.Replace("[,", "[");
//行程数据源.
string dbData ="[";
foreach (DataRow dr in dt.Rows)
{
dbData += "{value:" + dr[2].ToString() + ",name:'" + dr[1] + "'},";
}
dbData = dbData.Substring(0, dbData.Length - 1);
dbData = dbData + "]";
//组合成要生成的json格式.
string str = "";
str += "{";
str += "title: {";
str += " text: '" + this.Title + "',";
str += " subtext: '" + this.SubTitle + "',";
str += " x: 'center'";
str += " },";
str += "tooltip: {";
str += " trigger: 'item',";
str += " formatter: \"{a}
{b} : {c} ({d}%)\"";
str += "},";
str += " legend: {";
str += " orient: 'vertical',";
str += " left: 'left',";
str += " data:" + series_Data + "";
str += " },";
str += " series: [";
str += " { ";
str += " name: '" + this.TongJiWeiDu + "',";
str += " type: 'pie',";
str += " radius: '55%',";
str += " center: ['50%', '60%'],";
str += " data: " + dbData + ",";
str += " itemStyle: {";
str += " emphasis: {";
str += " shadowBlur: 10,";
str += " shadowOffsetX: 0,";
str += " shadowColor: 'rgba(0, 0, 0, 0.5)'";
str += " }";
str += " }";
str += " }";
str += " ] ";
str += "}; ";
// DataType.WriteFile("c:\\111.txt", str);
return str;
}
}
public class Rpt2Attrs : System.Collections.CollectionBase
{
public void Add(Rpt2Attr en)
{
this.InnerList.Add(en);
}
public Rpt2Attr GetD2(int idx)
{
return (Rpt2Attr)this.InnerList[idx];
}
}
///
/// 报表基类
///
abstract public class Rpt2Base
{
#region 构造方法
///
/// 报表基类
///
public Rpt2Base()
{
}
#endregion 构造方法
#region 要求子类强制重写的属性.
///
/// 显示的标题.
///
abstract public string Title
{
get;
}
///
/// 默认选择的属性.
///
abstract public int AttrDefSelected
{
get;
}
///
/// 分组显示属性, 多个属性用@符号隔开.
///
abstract public Rpt2Attrs AttrsOfGroup
{
get;
}
#endregion 要求子类重写的属性.
#region 提供给操作者的方法.
#endregion 提供给操作者的方法
}
}