Listing of GIF_BARSBYCOLOUR.ASPX

This is a listing of most of the script that produces all 4 bar charts. The calling page has 4 <img> tags, each calls this script with a URL variable called "Colour". This script uses that URL variable to determine the bar colours and also to construct the SQL statement that reads the database. That is how 4 different graphs are produced from one script.

The images produced have a smaller width than default and a number of component properties are changed to allow for this. Also the background colour is a light grey and this value must be used for the background of the different text items.

Dim Colour As String
Select Case Request.QueryString("Colour")
  Case "Red" : Colour = "ff0000"
  Case "Blue" : Colour = "0000ff"
  Case "Green" : Colour = "00ff00"
  Case "Yellow" : Colour = "ffff00"
End Select

Dim Graph As New GraphClass

Dim AConnection As OleDbConnection = _
 New OleDbConnection("PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" &_
 Server.Mappath("data.mdb"))
Dim ACommand As OleDbCommand = New OleDbCommand("SELECT Day, " &_
 Request.QueryString("Colour") & " FROM Table1 ORDER BY Day", AConnection)
AConnection.Open
Dim DataReader As OleDbDataReader = ACommand.ExecuteReader

'The day, the value and the colour are added for each record
'The data value is read using DataReader.Item(1) because it is the second
'field in the recordset

While DataReader.Read
  Graph.AddData(DataReader.Item("Day"), DataReader.Item(1), Colour)
End While

AConnection.Close

Graph.Title = "Results for " & Request.QueryString("Colour")
Graph.TitleX = 100
Graph.Width = 300
Graph.MaxX = 220
Graph.XAxisText = "Days"
Graph.YAxisText = "Total"
Graph.ShowLegend = false
Graph.BGColor = "eeeeee"
Graph.PlotAreaColor = "eeeeee"
Graph.TitleBGColor = "eeeeee"
Graph.LabelBGColor = "eeeeee"
Graph.AxisTextBGColor = "eeeeee"
Graph.GraphType = 1

Graph.GraphToBrowser(1)