|
.SetData oconst.chDimCategories,oconst.chDataLiteral,XXX (设置X轴的数据值)
.SetData oconst.chDimValues,oconst.chDataLiteral,XXX(设置Y 轴的数据值)
.type=0(设置图表显示的类型,0 表示普通柱形图)
end with
对照图片,我们可以知道,X 轴为日期(季度),Y轴为销售额,绘图区为具体的销售额数据。
OWC支持在同一张图表中显示两条以上的曲线(或两个不同颜色的柱子,如上图所示的预计与实际)。因此,要生成我们所看到的图片,只需先生成一条series 曲线(即在绘图区中先绘出预计的销售额图表),然后再添加一条series曲线(即在绘图区中绘出实际的销售额图表)就行了
先定义及设置参数
dim strChartAbsPath
dim strChartRelPath
strChartAbsPath = Server.MapPath("temp")
strChartRelPath = "temp"
以下是生成、删除图片的函数
Function ExportChartToGIF(objCSpace, strAbsFilePath, strRelFilePath)
Dim strFileName
Randomize
strFileName = Timer & Rnd & ".gif"
o b j C S p a c e . E x p o r t P i c t u r estrAbsFilePath & "/" & strFileName, "gif",300(图片高度), 500(图片宽度,以上两值均可由程序动态设置))
ExportChartToGIF = strRelFilePath &"/" & strFileName
End Function
Function 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
a n d D a t e D i f f ( " d " ,g i f .DateLastModified, now) > 5 (如果图片生成的时间已超过5 天,则删除它) then
objFS.DeleteFile GIFpath & "\" &gif.Name, True
end if
i=i+1
next
set objFolder = nothing
set objFS = nothing
End Function
以下是调用代码
strChartFile = ExportChartToGIF(chart, strChartAbsPath, strChartRelPath)
Response.Write "<p align='center'><IMG SRC=""" & strChartFile & """>" &"</P>"
⋯⋯
CleanUpGIF(strChartAbsPath)
⋯⋯
虽然用OWC 生成的图表功能齐全,界面美观,但它也存在着不少缺陷。
首先,OWC只支持RecordSet数据集,不支持DataSet 数据集,因此在检索时不能使用sqlCommand、sqlDataAdapter 等对象,只能使用RecordSet对象进行检索。
上一篇:初学ASP之领略IIS的几则新鲜应用
下一篇:在Windows2003中ASP出现(错误“不允许的父路径 ”)问题的解决方法
|