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.
<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 ORDER BY Day
</cfquery>
<cfoutput query="Recordset">
<cfset Chart.AddPoint(#Day#, #Red#, "ff0000", "Red")>
<cfset Chart.AddPoint(#Day#, #Blue#, "0000ff", "Blue")>
<cfset Chart.AddPoint(#Day#, #Green#, "00ff00", "Green")>
<cfset Chart.AddPoint(#Day#, #Yellow#, "ffff00", "Yellow")>
<cfset Chart.AddXValue(#Day#, #DayName#)>
</cfoutput>
<cfset Chart.Title = "All the combined results">
<cfset Chart.TitleX = 100>
<cfset Chart.YAxisText = "Total for each day">
<cfset Chart.OriginY = 220>
<cfset Chart.XOffset = 1>
<cfset Chart.XTop = 7>
<cfset Chart.XGrad = 1>
<cfset Chart.UseXAxisLabels = true>
<cfset Chart.LineWidth = 2>
<cfset Chart.PointSize = 3>
<cfset Chart.PointStyle = 1>
<cfset TempFile = ExpandPath(".") & "\" & CreateUUID() & ".gif">
<cfset Chart.SaveGIFLine(TempFile)>
<cfcontent type="image/gif" deletefile="yes" file=#tempfile#>
© Chestysoft, 2024.