MACROMEDIA COLDFUSION 5-DEVELOPING Develop Manual page 92

Table of Contents

Advertisement

72
Example: adding a pie chart
The example in the following procedure adds a pie chart to the page.
To create a pie chart:
1
2
3
4
5
Open graphdata.cfm in ColdFusion Studio.
Edit the DeptSalaries query and the
<!--- A query to get statistical data for each department. --->
<cfquery dbtype = "query" name = "DeptSalaries">
SELECT
Dept_Name,
SUM(Salary) AS SumByDept,
AVG(Salary) AS AvgByDept
FROM GetSalaries
GROUP BY Dept_Name
</cfquery>
<!--- Reformat the generated numbers to show only thousands --->
<cfloop index="i" from="1" to="#DeptSalaries.RecordCount#">
<cfset DeptSalaries.SumByDept[i]=Round(DeptSalaries.SumByDept[i]/
1000)*1000>
<cfset DeptSalaries.AvgByDept[i]=Round(DeptSalaries.AvgByDept[i]/
1000)*1000>
</cfloop>
Add the following
cfgraph
<!--- Pie graph, from DeptSalaries Query of Queries --->
<cfgraph type="pie"
query="DeptSalaries"
valueColumn="SumByDept"
itemColumn="Dept_Name"
title="Total Salaries by Department"
titleFont="Times"
showValueLabel="rollover"
valueLabelFont="Times"
borderWidth = 0
backgroundColor = "##CCFFFF"
colorlist="##6666FF,##66FF66,##FF6666,##66CCCC"
LegendFont="Times">
</cfgraph>
<br>
Save the page.
Return to your browser and enter the following URL to view graphdata.cfm:
http://127.0.0.1/myapps/graphdata.cfm
code so that they appear as follows:
cfloop
tag before the end of the body:
Chapter 5 Graphing Data

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