欢迎光临
我们一直在努力

利用OWC画图的例子

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

<% option explicit %>

<html>

<head>

<title>利用owc画图的例子</title>

<!– #include virtual="/include/adovbs.inc" –>

<%

function exportcharttogif(objcspace, strabsfilepath, strrelfilepath)

dim strfilename

randomize

strfilename = timer & rnd & ".gif"

objcspace.exportpicture strabsfilepath & "\" & strfilename, "gif", 600, 350

exportcharttogif = strrelfilepath & "/" & strfilename

end function

sub cleanupgif(gifpath)

dim objfs

dim objfolder

dim gif

set objfs = server.createobject("scripting.filesystemobject")

set objfolder = objfs.getfolder(gifpath)

for each gif in objfolder.files

if instr(gif.name, ".gif") > 0 and datediff("n", gif.datelastmodified, now) > 10 then

objfs.deletefile gifpath & "\" & gif.name, true

end if

next

set objfolder = nothing

set objfs = nothing

end sub

%>

</head>

<body bgcolor="#ffffff">

<%

dim objchartspace

dim objchart

dim objseries

dim objconn

dim objrs

dim c

dim series

dim strchartabspath

dim strchartrelpath

dim strchartfile

strchartabspath = server.mappath("/mypath/temp")

strchartrelpath = "temp"

set objchartspace = server.createobject("owc.chart")

set objchart = objchartspace.charts.add()

set c = objchartspace.constants

objchart.type = c.chcharttypelinemarkers

objchart.haslegend = true

set objconn = server.createobject("adodb.connection")

objconn.open "provider=sqloledb;data source=myserver;initial catalog=testdb;user id=myuid;password=mypswd;"

set objrs = server.createobject("adodb.recordset")

set objrs.activeconnection = objconn

objrs.cursortype = adopenstatic

objrs.cursorlocation = aduseclient

objrs.open "select * from testscore order by test"

set objchartspace.datasource = objrs

objchart.setdata c.chdimseriesnames, 0, "student"

for each objseries in objchart.seriescollection

objseries.setdata c.chdimcategories, 0, "test"

objseries.setdata c.chdimvalues, 0, "score"

next

for each axis in objchart.axes

axis.hastitle = true

if axis.type = c.chcategoryaxis then

axis.title.caption = "test"

else

axis.title.caption = "score"

end if

next

objchart.seriescollection(2).interior.color = "red"

objchart.seriescollection(2).line.color = "red"

strchartfile = exportcharttogif(objchartspace, strchartabspath, strchartrelpath)

response.write "<img src=""" & strchartfile & """>" & "<p>"

cleanupgif strchartabspath

objrs.close

set objrs = nothing

set objconn = nothing

set objseries = nothing

set objchart = nothing

set objchartspace = nothing

%>

</body>

</html>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 利用OWC画图的例子
分享到: 更多 (0)