1 <% 
  2 '生成各种圖型的png圖片
  3 class owc
  4     private o
  5     private PicType
  6     
  7     '創建時自動create owc
  8     Private Sub Class_Initialize()
  9         set o=Server.CreateObject("OWC11.ChartSpace")
 10         PicType = "PNG"'生成的圖片格式
 11     End Sub
 12     '實例終止時自動設為nothing
 13     Private Sub Class_Terminate
 14         set o=nothing
 15     End Sub
 16     '畫圖矩形圖
 17     'chart_bgcolor_圖表的背景顏色
 18     'chartCaption_圖表的標題
 19     'chartCaption_fontColor_圖表標題顏色
 20     'Interior_Color_矩形內的填充顏色
 21     'Caption_名稱
 22     'categories_名稱數組
 23     'values_值數組串
 24     public sub bar(chart_bgcolor_,chartCaption_,chartCaption_fontColor_,Interior_Color_,Caption_,categories_,values_,width_,height_)
 25         On Error Resume Next
 26         Response.Expires = 0
 27         Response.Buffer = True
 28         Response.Clear
 29         o.Clear
 30         set cht = o.Charts.Add
 31         set c = o.Constants
 32         cht.Type = c.chChartTypeColumnClustered
 33         '設背景色或是填充
 34         o.Charts(0).PlotArea.Interior.SetSolid chart_bgcolor_
 35 
 36         '加上圖表的標題
 37         o.HasChartSpaceTitle = True
 38         set cst=o.ChartSpaceTitle
 39         cst.Caption = chartCaption_
 40         cst.Font.Color = chartCaption_fontColor_
 41         cst.Font.Italic = False
 42         cst.Font.Name = "Arial"
 43         cst.Font.Size = 12
 44         cst.Font.Underline = c.owcUnderlineStyleSingle    
 45 
 46         '添加數據
 47         cht.SetData c.chDimCategories, c.chDataLiteral, categories_
 48         cht.SeriesCollection(0).SetData c.chDimValues, c.chDataLiteral, values_
 49         '直條的背景色進行設定
 50         set sc=o.Charts(0).SeriesCollection(0)
 51         sc.Interior.Color=Interior_Color_
 52 
 53         '直條上的顯示設置
 54         sc.Caption=Caption_
 55         set dl = cht.SeriesCollection(0).DataLabelsCollection.Add
 56         dl.HasValue = True
 57         dl.HasPercentage = False
 58         dl.Font.Size = 9
 59         dl.Font.Color = "red"
 60         dl.Position = c.chLegendPositionRight
 61         dl.NumberFormat = "00.00%"
 62         '左邊百分比的屬性設置
 63         Set cta = cht.Axes(c.chAxisPositionLeft)
 64         cta.Font.Size = 9
 65         cta.NumberFormat = "0.0%"
 66         cta.MajorUnit = 0.1
 67         
 68         Response.ContentType = "image/" & PicType
 69         Response.BinaryWrite o.GetPicture(PicType,width_,height_)
 70     end sub
 71     '多系列矩形圖
 72     'chart_bgColor_圖表的背景顏色
 73     'chartCaption_圖表的標題
 74     'chartCaption_fontColor_圖表標題顏色
 75     'color_顏色數組
 76     'caption_名稱數組
 77     'categories_名稱數組
 78     'values_值數組
 79     public sub serBar(chart_bgColor_,chartCaption_,chartCaption_fontColor_,color_,caption_,categories_,values_,width_,height_)
 80         On Error Resume Next
 81         Response.Expires = 0
 82         Response.Buffer = True
 83         Response.Clear         
 84         o.Clear
 85         o.Charts.Add
 86         Set c = o.Constants
 87         '圖表的類型
 88         o.Charts(0).type=c.chChartTypeColumnClustered 
 89         '給繪圖區加背景色
 90         o.Charts(0).PlotArea.Interior.SetSolid chart_bgColor_
 91         ''加上圖表的標題
 92         o.HasChartSpaceTitle = True
 93         o.ChartSpaceTitle.Caption = chartCaption_
 94         '標題的屬性
 95         o.ChartSpaceTitle.Font.Color = chartCaption_fontColor_
 96         o.ChartSpaceTitle.Font.Italic = False
 97         o.ChartSpaceTitle.Font.Name = "Arial"
 98         o.ChartSpaceTitle.Font.Size = 12
 99         o.ChartSpaceTitle.Font.Underline = c.owcUnderlineStyleSingle
100         '用循環來新增SeriesCollection以及里面的內容
101         for i=0 to ubound(caption_)
102             valuetemp=""
103             for j = i*(ubound(categories_)+1) to (i+1)*(ubound(categories_)+1)-1
104                 valuetemp = valuetemp & "," & values_(j)
105             next
106             valuearr = split(mid(valuetemp,2),",")
107             o.Charts(0).SeriesCollection.Add
108             o.Charts(0).SeriesCollection(i).Caption = caption_(i)
109             o.Charts(0).SeriesCollection(i).Interior.Color = color_(i)
110             o.Charts(0).SeriesCollection(i).SetData c.chDimCategories, c.chDataLiteral, categories_
111             o.Charts(0).SeriesCollection(i).SetData c.chDimValues, c.chDataLiteral, valuearr
112             set dl = o.Charts(0).SeriesCollection(i).DataLabelsCollection.Add
113             dl.HasValue = True
114             dl.HasPercentage = False
115             dl.Font.Size = 9
116             dl.Font.Color = "red"
117             dl.Position = c.chLegendPositionRight
118             dl.NumberFormat = "00.00%"
119         next
120         ''圖例的設定    
121         o.Charts(0).HasLegend = True 
122         o.Charts(0).Legend.Font.Size = 9
123         o.Charts(0).Legend.Position = c.chLegendPositionBottom        
124         ''左邊百分比的屬性設置
125         Set cta = o.Charts(0).Axes(c.chAxisPositionLeft)
126         cta.Font.Size = 9
127         cta.NumberFormat = "0.00%"
128         cta.MajorUnit = 0.1
129         Response.ContentType = "image/" & PicType
130         response.BinaryWrite o.GetPicture(PicType,width_,height_)
131     end sub
132     '畫圓餅圖
133     'chart_bgColor_繪圖區加背景色
134     'chartCaption_圖表的標題
135     'chartCaption_fontColor_圖表標題顏色
136     public sub Pie(chart_bgColor_,chartCaption_,chartCaption_fontColor_,Caption_,categories_,values_,width_,height_)
137         On Error Resume Next
138         Response.Expires = 0
139         Response.Buffer = True
140         Response.Clear 
141         o.Clear
142         Set cht = o.Charts.Add
143         Set c = o.Constants
144         cht.Type = c.chChartTypePie3d
145         '給繪圖區加背景色
146         o.Charts(0).PlotArea.Interior.SetSolid chart_bgColor_
147         cht.ExtrudeAngle = 90
148         cht.ChartDepth = 169
149         cht.AspectRatio = 120
150         cht.Rotation =180
151         cht.Inclination=70
152 
153         o.HasChartSpaceTitle = True
154         o.ChartSpaceTitle.Caption = chartCaption_
155         o.ChartSpaceTitle.Font.Color = chartCaption_fontColor_
156         o.ChartSpaceTitle.Font.Name = "Arial" 
157         o.ChartSpaceTitle.Font.Size = 12
158         o.ChartSpaceTitle.Font.Underline = c.owcUnderlineStyleSingle
159             
160         cht.HasLegend = True
161         cht.Legend.Font.Size = 9
162         cht.Legend.Position = c.chLegendPositionBottom
163 
164         cht.SetData c.chDimCategories, c.chDataLiteral, categories_
165         cht.SeriesCollection(0).SetData c.chDimValues, c.chDataLiteral, values_
166         set sc=o.Charts(0).SeriesCollection(0)
167         sc.Caption=Caption_
168         Set dl = cht.SeriesCollection(0).DataLabelsCollection.Add
169         dl.Separator = ":"
170         dl.HasValue = false
171         dl.HasSeriesName = false    
172         dl.HasCategoryName=true
173         dl.HasPercentage = true
174         dl.Font.Size = 9
175         dl.Font.Color = "red"
176         dl.NumberFormat = "00.00%"
177         Response.ContentType = "image/" & PicType
178         response.BinaryWrite o.GetPicture(PicType,width_,height_)
179     end sub
180     '拆線圖
181     'chart_bgColor_繪圖區加背景色
182     'chartCaption_圖表的標題
183     'chartCaption_fontColor_圖表標題顏色
184     public sub line(chart_bgColor_,chartCaption_,chartCaption_fontColor_,Caption_,categories_,values_,width_,height_)
185         On Error Resume Next
186         Response.Expires = 0
187         Response.Buffer = True
188         Response.Clear 
189         o.Clear
190         Set cht = o.Charts.Add 
191         Set c = o.Constants 
192         cht.Type = c.chChartTypeLineMarkers
193         '給繪圖區加背景色
194         o.Charts(0).PlotArea.Interior.SetSolid chart_bgColor_
195         o.HasChartSpaceTitle = True 
196         o.ChartSpaceTitle.Caption = chartCaption_
197         o.ChartSpaceTitle.Font.Color = chartCaption_fontColor_ 
198         o.ChartSpaceTitle.Font.Name = "Arial" 
199         o.ChartSpaceTitle.Font.Size = 12
200         o.ChartSpaceTitle.Font.Underline = c.owcUnderlineStyleSingle
201         
202         cht.SetData c.chDimCategories, c.chDataLiteral, categories_
203         cht.SeriesCollection(0).SetData c.chDimValues, c.chDataLiteral, values_ 
204         
205         set sc=o.Charts(0).SeriesCollection(0)
206         sc.Caption=Caption_
207         Set dl = cht.SeriesCollection(0).DataLabelsCollection.Add 
208         dl.HasValue = True 
209         dl.HasPercentage = False 
210         dl.Font.Size = 9 
211         dl.Font.Color = "red" 
212 
213         Set categoryAxis = cht.Axes(c.chAxisPositionBottom) 
214         categoryAxis.Font.Size = 9 
215 
216         Set categoryAxis = cht.Axes(c.chAxisPositionLeft) 
217         categoryAxis.Font.Size = 9 
218         Response.ContentType = "image/" & PicType
219         response.BinaryWrite o.GetPicture(PicType,width_,height_)
220     end sub
221     '多系列拆線圖
222     'chart_bgColor_圖表的背景顏色
223     'chartCaption_圖表的標題
224     'chartCaption_fontColor_圖表標題顏色
225     'color_顏色數組
226     'caption_名稱數組
227     'categories_名稱數組
228     'values_值數組
229     public sub serLine(chart_bgColor_,chartCaption_,chartCaption_fontColor_,color_,SeriesNames_,categories_,values_,width_,height_)
230         On Error Resume Next
231         Response.Expires = 0
232         Response.Buffer = True
233         Response.Clear 
234         o.Clear
235         Set cht = o.Charts.Add 
236         Set c = o.Constants 
237         '設置圖表類型
238         cht.Type = c.chChartTypeLineMarkers
239         '給繪圖區加背景色
240         o.Charts(0).PlotArea.Interior.Color=chart_bgColor_
241         '加上標題
242         o.HasChartSpaceTitle = True
243         o.ChartSpaceTitle.Caption = chartCaption_
244         o.ChartSpaceTitle.Font.Color = chartCaption_fontColor_
245         o.ChartSpaceTitle.Font.Name = "Arial"
246         o.ChartSpaceTitle.Font.Size = 12
247         ''添加數據
248         cht.SetData c.chDimSeriesNames, c.chDataLiteral, SeriesNames_
249         cht.SetData c.chDimCategories, c.chDataLiteral, Categories_
250      
251         set categoryAxis = cht.Axes(c.chAxisPositionBottom)
252         categoryAxis.Font.Size = 9
253      
254         Set categoryAxis = cht.Axes(c.chAxisPositionLeft)
255         categoryAxis.Font.Size = 9
256 
257         for i = 0 to ubound(SeriesNames_)
258             valuetemp = ""
259             for j = i*(ubound(Categories_)+1) to (i+1)*(ubound(Categories_)+1)-1
260                 valuetemp = valuetemp & "," & values_(j)
261             next
262             valuearr = split(mid(valuetemp,2),",")
263             cht.SeriesCollection(i).SetData c.chDimValues, c.chDataLiteral, valuearr
264             cht.SeriesCollection(i).Line.Color = color_(i)
265             cht.SeriesCollection(i).Line.Weight = c.owcLineWeightThin
266             cht.SeriesCollection(i).Marker.Style = c.chMarkerStyleDiamond
267             cht.SeriesCollection(i).Interior.Color = color_(i)
268             Set dl = cht.SeriesCollection(i).DataLabelsCollection.Add
269             dl.HasValue = true
270             dl.HasPercentage = false
271             dl.Font.Size = 9
272             dl.font.color="red"
273         next
274         Response.ContentType = "image/" & PicType
275         response.BinaryWrite o.GetPicture(PicType,width_,height_)
276     end sub
277 end class
278 %> 
279 
<!--#include file="owc.asp" -->
<%
'Option Explicit
Response.buffer=true
Response.Expires = -1
Response.AddHeader "Pragma","no-cache"
Response.AddHeader "cache-ctrol","no-cache"
chartType=request.QueryString("chartType")
select case chartType
    case "bar"
        call bar()
    case "serbar"
        call serbar()
    case "pie"
        call pie()
    case "line"
        call line()
    case "serline"
        call serline()
end select

sub bar()
    On Error Resume Next
    set o=new owc
    dim chart_bgcolor,chartCaption,chartCaption_fontColor,Interior_Color,Caption,categories,values,width,height
    chart_bgColor=request.QueryString("chart_bgColor")
    if chart_bgColor="" then chart_bgColor="#FFFFFF"
    chartCaption=request.QueryString("chartCaption")
    chartCaption_fontColor=request.QueryString("chartCaption_fontColor")
    Interior_Color=request.QueryString("Interior_Color")
    Caption=request.QueryString("Caption")
    categories=request.QueryString("categories")
    values=request.QueryString("values")
    width=request.QueryString("width")
    if width="" then width="400"
    height=request.QueryString("height")
    if height="" then height="300"
    dim catarr,valarr
    catarr=split(categories,",")
    valarr=split(values,",")
    o.bar chart_bgcolor,chartCaption,chartCaption_fontColor,Interior_Color,Caption,catarr,valarr,width,height
    set o=nothing
end sub
sub serbar()
    On Error Resume Next
    set o=new owc
    dim chart_bgcolor,chartCaption,chartCaption_fontColor,color,Caption,categories,values,width,height
    chart_bgColor=request.QueryString("chart_bgColor")
    if chart_bgColor="" then chart_bgColor="#FFFFFF"
    chartCaption=request.QueryString("chartCaption")
    chartCaption_fontColor=request.QueryString("chartCaption_fontColor")
    color=request.QueryString("color")
    Caption=request.QueryString("Caption")
    categories=request.QueryString("categories")
    values=request.QueryString("values")
    width=request.QueryString("width")
    if width="" then width="400"
    height=request.QueryString("height")
    if height="" then height="300"
    dim colarr,catarr,valarr
    colarr=split(color,",")
    catarr=split(categories,",")
    valarr=split(values,",")
    o.serbar chart_bgColor,chartCaption,chartCaption_fontColor,colarr,catarr,valarr,values,width,height
    set o=nothing
end sub
sub pie()
    On Error Resume Next
    set o=new owc
    dim chart_bgcolor,chartCaption,chartCaption_fontColor,Caption,categories,values,width,height
    chart_bgColor=request.QueryString("chart_bgColor")
    if chart_bgColor="" then chart_bgColor="#FFFFFF"
    chartCaption=request.QueryString("chartCaption")
    chartCaption_fontColor=request.QueryString("chartCaption_fontColor")
    Caption=request.QueryString("Caption")
    categories=request.QueryString("categories")
    values=request.QueryString("values")
    width=request.QueryString("width")
    if width="" then width="400"
    height=request.QueryString("height")
    if height="" then height="300"
    dim catarr,valarr
    catarr=split(categories,",")
    valarr=split(values,",")
    o.pie chart_bgColor,chartCaption,chartCaption_fontColor,Caption,catarr,valarr,width,height
    set o=nothing
end sub
sub line()
    On Error Resume Next
    set o=new owc
    dim chart_bgcolor,chartCaption,chartCaption_fontColor,Caption,categories,values,width,height
    chart_bgColor=request.QueryString("chart_bgColor")
    if chart_bgColor="" then chart_bgColor="#FFFFFF"
    chartCaption=request.QueryString("chartCaption")
    chartCaption_fontColor=request.QueryString("chartCaption_fontColor")
    Caption=request.QueryString("Caption")
    categories=request.QueryString("categories")
    values=request.QueryString("values")
    width=request.QueryString("width")
    if width="" then width="400"
    height=request.QueryString("height")
    if height="" then height="300"
    dim catarr,valarr
    catarr=split(categories,",")
    valarr=split(values,",")
    o.line chart_bgColor,chartCaption,chartCaption_fontColor,Caption,catarr,valarr,width,height
    set o=nothing
end sub
sub serline()
    On Error Resume Next
    set o=new owc
    dim chart_bgcolor,chartCaption,chartCaption_fontColor,color,SeriesNames,categories,values,width,height
    chart_bgColor=request.QueryString("chart_bgColor")
    if chart_bgColor="" then chart_bgColor="#FFFFFF"
    chartCaption=request.QueryString("chartCaption")
    chartCaption_fontColor=request.QueryString("chartCaption_fontColor")
    color=request.QueryString("color")
    SeriesNames=request.QueryString("SeriesNames")
    categories=request.QueryString("categories")
    values=request.QueryString("values")
    width=request.QueryString("width")
    if width="" then width="400"
    height=request.QueryString("height")
    if height="" then height="300"
    dim colarr,serarr,catarr,valarr
    colarr=split(color,",")
    serarr=split(SeriesNames,",")
    catarr=split(categories,",")
    valarr=split(values,",")
    o.serline chart_bgColor,chartCaption,chartCaption_fontColor,colarr,serarr,catarr,valarr,width,height
    set o=nothing
end sub
%>

 1 <%@LANGUAGE="VBSCRIPT" CODEPAGE="950"%>
 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 3 <html xmlns="http://www.w3.org/1999/xhtml">
 4 <head>
 5 <meta http-equiv="Content-Type" content="text/html; charset=big5" />
 6 <title>test owc</title>
 7 </head>
 8 
 9 <body>
10 <%
11 url="chart.asp?chartType=bar"&_
12     "&chart_bgcolor=" & server.URLEncode("#FFFFFF") &_
13     "&chartCaption=" & server.URLEncode("報表標題") &_
14     "&chartCaption_fontColor=" & server.URLEncode("BLUE") &_
15     "&Interior_Color=" & server.URLEncode("#CCCC00") &_
16     "&Caption=" & server.URLEncode("組別") &_
17     "&categories=" & server.URLEncode("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") &_
18     "&values=" & server.urlencode("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") &_
19     "&width=" & server.urlencode("800") &_
20     "&height=" & server.URLEncode("500")
21 'url="t.asp"
22 %>
23 <img src="<%=url %>" />
24 </body>
25 </html>
26 

ASP封裝OWC CLASS相关推荐

  1. html5 strongeaseinout,Canvas開發庫封裝

    一.Canvas第三方類庫 1.常見的第三方類庫 konva.js body{ margin:0; } //創建舞台 var stage=new Konva.Stage({ container:&qu ...

  2. [教程] [承風雅傳HSU]用ES4封裝Win7---ES4 Win7封裝教程(未完待續)

    [教程] [承風雅傳HSU]用ES4封裝Win7---ES4 Win7封裝教程(未完待續) a10036it 发表于 2015-7-27 21:11:19 https://www.itsk.com/t ...

  3. react-native 原生組件封裝與原生模塊和js的交互

    React-native 與原生模塊之間的交互 與原生模塊之間交互,主要分兩種, 一. 只需要導出方法 傳遞參數等交互 模塊之間交互 二. 視圖交互 JS 需要用到native的原生的視圖控件 為了看 ...

  4. ASP中利用OWC控件实现图表功能详解[zz]

    ASP中利用OWC控件实现图表功能详解 在ASP中利用OWC(Office Web Components)控件可轻松实现各种图表功能,如饼图,簇状柱型图,折线图等. 在下面的代码中我详细的给出了饼图, ...

  5. android 溢出按钮,React-Native封裝Tabbar 實現中間按鈕溢出效果(Android/iOS)

    以前寫過一篇文章是基於react-native-tab-navigator 封裝Tabbar,由於RN版本的不斷更新,react-navigation,自17年1月開源以來就備受關注,Fb推薦使用庫, ...

  6. ASP中利用OWC控件实现图表功能详解

    在ASP中利用OWC(Office Web Components)控件可轻松实现各种图表功能,如饼图,簇状柱型图,折线图等. 在下面的代码中我详细的给出了饼图,簇状柱型图,折线图的使用方法.OWC的更 ...

  7. java owc_vbscript ms owc 封裝代码

    ''owc.vbs class owc private o '传入物件 public property set set_obj(o_id) set o=o_id end property '画图矩形图 ...

  8. 如何在ASP.NET中用OWC绘制图表

    一.概述  <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />   ...

  9. [转贴]如何在ASP.NET中用OWC绘制图表

    一.概述 在开发应用程序时,经常会遇到必须提供交互式图表的情况.例如,你可能在开发一个管理销售和产品数据的应用程序,数据保存在SQL Server数据库上,应用程序允许用户添加数据.更新现有数据,但除 ...

最新文章

  1. shell批量添加用户
  2. pandownload 卢本伟_PanDownload复活了!60MB/s!附下载地址
  3. 订单拣选作业模式总结
  4. getparent_Java文件类字符串getParent()方法(带示例)
  5. Sql Server参数化查询之where in和like实现之xml和DataTable传参
  6. 利用NSA方程式工具—“永恒之蓝”攻陷一台计算(MS17-010)
  7. 什么是BSIC及其在GSM系统中的应用
  8. 谢谢版主整理的好材料,,妈妈再也不用担心的我的unity
  9. 用只读打开服务器上的文档,打开WebDAV文档在MS Office中以IT只读方式打开WebDAV服务器...
  10. “不限流量卡”真的不限量,但是却限制了这些!
  11. H5原生js简单拼图游戏
  12. IDEA中MAVEN项目Dependency not found 问题
  13. python-----定制群发微信消息
  14. R网格MIC与频繁项集
  15. 微信小程序入门之广告条
  16. final修饰的变量就是常量?
  17. uva 378Intersecting Lines
  18. 从后台得到webshell十大技巧大汇总
  19. 学计算机的学后感,关于大学生计算机学习心得体会(精选4篇)
  20. C语言例题:求出圆柱体的体积

热门文章

  1. PHP 6:PHP 基本数据类型
  2. Java @override报错的解决方法 .
  3. linux系统中防止系统时间,设置系统时间与在Linux中
  4. 国立大学 计算机,新加坡国立大学 计算机
  5. 自我引用(Self reference)
  6. MySQL分组函数使用的其他注意事项
  7. base64原理核心规则
  8. MybatisPlus添加操作
  9. 获取class文件对象三种方式
  10. 微服务调用组件Feign:简介以及搭建环境