Listing of GIF_LINES.ASP

This is a listing of most of the script that produces the line graph. It generates a line graph using all the data from the database. Instead of showing numbers along the x-axis it uses the names of the days.

Some of the component properties need to be set to calibrate the axes and set the sizes of the lines and the points. Calibrating the x-axis manually is usually required when text is used instead of the numeric values. The origin is moved upwards to allow room for the day names.

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 ORDER BY Day"
RS.Open SQL, DBConn

While Not RS.Eof
  Chart.AddPoint CInt(RS("Day")), CInt(RS("Red")), "ff0000", "Red"
  Chart.AddPoint CInt(RS("Day")), CInt(RS("Blue")), "0000ff", "Blue"
  Chart.AddPoint CInt(RS("Day")), CInt(RS("Green")), "00ff00", "Green"
  Chart.AddPoint CInt(RS("Day")), CInt(RS("Yellow")), "ffff00", "Yellow"
  Chart.AddXValue CInt(RS("Day")), RS("DayName")
  RS.MoveNext
Wend

RS.Close
DBConn.Close

Chart.Title = "All the combined results"
Chart.TitleX = 100
Chart.YAxisText = "Total for each day"
Chart.OriginY = 220
Chart.XOffset = 1
Chart.XTop = 7
Chart.XGrad = 1
Chart.UseXAxisLabels = true
Chart.LineWidth = 2
Chart.PointSize = 3
Chart.PointStyle = 1

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

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.