Listing of GIF_BARSBYDAY.CFM

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 and the data value is read directly from the database. 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.

<cfcache action="flush">
<cfobject action="create" name="Chart" class="csDrawGraph.Draw">
<cfquery name="Recordset" dbType="dynamic" connectstring="Driver={Microsoft Access Driver (*.mdb)};Dbq=#ExpandPath(".")#\data.mdb">
SELECT * FROM Table1 WHERE Day=#URL.Day#
</cfquery>

<cfoutput query="Recordset">
<cfset Chart.AddData("Red", #Red#, "ff0000")>
<cfset Chart.AddData("Blue", #Blue#, "0000ff")>
<cfset Chart.AddData("Green", #Green#, "00ff00")>
<cfset Chart.AddData("Yellow", #Yellow#, "ffff00")>
</cfoutput>
<cfset Chart.Title = "Results for day " & URL.Day>
<cfset Chart.TitleX = 100>

<cfset TempFile = ExpandPath(".") & "\" & CreateUUID() & ".gif">
<cfset Chart.SaveGIFBar(TempFile)>
<cfcontent type="image/gif" deletefile="yes" file=#tempfile#>