User Guide

Table Of Contents
760 Chapter 31: Creating Charts and Graphs
Reviewing the code
The following table describes the code and its function:
Part 2: making the chart dynamic
1.
Open chartdata.cfm in your editor.
2.
Edit the cfchart tag for the pie chart so it appears as follows:
<cfchart
font="Times"
fontBold="yes"
backgroundColor="##CCFFFF"
show3D="yes"
url="Salary_Details.cfm?Item=$ITEMLABEL$"
>
<cfchartseries
type="pie"
query="DeptSalaries"
valueColumn="AvgByDept"
Code Description
<cfquery name="GetSalaryDetails"
datasource="cfdocexamples">
SELECT
Departmt.Dept_Name,
Employee.FirstName,
Employee.LastName,
Employee.StartDate,
Employee.Salary,
Employee.Contract
FROM Departmt, Employee
WHERE
Departmt.Dept_Name =
'#URL.Item#'
AND Departmt.Dept_ID =
Employee.Dept_ID
ORDER BY Employee.LastName,
Employee.Firstname
</cfquery>
Get the salary data for the department
whose name was passed in the URL
parameter string. Sort the data by the
employee’s last and first names.
<table border cellspacing=0 cellpadding=5>
<tr>
<th>Employee Name</td>
<th>StartDate</td>
<th>Salary</td>
<th>Contract?</td>
</tr>
<cfoutput query="GetSalaryDetails" >
<tr>
<td>#FirstName# #LastName#</td>
<td>#dateFormat(StartDate,
"mm/dd/yyyy")#</td>
<td>#numberFormat(Salary, "$999,999")#</td>
<td>#Contract#</td>
</tr>
</cfoutput>
</table>
Display the data retrieved by the query
as a table. Format the start date into
standard month/date/year format, and
format the salary with a leading dollar
sign, comma separator, and no decimal
places.