一個不需要第三方組件,可實現華簡單圖形的類

來源:互聯網
上載者:User
圖形 通常我們做統計圖的時候需要藉助組件來完成例如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://www.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 & "<table height=" & BarWidth & " border=1 width=" & Maximum & " cellspacing=2>" & vbNewLine
data = data & vbTab & "<tr><td width=" & Items(Idx) & " bgcolor=" & BarColor & " align=center><font size=-4> </font></td>"
If Items(Idx) < Maximum Then
data = data & "<td width=" & Maximum - Items(Idx) & "></td>"
End If
data = data & "</tr>" & vbNewLine & "</table>" & vbNewLine
Next
ElseIf LCase( Orientation ) = "vertical" Then
data = "<table><tr>" & vbNewLine
For Idx = LBound( Items ) To UBound( Items )
data = data & "<td><table width=" & BarWidth & " border=1 height=" & Maximum & " cellspacing=2>" & vbNewLine
If Items(Idx) < Maximum Then
data = data & "<tr><td height=" & Maximum - Items(Idx) & "></td></tr>"
End If
data = data & vbTab & "<tr><td height=" & Items(Idx) & " bgcolor=" & BarColor & " align=center><font size=-4> </font></td>"
data = data & "</tr>" & vbNewLine & "</table>" & vbNewLine & "</td>" & vbNewLine
Next
data = data & "</tr></table>" & vbNewLine
End If
Build = data
End Function

End Class
%>
使用方法
這個類一共有四個屬性
BarWidth(圖片條的尺寸)
BarColor*(圖片條顏色)
Maximum(圖片條最大長度)
Orientation(方向)
有兩個函數
Add( value )添加圖片條到圖片中
Build()建立圖片
案例:
<!-- #include file=clsGraph.asp -->
<%
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() )
%>



相關文章

Cloud Intelligence Leading the Digital Future

Alibaba Cloud ACtivate Online Conference, Nov. 20th & 21st, 2019 (UTC+08)

Register Now >

11.11 Big Sale for Cloud

Get Unbeatable Offers with up to 90% Off,Oct.24-Nov.13 (UTC+8)

Get It Now >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。