ASP Chart 使用范例
发表时间:2024-06-17 来源:明辉站整理相关软件相关文章人气:
[摘要]Simple Chart Example 使用很简单哦,这样就可以了: 用Server.CreateObject建立对象 设置图表属性 调用SaveChart方法保存到硬盘或者用Response.BinaryWrite Chart.Image直接发送 下面这段代码是示范如何建立一个柱图的: ctB...
Simple Chart Example
使用很简单哦,这样就可以了:
用Server.CreateObject建立对象
设置图表属性
调用SaveChart方法保存到硬盘或者用Response.BinaryWrite Chart.Image直接发送
下面这段代码是示范如何建立一个柱图的:
ctBar = 1
cNone = 0
cGradient =6
rem **********************************************************************
rem * Instantiate the Chart component
rem **********************************************************************
Set Chart = Server.CreateObject ("ASPChart.Chart")
rem **********************************************************************
rem * Add a Bar series with 3 points
rem **********************************************************************
Chart.AddSeries (ctBar)
Chart.AddValue 200, "Regular", vbBlue
Chart.AddValue 233, "Enhanced ", vbRed
Chart.AddValue 260, "Free", vbGreen
Chart.BarStyle = cGradient
rem **********************************************************************
rem * Set the PanelColor, remove the OuterBevel
rem **********************************************************************
Chart.PanelColor = vbWhite
Chart.BevelOuter = cNone
Chart.ChartBGColor = vbWhite
rem **********************************************************************
rem * Set the Width and Height of the image
rem **********************************************************************
Chart.Height = 300
Chart.Width = 500
rem **********************************************************************
rem * Set the filename, save the image and write the image tag
rem **********************************************************************
Chart.FileName = "d:\inetpub\wwwroot\images\smpchrt1.jpg"
'也不知道用Server.MapPath,不知道是笨呢还是图效率高。
Chart.SaveChart
Response.Write "<img src=""http://www.okasp.com/images/smpchrt1.jpg"">"
rem **********************************************************************
rem * Destroy the object
rem **********************************************************************
Set Chart = nothing
Multiple Series per Chart
下面这段代码是示范如何建立多列数据的图表的.
Set Chart = Server.CreateObject("AspChart.Chart")
Randomize
Chart.AddSeries 7 'Candle Series
dblOpen = 1000 + Rnd(100)
for intCount = 1 to 30
dblBase = Round(100*Rnd-50)
Chart.AddCandle Now + intCount, dblOpen, dblOpen+20, dblOpen-20, dblOpen+dblBase
dblOpen = dblOpen + dblBase
next
Randomize
Chart.AddSeries 5 '这样再调用一次AddSeries就可以再加一列数据了
dblOpen = 1000 + Rnd(100)
for intCount = 1 to 30
dt = Now + intCount
dblBase = Round(100*Rnd-50)
Chart.AddXY dt, dblOpen, CStr(Month(dt))+ "/" + _
CStr(Day(dt))+"/" + CStr(Year (dt) Mod 100),vbRed
dblOpen = dblOpen + dblBase
next
再加一段直接输出到浏览器的例子吧:
Response.ContentType = "image/JPEG"
Dim Chart
Set Chart = Server.CreateObject ("ASPChart.Chart")
Chart.AddSeries (ctBar)
Chart.AddValue 200, "Regular", vbBlue
Chart.AddValue 233, "Enhanced ", vbRed
Chart.AddValue 260, "Free", vbGreen
Chart.BarStyle = cGradient
Chart.PanelColor = vbWhite
Chart.BevelOuter = cNone
Chart.ChartBGColor = vbWhite
Chart.Height = 300
Chart.Width = 500
Response.BinaryWrite Chart.Image
Set Chart = nothing
(出处:热点网络)