让我们一起爱米兰
站内搜搜:
移动设备
请扫描二维码
或访问
m.milan100.com
您所在的位置 -> 米兰百分百 -> ASP -> asp不是用第三方组件,可实现华简单图形的类

asp不是用第三方组件,可实现华简单图形的类

点击数:943 发表时间:2010-07-26 18:55:48 作者: 来源链接:
分享到:
分享到微信

通常我们做统计图的时候需要借助组件来完成例如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() )
%>
 

0
很 好
0
一 般
0
差 劲
热门新闻
相关文章
上一篇: ASP中七种实现分页显示的方法
下一篇: ASP+MsSqlServer 存储过程分页
评论区
匿名

返回首页 | 收藏本页 | 回到顶部
Copyright 2010. 米兰百分百 Powered By Bridge.
京ICP备15050557号