asp无组件实现画简单图形的类

作者:佚名 来源:asp之家 时间:2004-06-17 13:30:00 

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



标签:画图,无组件,asp
0
投稿

猜你喜欢

  • MySQL数据库中的重要数据应当如何保护

    2008-12-17 15:56:00
  • 一个向上滚动代码

    2010-02-10 12:29:00
  • oracle sqlplus 常用命令大全

    2009-05-24 19:47:00
  • Christopher Schmitt 谈学习CSS的益处

    2008-07-13 14:15:00
  • 关于CSS中字号控制的兼容性研究

    2010-01-23 12:48:00
  • 完美的js验证网址url(正则表达式)

    2008-06-07 09:36:00
  • Linux mysql安装修改root密码服务

    2010-10-14 13:59:00
  • Safari显示网页字体为超级无敌难看的宋体的原因

    2008-04-20 16:49:00
  • 解决SQL Server的“此数据库没有有效所有者”问题

    2011-12-14 18:29:35
  • 一个非常有代表性的javascript简易拖动类

    2009-05-25 12:44:00
  • asp form 表单验证函数

    2011-04-04 11:10:00
  • 网页设计中的对比原则

    2010-03-20 21:50:00
  • ASP访问SQL Server内置对象

    2008-04-05 06:49:00
  • MySQL数据库root权限丢失解决方案

    2008-07-13 13:59:00
  • asp如何设定程序的执行次数?

    2010-05-18 18:31:00
  • 用ASP实现在线压缩与解压缩

    2007-09-29 12:13:00
  • Xml_javascript分页

    2008-09-04 14:43:00
  • CSS样式表中继承关系的空格与不空格

    2007-12-12 13:05:00
  • 13家著名科技公司logo标识来历及演变

    2008-02-19 16:42:00
  • sql server update 表的问题

    2009-10-04 20:32:00
  • asp之家 网络编程 m.aspxhome.com