MACROMEDIA COLDFUSION 5-DEVELOPING Develop Manual page 95

Table of Contents

Advertisement

Controlling Graph Appearance
2
3
4
5
Edit the GetSalaries query so that it appears as follows:
<!-- Get the raw data from the database. -->
<cfquery name="GetSalaries" datasource="CompanyInfo">
SELECT Departmt.Dept_Name,
Employee.StartDate,
Employee.Salary
FROM Departmt, Employee
WHERE Departmt.Dept_ID = Employee.Dept_ID
</cfquery>
Add the following code before the
<!--- Convert start date to start year. --->
<!--- You must explicitly convert the date to a number for the query
to work --->
<cfloop index="i" from="1" to="#GetSalaries.RecordCount#">
<cfset GetSalaries.StartDate[i]=NumberFormat(DatePart("yyyy",
GetSalaries.StartDate[i]) ,9999)>
</cfloop>
<!--- Query of Queries for average salary by start year --->
<cfquery dbtype = "query" name = "HireSalaries">
SELECT
StartDate,
AVG(Salary) AS AvgByStart
FROM GetSalaries
GROUP BY StartDate
</cfquery>
<!--- Round average salaries to thousands --->
<cfloop index="i" from="1" to="#HireSalaries.RecordCount#">
<cfset
HireSalaries.AvgByStart[i]=Round(HireSalaries.AvgByStart[i]/
1000)*1000>
</cfloop>
Add the following
cfgraph
<!--- Area-style Line graph, from HireSalaries Query of Queries --->
<cfgraph type="line"
query="HireSalaries"
valueColumn="AvgByStart"
itemColumn="StartDate"
title="Average Salaries by Date of Hire"
fileFormat="Flash"
GraphWidth=400
BackgroundColor="##FFFF00"
Depth=5
lineColor="teal"
fill="yes" >
</cfgraph>
<br>
Save the page.
tag:
html
tag before the end of the
tag block.
body
75

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION 5-DEVELOPING and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Coldfusion 5

Table of Contents