VbScript 封裝MS OWC(二)

代码如下:

''OWC1.VBS
class owc
private o
'傳入物件
public sub create(id_,width_,height_,location_)
Set o = document.createElement("object")
o.setAttribute "id",id_
o.setAttribute "classid","CLSID:0002E55D-0000-0000-C000-000000000046"
o.setAttribute codebase="owc11.dll"
o.style.width=width_
o.style.height=height_
document.getElementById(location_).appendChild(o)
end sub
'畫圖矩形圖
'chart_bgcolor_圖表的背景顏色
'chartCaption_圖表的標題
'chartCaption_fontColor_圖表標題顏色
'Interior_Color_矩形內的填充顏色
'Caption_名稱
'categories_名稱數組
'values_值數組串
public sub bar(chart_bgcolor_,chartCaption_,chartCaption_fontColor_,Interior_Color_,Caption_,categories_,values_)
o.Clear
set cht = o.Charts.Add
set c = o.Constants
cht.Type = c.chChartTypeColumnClustered
'設背景色或是填充
o.Charts(0).PlotArea.Interior.SetSolid chart_bgcolor_

'加上圖表的標題
o.HasChartSpaceTitle = True
set cst=o.ChartSpaceTitle
cst.Caption = chartCaption_
cst.Font.Color = chartCaption_fontColor_
cst.Font.Italic = False
cst.Font.Name = "Arial"
cst.Font.Size = 12
cst.Font.Underline = c.owcUnderlineStyleSingle

'添加數據
cht.SetData c.chDimCategories, c.chDataLiteral, categories_
cht.SeriesCollection(0).SetData c.chDimValues, c.chDataLiteral, values_
'直條的背景色進行設定
set sc=o.Charts(0).SeriesCollection(0)
sc.Interior.Color=Interior_Color_

'直條上的顯示設置
sc.Caption=Caption_
set dl = cht.SeriesCollection(0).DataLabelsCollection.Add
dl.HasValue = True
dl.HasPercentage = False
dl.Font.Size = 9
dl.Font.Color = "red"
dl.Position = c.chLegendPositionRight
dl.NumberFormat = "00.00%"
'左邊百分比的屬性設置
Set cta = cht.Axes(c.chAxisPositionLeft)
cta.Font.Size = 9
cta.NumberFormat = "0.0%"
cta.MajorUnit = 0.1
end sub
'多系列矩形圖
'chart_bgColor_圖表的背景顏色
'chartCaption_圖表的標題
'chartCaption_fontColor_圖表標題顏色
'color_顏色數組
'caption_名稱數組
'categories_名稱數組
'values_值數組
public sub serBar(chart_bgColor_,chartCaption_,chartCaption_fontColor_,color_,caption_,categories_,values_)
o.Clear
o.Charts.Add
Set c = o.Constants
'圖表的類型
o.Charts(0).type=c.chChartTypeColumnClustered
'給繪圖區加背景色
o.Charts(0).PlotArea.Interior.SetSolid chart_bgColor_
''加上圖表的標題
o.HasChartSpaceTitle = True
o.ChartSpaceTitle.Caption = chartCaption_
'標題的屬性
o.ChartSpaceTitle.Font.Color = chartCaption_fontColor_
o.ChartSpaceTitle.Font.Italic = False
o.ChartSpaceTitle.Font.Name = "Arial"
o.ChartSpaceTitle.Font.Size = 12
o.ChartSpaceTitle.Font.Underline = c.owcUnderlineStyleSingle
'用循環來新增SeriesCollection以及里面的內容
for i=0 to ubound(caption_)
valuetemp=""
for j = i*(ubound(categories_)+1) to (i+1)*(ubound(categories_)+1)-1
valuetemp = valuetemp & "," & values_(j)
next
valuearr = split(mid(valuetemp,2),",")
o.Charts(0).SeriesCollection.Add
o.Charts(0).SeriesCollection(i).Caption = caption_(i)
o.Charts(0).SeriesCollection(i).Interior.Color = color_(i)
o.Charts(0).SeriesCollection(i).SetData c.chDimCategories, c.chDataLiteral, categories_
o.Charts(0).SeriesCollection(i).SetData c.chDimValues, c.chDataLiteral, valuearr
set dl = o.Charts(0).SeriesCollection(i).DataLabelsCollection.Add
dl.HasValue = True
dl.HasPercentage = False
dl.Font.Size = 9
dl.Font.Color = "red"
dl.Position = c.chLegendPositionRight
dl.NumberFormat = "00.00%"
next
''圖例的設定
o.Charts(0).HasLegend = True
o.Charts(0).Legend.Font.Size = 9
o.Charts(0).Legend.Position = c.chLegendPositionBottom
''左邊百分比的屬性設置
Set cta = o.Charts(0).Axes(c.chAxisPositionLeft)
cta.Font.Size = 9
cta.NumberFormat = "0.00%"
cta.MajorUnit = 0.1
end sub
'畫圓餅圖
'chart_bgColor_繪圖區加背景色
'chartCaption_圖表的標題
'chartCaption_fontColor_圖表標題顏色
public sub Pie(chart_bgColor_,chartCaption_,chartCaption_fontColor_,Caption_,categories_,values_)
o.Clear
Set cht = o.Charts.Add
Set c = o.Constants
cht.Type = c.chChartTypePie3d
'給繪圖區加背景色
o.Charts(0).PlotArea.Interior.SetSolid chart_bgColor_
cht.ExtrudeAngle = 90
cht.ChartDepth = 169
cht.AspectRatio = 120
cht.Rotation =180
cht.Inclination=70

o.HasChartSpaceTitle = True
o.ChartSpaceTitle.Caption = chartCaption_
o.ChartSpaceTitle.Font.Color = chartCaption_fontColor_
o.ChartSpaceTitle.Font.Name = "Arial"
o.ChartSpaceTitle.Font.Size = 12
o.ChartSpaceTitle.Font.Underline = c.owcUnderlineStyleSingle

cht.HasLegend = True
cht.Legend.Font.Size = 9
cht.Legend.Position = c.chLegendPositionBottom

cht.SetData c.chDimCategories, c.chDataLiteral, categories_
cht.SeriesCollection(0).SetData c.chDimValues, c.chDataLiteral, values_
set sc=o.Charts(0).SeriesCollection(0)
sc.Caption=Caption_
Set dl = cht.SeriesCollection(0).DataLabelsCollection.Add
dl.Separator = ":"
dl.HasValue = false
dl.HasSeriesName = false
dl.HasCategoryName=true
dl.HasPercentage = true
dl.Font.Size = 9
dl.Font.Color = "red"
dl.NumberFormat = "00.00%"
end sub
'拆線圖
'chart_bgColor_繪圖區加背景色
'chartCaption_圖表的標題
'chartCaption_fontColor_圖表標題顏色
public sub line(chart_bgColor_,chartCaption_,chartCaption_fontColor_,Caption_,categories_,values_)
o.Clear
Set cht = o.Charts.Add
Set c = o.Constants
cht.Type = c.chChartTypeLineMarkers
'給繪圖區加背景色
o.Charts(0).PlotArea.Interior.SetSolid chart_bgColor_
o.HasChartSpaceTitle = True
o.ChartSpaceTitle.Caption = chartCaption_
o.ChartSpaceTitle.Font.Color = chartCaption_fontColor_
o.ChartSpaceTitle.Font.Name = "Arial"
o.ChartSpaceTitle.Font.Size = 12
o.ChartSpaceTitle.Font.Underline = c.owcUnderlineStyleSingle

cht.SetData c.chDimCategories, c.chDataLiteral, categories_
cht.SeriesCollection(0).SetData c.chDimValues, c.chDataLiteral, values_

set sc=o.Charts(0).SeriesCollection(0)
sc.Caption=Caption_
Set dl = cht.SeriesCollection(0).DataLabelsCollection.Add
dl.HasValue = True
dl.HasPercentage = False
dl.Font.Size = 9
dl.Font.Color = "red"

Set categoryAxis = cht.Axes(c.chAxisPositionBottom)
categoryAxis.Font.Size = 9

Set categoryAxis = cht.Axes(c.chAxisPositionLeft)
categoryAxis.Font.Size = 9
end sub
'多系列拆線圖
'chart_bgColor_圖表的背景顏色
'chartCaption_圖表的標題
'chartCaption_fontColor_圖表標題顏色
'color_顏色數組
'caption_名稱數組
'categories_名稱數組
'values_值數組
public sub serLine(chart_bgColor_,chartCaption_,chartCaption_fontColor_,color_,SeriesNames_,categories_,values_)
o.Clear
Set cht = o.Charts.Add
Set c = o.Constants
'設置圖表類型
cht.Type = c.chChartTypeLineMarkers
'給繪圖區加背景色
o.Charts(0).PlotArea.Interior.Color=chart_bgColor_
'加上標題
o.HasChartSpaceTitle = True
o.ChartSpaceTitle.Caption = chartCaption_
o.ChartSpaceTitle.Font.Color = chartCaption_fontColor_
o.ChartSpaceTitle.Font.Name = "Arial"
o.ChartSpaceTitle.Font.Size = 12
''添加數據
cht.SetData c.chDimSeriesNames, c.chDataLiteral, SeriesNames_
cht.SetData c.chDimCategories, c.chDataLiteral, Categories_

set categoryAxis = cht.Axes(c.chAxisPositionBottom)
categoryAxis.Font.Size = 9

Set categoryAxis = cht.Axes(c.chAxisPositionLeft)
categoryAxis.Font.Size = 9

for i = 0 to ubound(SeriesNames_)
valuetemp = ""
for j = i*(ubound(Categories_)+1) to (i+1)*(ubound(Categories_)+1)-1
valuetemp = valuetemp & "," & values_(j)
next
valuearr = split(mid(valuetemp,2),",")
cht.SeriesCollection(i).SetData c.chDimValues, c.chDataLiteral, valuearr
cht.SeriesCollection(i).Line.Color = color_(i)
cht.SeriesCollection(i).Line.Weight = c.owcLineWeightThin
cht.SeriesCollection(i).Marker.Style = c.chMarkerStyleDiamond
cht.SeriesCollection(i).Interior.Color = color_(i)
Set dl = cht.SeriesCollection(i).DataLabelsCollection.Add
dl.HasValue = true
dl.HasPercentage = false
dl.Font.Size = 9
dl.font.color="red"
next
end sub
'清除圖型
public sub clear()
o.Clear
end sub
end class

代码如下:

<html>
<head>
<title>vbscript owc class test</title>
<script language="vbscript" src="owc1.vbs"></script>
<script language="vbscript">
sub window_onload()
set t = new owc

categories =Array("A2-1","A2-2","A2-3","A3-1","A3-2","A3-3"_
,"B2-1","B2-2","B2-3","B3-1","B3-2","B3-3"_
,"C2-1","C2-2","C3-1","C3-2","C3-3")
values = Array(0.813,0.689,0.800,0.833,0.681,0.864,0.743_
,0.894,0.822,0.874,0.746,0.908,0.850_
,0.728,0.731,0.734,0.624)
t.create "cs1","100%","400px","c1"
t.bar "#FFFFFF","報表標題","BLUE","#CCCC00","組別",categories,values

color=Array("#CCFFFF","#99CCFF","#00CCFF","#FF0000","#660066","#FF8080")
caption=Array("第1周","第2周","第3周","第4周")
categories=Array("A棟","B棟")
values=Array(0.6951,0.5798,0.7075,0.512,0.7907,0.7493,0.8691,0.7716)
t.create "cs2","100%","400px","c2"
t.serbar "#FFFFFF","2008年10月坑頭三廠各周各樓層達成率比較圖","red",color,caption,categories,values

categories=array("臺北","上海")
values = array(238760,912560.62)
t.create "cs3","100%","400px","c3"
t.Pie "#FFFFFF","銷售金額所佔比例(城市分類)","BLUE","城市",categories,values

categories =array("2008/11/1","2008/11/2","2008/11/3","2008/11/4","2008/11/5","2008/11/6","2008/11/7","2008/11/8","2008/11/9","2008/11/10","2008/11/11","2008/11/12","2008/11/13","2008/11/14","2008/11/15","2008/11/16","2008/11/17","2008/11/18","2008/11/19","2008/11/20","2008/11/21","2008/11/22","2008/11/23","2008/11/24","2008/11/25","2008/11/26","2008/11/27","2008/11/28","2008/11/29","2008/11/30")
values = array(67239.89,60400.26,7202.89,18453.12,28889.29,102136.25,78826.39,146291.6,93743.29,44204.44,45349.28,50730.6,37900.21,84359.87,169333.62,114594.96,75334.77,51360.32,55853.05,37912.63,45068.22,63930.98,72993.71,18699.5,24714.5,34792.91,39414.58,92171.2,74433.06,3998894.41)
t.create "cs4","100%","400px","c4"
t.line "#FFFFFF","銷售金額","BLUE","日期",categories,values

color=Array("#CCFFFF","#99CCFF","#00CCFF","#FF0000")
SeriesNames = array("A產品","B產品","C產品","D產品")
Categories = array("2005/3/24","2005/3/25","2005/3/26","2005/3/27","2005/3/28")
values = array(50,100,20,80,89,40,60,20,90,70,20,50,55,25,60,80,20,75,58,100)
t.create "cs5","100%","400px","c5"
t.serline "#FFFFFF","達成率月報表","red",color,SeriesNames,categories,values

set t=nothing
end sub
</script>
</head>
<body>
<div id="c1"></div>
<div id="c2"></div>
<div id="c3"></div>
<div id="c4"></div>
<div id="c5"></div>
</body>
</html>

(0)

相关推荐

  • VbScript 封裝MS OWC(二)

    复制代码 代码如下: ''OWC1.VBS class owc private o '傳入物件 public sub create(id_,width_,height_,location_) Set o = document.createElement("object") o.setAttribute "id",id_ o.setAttribute "classid","CLSID:0002E55D-0000-0000-C000-000

  • vbscript ms owc 封裝代码

    复制代码 代码如下: ''owc.vbs class owc private o '传入物件 public property set set_obj(o_id) set o=o_id end property '画图矩形图 'chart_bgcolor_图表的背景颜色 'chartCaption_图表的标题 'chartCaption_fontColor_图表标题颜色 'Interior_Color_矩形内的填充颜色 'Caption_名称 'categories_名称数组 'values_值数

  • InputStreamReader和BufferedReader用法及实例讲解

    一.BufferedReader类 . 所属类库: java.lang.Object java.io.Reader java.io.BufferedReader . 基本概念 : public class BufferedReader    extends Reader 从字符输入流中读取文本,缓冲各个字符,从而实现字符.数组和行的高效读取. 可以指定缓冲区的大小,或者可使用默认的大小.大多数情况下,默认值足够大. 通常, Reader 所作的每个读取请求都会导致对底层字符或字节流进行相应的读取

  • Django自带用户认证系统使用方法解析

    Django自带用户认证系统,这个系统支持访问控制.注册用户.关联创建者和内容等:在开发用户认证功能时的时候,可以使用django中的django.contrib.auth 中封裝了注册.认证,登录登出方法,可以直接使用: 相关表 在使用"python manage.py makemigrationss"和"python manage.py migrate"迁移完成数据库之后 根据配置文件settings.py中的数据库段生成的数据表中已经包含了6张进行认证的数据表

  • ASP动态网页制作技术经验分享

    学好一门编程语言有两个条件是必不可少的,一是理论与实践结合.在实际例程去验证书本上的理论能加深你对理论的理解:二是学会总结,把学习.运用中的心得体会记下来,当成一种经验或者教训加以提炼并在日后的应用中加以改进,一定能提高你对这门编程语言的认识.以下是笔者在学习与运用ASP编程中的两点经验,希望能对大家有所帮助. ASP页面内VBScript和JScript的交互 ASP具备管理不同语言脚本程序的能力,能够自动调用合适的脚本引擎以解释脚本代码和执行内置函数.ASP开发环境提供了两种脚本引擎,即VB

  • 代码实现打印功能(asp.net+javascript)

    一.在服务器端实现 1.这个是在本页面上的.cs文件里写的 复制代码 代码如下: if (resultInt > 0) { //清除验证码 ,显示执行结果,并转向新的地址 Session["YanZhengMa"] = ""; String caoCode = "if(confirm('提交成功,是否打印'))" + "{" + "window.location.href='printTKZ.aspx?type

  • Asp.Net使用Npoi导入导出Excel的方法

    asp.net针对Excel文件的导入与导出是非常常见的功能之一.本文实例讲述了Asp.Net使用Npoi导入导出Excel的方法.分享给大家供大家参考之用.具体方法如下: 在使用Npoi导出Excel的时候,服务器可以不装任何office组件,一般在导出时用到Npoi导出Excel文件,所导Excel也符合规范,打开时也不会有任何文件损坏之类的提示.但是在做导入时还是使用OleDb的方式,这种方式的导入在服务器端似乎还是需要装office组件的. 一.Npoi导出/下载Excel 具体功能代码

  • JS如何将数字类型转化为没3个一个逗号的金钱格式

    3345687687876789123 转化为:xxx,xxx,xxx 复制代码 代码如下: <script type="text/javascript"> window.onload = function(){ //整个测试由小刀提供 var testFun = function( callback, str ){ var tipElem = document.createElement( 'div' ), startTime, duration = 0; for( va

  • 想学习javascript JS和jQuery哪个重要 先学哪个

    笔者以自己身学习和使用经验分享给大家,有任何问题或疑惑,欢迎留言 在回答题目问题前,首先大家需要了解下什么是js,什么是jQuery js,即JavaScript 在1995年时,由Netscape公司的Brendan Eich,在网景导航者浏览器上首次设计实现而成.因为Netscape与Sun合作,Netscape管理层希望它外观看起来像Java,因此取名为JavaScript JavaScript一种直译式脚本语言,是一种动态类型.弱类型.基于原型的语言,内置支持类型. jQuery jQu

  • Java实现级联下拉结构的示例代码

    目录 前言 构建统一返回下拉结构 构建集合<对象>转下拉树工具类 构建List<Map>转下拉或下拉树的工具类 前言 在开发过程中,会遇到很多的实体需要将查出的数据处理为下拉或者级联下拉的结构,提供给前端进行展示. 在数据库查出的结构中,可能是集合<实体类>的结构,也有可能是List<Map>的结构. 在下拉或者级联下拉的节点数据中,有时候还需要动态的携带其他的参数,已便于前端对某些数据的显示 如区域的级联下拉树中,需要携带经纬度的区域–在选择的时候在地图展

随机推荐