User Guide

Linking Dynamically from Graphs 79
Reviewing the code
The following table describes the code and its function:
Part 2: Making the graph dynamic
1 Open graphdata.cfm in ColdFusion Studio.
2 Edit the
cfgraph tag for the pie chart so it appears as follows:
<cfgraph type="pie"
query="DeptSalaries"
valueColumn="SumByDept"
itemColumn="Dept_Name"
URL="Salary_Details.cfm?Dept_Name="
URLColumn="Dept_Name"
Code Description
<cfquery name="GetSalaryDetails"
datasource="CompanyInfo">
SELECT
Departmt.Dept_Name,
Employee.FirstName,
Employee.LastName,
Employee.StartDate,
Employee.Salary,
Employee.Contract
FROM Departmt, Employee
WHERE
Departmt.Dept_Name =
#URL.Dept_Name#
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 employees 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.