
76
Chapter 5 Graphing Data
6
Return to your browser and enter the following URL to view graphdata.cfm:
http://127.0.0.1/myapps/graphdata.cfm
Reviewing the code
The following table describes the highlighted code and its function:
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
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.
<cfgraph type="line"
query="HireSalaries"
valueColumn="AvgByStart"
itemColumn="StartDate"
Create a line graph using the
HireSalaries query. Graph the average
salaries against the start date.
title="Average Salaries by
Date of Hire"
Title the graph.
fileFormat="Flash"
Send the graph to the user as a Flash
file.
GraphWidth=400
Limit the graph width to 400 pixels.
Generator automatically resizes the
graph’s height to maintain the aspect
ratio.
BackgroundColor="##FFFF00"
Depth=5
lineColor="teal"
Display a 3D graph in teal against a
yellow background.
fill="yes"
Fill the region below the graph to create
an area graph.
Содержание COLDFUSION 5-DEVELOPING
Страница 1: ...Macromedia Incorporated Developing ColdFusion Applications MacroMedia ColdFusion 5 ...
Страница 58: ...38 Chapter 3 Querying a Database ...
Страница 134: ...114 Chapter 7 Updating Your Database ...
Страница 210: ...190 Chapter 10 Reusing Code ...
Страница 232: ...212 Chapter 11 Preventing and Handling Errors ...
Страница 238: ...218 Chapter 12 Using the Application Framework ...
Страница 262: ...242 Chapter 12 Using the Application Framework ...
Страница 278: ...258 Chapter 13 Extending ColdFusion Pages with CFML Scripting ...
Страница 320: ...300 Chapter 15 Indexing and Searching Data ...
Страница 336: ...316 Chapter 16 Sending and Receiving E mail ...
Страница 374: ...354 Chapter 18 Interacting with Remote Servers ...