ASP Chart 使用范例
發(fā)表時(shí)間:2024-06-17 來(lái)源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]Simple Chart Example 使用很簡(jiǎn)單哦,這樣就可以了: 用Server.CreateObject建立對(duì)象 設(shè)置圖表屬性 調(diào)用SaveChart方法保存到硬盤或者用Response.BinaryWrite Chart.Image直接發(fā)送 下面這段代碼是示范如何建立一個(gè)柱圖的: ctB...
Simple Chart Example
使用很簡(jiǎn)單哦,這樣就可以了:
用Server.CreateObject建立對(duì)象
設(shè)置圖表屬性
調(diào)用SaveChart方法保存到硬盤或者用Response.BinaryWrite Chart.Image直接發(fā)送
下面這段代碼是示范如何建立一個(gè)柱圖的:
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
下面這段代碼是示范如何建立多列數(shù)據(jù)的圖表的.
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 '這樣再調(diào)用一次AddSeries就可以再加一列數(shù)據(jù)了
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
(出處:熱點(diǎn)網(wǎng)絡(luò))