ASP Chart Usage Example

Source: Internet
Author: User
Simple Chart Example
It's easy to use Oh, that's it:

Building Objects with Server.CreateObject
Set chart Properties
Call the Savechart method to save to the hard disk or send directly with Response.BinaryWrite chart.image
The following code is a demonstration of how to create a column chart:

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, "Regular", Vbblue
Chart.addvalue 233, "enhanced", vbred
Chart.addvalue, "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"
"Also do not know with Server.MapPath, do not know is stupid or diagram efficiency is high."
Chart.savechart
Response.Write "
REM **********************************************************************
REM * Destroy the object
REM **********************************************************************
Set Chart = Nothing

Multiple Series per Chart
The following code is a diagram that demonstrates how to build multiple columns of data.

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 ' So call again Addseries can add another column of data.
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 (DT) Mod, vbred
Dblopen =dblopen + dblbase
Next

Add a direct output to the browser example:

Response.ContentType = "Image/jpeg"
Dim Chart
Set Chart = Server.CreateObject ("Aspchart.chart")
Chart.addseries (Ctbar)
Chart.addvalue, "Regular", Vbblue
Chart.addvalue 233, "enhanced", vbred
Chart.addvalue, "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


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.