欢迎光临
我们一直在努力

一个不需要第三方组件,可实现华简单图形的类

建站超值云服务器,限时71元/月

通常我们做统计图的时候需要借助组件来完成例如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)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 一个不需要第三方组件,可实现华简单图形的类
分享到: 更多 (0)