Cookies

This site uses cookies for functionality, traffic analysis and for targeted advertising. Click the Accept button to accept our Cookie Policy. The Cookie Policy page offers configuration for a reduced set of cookies for this site.

Listing of GIF_BARSBYDAY.ASP

This is a listing of the script that generates a bar chart for each record. The calling page calls this script with a URL variable called "Day", which is used to select the correct record from the database.

The csDrawGraph AddData method is called for each field. The data value is read directly from the database and it is important to use the CInt( ) function to prevent a type mismatch error. It uses all the default property settings which simplifies the script although it could be preferable to specify the top of the YAxis and the graduations (YTop and YGrad) to ensure that each graph uses the same scale.

Set Chart = Server.CreateObject("csDrawGraphTrial.Draw")

DataConnection = "DRIVER={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=" & _
  Server.MapPath("Data.accdb")
Set DBConn = Server.CreateObject("ADODB.Connection")
DBConn.Open DataConnection
Set RS = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT * FROM Table1 WHERE Day=" & Request.QueryString("Day")
RS.Open SQL, DBConn

Chart.AddData "Red", CInt(RS("Red")), "ff0000"
Chart.AddData "Blue", CInt(RS("Blue")), "0000ff"
Chart.AddData "Green", CInt(RS("Green")), "00ff00"
Chart.AddData "Yellow", CInt(RS("Yellow")), "ffff00"
Chart.Title = "Results for day " & Request.QueryString("Day")
Chart.TitleX = 100

RS.Close
DBConn.Close

Response.ContentType = "image/gif"
Response.BinaryWrite Chart.GIFBar

Cookies

This site uses cookies for functionality, traffic analysis and for targeted advertising. Click the Accept button to accept our Cookie Policy. The Cookie Policy page offers configuration for a reduced set of cookies for this site.