通常我們做統(tǒng)計圖的時候需要借助組件來完成例如mschart,aspchart等
但是這個類不需要任何組件,而且使用方便
clsgraph.asp
<%
class inteligraph
public copyright, developer, name, version, web
public maximum, barwidth, barcolor, orientation
private items(), cnt
private sub class_initialize()
copyright = "?2001 ticluse teknologi, all rights reserved."
developer = "james lind雗"
name = "inteligraph"
version = "1.0"
web = "http://intelidev.com"
cnt = 0
end sub
public function add( value )
redim preserve items( cnt )
items( cnt ) = value
data = cnt
cnt = cnt + 1
add = data
end function
public function build()
if cnt < 1 then exit function
if len( orientation ) = 0 or lcase( orientation ) = "horizontal" then
for idx = lbound( items ) to ubound( items )
data = data & "
" & vbnewline
data = data & vbtab & " | "
if items(idx) < maximum then
data = data & " | "
end if
data = data & "
" & vbnewline & "
" & vbnewline
next
elseif lcase( orientation ) = "vertical" then
data = "
" & vbnewline
for idx = lbound( items ) to ubound( items )
data = data & "" & vbnewline if items(idx) < maximum then data = data & " | " end if data = data & vbtab & " | " data = data & " " & vbnewline & " " & vbnewline & " | " & vbnewline
next
data = data & "
" & vbnewline
end if
build = data
end function
end class
%>
使用方法
這個類一共有四個屬性
barwidth(圖片條的尺寸)
barcolor*(圖片條顏色)
maximum(圖片條最大長度)
orientation(方向)
有兩個函數(shù)
add( value )添加圖片條到圖片中
build()建立圖片
事例:
<%
public const vert = "vertical"
public const horz = "horizontal"
dim graph
set graph = new inteligraph
graph.barwidth = 10
graph.barcolor = "blue"
graph.maximum = 100
graph.orientation = horz
for idx = 0 to 100 step 25
graph.add( idx )
next
response.write( graph.build() )
%>
該文章在 2010/7/8 0:34:31 編輯過