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.
<cfcache action="flush">
<cfswitch expression="#URL.Colour#">
<cfcase value="Red">
<cfset Colour = "ff0000">
</cfcase>
<cfcase value="Green">
<cfset Colour = "00ff00">
</cfcase>
<cfcase value="Blue">
<cfset Colour = "0000ff">
</cfcase>
<cfcase value="Yellow">
<cfset Colour = "ffff00">
</cfcase>
</cfswitch>
<cfobject action="create" name="Chart" class="csDrawGraph.Draw">
<cfquery name="Recordset" dbType="dynamic" connectstring="Driver={Microsoft Access Driver
(*.mdb)};Dbq=#ExpandPath(".")#\data.mdb">
SELECT Day, #URL.Colour# FROM Table1 ORDER BY Day
</cfquery>
<cfswitch expression="#URL.Colour#">
<cfcase value="Red">
<cfoutput query="Recordset"><cfset Chart.AddData(#Day#, #Red#, #Colour#)></cfoutput>
</cfcase>
<cfcase value="Green">
<cfoutput query="Recordset"><cfset Chart.AddData(#Day#, #Green#, #Colour#)></cfoutput>
</cfcase>
<cfcase value="Blue">
<cfoutput query="Recordset"><cfset Chart.AddData(#Day#, #Blue#, #Colour#)></cfoutput>
</cfcase>
<cfcase value="Yellow">
<cfoutput query="Recordset"><cfset Chart.AddData(#Day#, #Yellow#, #Colour#)></cfoutput>
</cfcase>
</cfswitch>
<cfset Chart.Title = "Results for " & URL.Colour>
<cfset Chart.TitleX = 100>
<cfset Chart.Width = 300>
<cfset Chart.MaxX = 220>
<cfset Chart.XAxisText = "Days">
<cfset Chart.YAxisText = "Total">
<cfset Chart.ShowLegend = false>
<cfset Chart.BGColor = "eeeeee">
<cfset Chart.PlotAreaColor = "eeeeee">
<cfset Chart.TitleBGColor = "eeeeee">
<cfset Chart.LabelBGColor = "eeeeee">
<cfset Chart.AxisTextBGColor = "eeeeee">
<cfset TempFile = ExpandPath(".") & "\" & CreateUUID() & ".gif">
<cfset Chart.SaveGIFBar(TempFile)>
<cfcontent type="image/gif" deletefile="yes" file=#tempfile#>
© Chestysoft, 2025.