User Guide

Table Of Contents
Creating charts: examples 755
Reviewing the code
The following table describes the code and its function:
Setting curve chart characteristics
Curves charts use the attributes already discussed. However, you should be aware that curve charts
require a large amount of processing to render. For fastest performance, create them offline, write
them to a file or variable, and then reference them in your application pages. For information on
creating offline charts, see “Writing a chart to a variable” on page 756.
Code Description
Employee.StartDate,
Add the employee start date to the data in the
GetSalaries query.
<cfloop index="i" from="1"
to="#GetSalaries.RecordCount#">
<cfset GetSalaries.StartDate[i]=
NumberFormat(DatePart("yyyy",
GetSalaries.StartDate[i]) ,9999)>
</cfloop>
Use a cfloop tag to extract the year of hire from each
employee’s hire data, and convert the result to a four-
digit number.
<cfquery dbtype = "query" name =
"HireSalaries">
SELECT
StartDate,
AVG(Salary) AS AvgByStart
FROM GetSalaries
GROUP BY StartDate
</cfquery>
Create a second query from the GetSalaries query.
This query contains the average salary for each start
year.
<cfloop index="i" from="1"
to="#HireSalaries.RecordCount#">
<cfset HireSalaries.AvgByStart[i]
=Round(HireSalaries.AvgByStart[i]
/1000)*1000>
</cfloop>
Round the salaries to the nearest thousand.
<cfchart
chartWidth=400
BackgroundColor="##FFFF00"
show3D="yes" >
<cfchartseries
type="area"
query="HireSalaries"
valueColumn="AvgByStart"
itemColumn="StartDate"
/>
</cfchart>
Create a line chart using the HireSalaries query.
Chart the average salaries against the start date.
Limit the chart width to 400 pixels, show the chart in
three dimensions, and set the background color to
white.