ASP Chart 使用範例

來源:互聯網
上載者:User
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:inetpubwwwrootimagessmpchrt1.jpg"
'也不知道用Server.MapPath,不知道是笨呢還是圖效率高。
Chart.SaveChart
Response.Write "<img src=""http://edu.cnzz.cn/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 to30


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


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.