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=""/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
