文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>利用OWC画图的例子

利用OWC画图的例子

时间:2007-04-09  来源:toumh

<% 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>
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载