
1000
DEVELOPING
COLDFUSION 9 APPLICATIONS
Working with Documents, Charts, and Reports
Las
t
upda
te
d 8/5/2010
Creating an area chart
The example in the following procedure adds an area chart to the salaries analysis page. The chart shows the average
salary by start date to the salaries analysis page. It shows the use of a second query of queries to generate a new analysis
of the raw data from the GetSalaries query. It also shows the use of additional
cfchart
attributes.
1
Open the chartdata.cfm file in your editor.
2
Edit the GetSalaries query so that it appears as follows:
<!-- Get the raw data from the database. -->
<cfquery name="GetSalaries" datasource="cfdocexamples">
SELECT Departmt.Dept_Name,
Employee.StartDate,
Employee.Salary
FROM Departmt, Employee
WHERE Departmt.Dept_ID = Employee.Dept_ID
</cfquery>
3
Add the following code before the
html
tag:
Code
Description
SUM(Salary) AS SumByDept,
In the DeptSalaries query, add a SUM aggregation function to get the sum of all
salaries per department.
<cfset
DeptSalaries.SumByDept[i]=Round(DeptSalari
es.SumByDept[i]/ 1000)*1000>
In the cfloop tag, round the salary sums to the nearest thousand.
<cfchart
tipStyle="mousedown"
font="Times"
fontsize=14
fontBold="yes"
backgroundColor = "##CCFFFF"
show3D="yes"
>
Show a tip only when a user clicks the chart, display text in Times bold font, set the
background color to light blue, and display the chart in three dimensions.
<cfchartseries
type="pie"
query="DeptSalaries"
valueColumn="SumByDept"
itemColumn="Dept_Name"
colorlist="##6666FF,##66FF66,##FF6666,##66
CCCC"
/>
Create a pie chart using the SumByDept salary sum values from the DeptSalaries
query.
Use the contents of the Dept_Name column for the item labels displayed in the
chart legend.
Get the pie slice colors from a custom list, which uses hexadecimal color numbers.
The double number signs prevent ColdFusion from trying to interpret the color
data as variable names.
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...