Creating An Area Chart - MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual

Developing coldfusion mx applications
Table of Contents

Advertisement

Reviewing the code
The following table describes the highlighted code and its function:
Code
SUM(Salary) AS SumByDept,
<cfset DeptSalaries.SumByDept[i]=
Round(DeptSalaries.SumByDept[i]/
1000)*1000>
<cfchart
tipStyle="mousedown"
font="Times"
fontBold="yes"
backgroundColor = "##CCFFFF"
show3D="yes"
>
<cfchartseries
type="pie"
query="DeptSalaries"
valueColumn="SumByDept"
itemColumn="Dept_Name"
colorlist=
"##6666FF,##66FF66,##FF6666,##66CCCC"
/>

Creating an area chart

The example in the following procedure adds an area chart showing 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
attributes.
To create an area chart:
Open chartdata.cfm your editor.
1
Edit the GetSalaries query so that it appears as follows:
2
<!-- 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
3
<!--- 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>
634
Chapter 28: Charting and Graphing Data
Description
In the DeptSalaries query, add a SUM aggregation
function to get the sum of all salaries per
department.
In the
cfloop
nearest thousand.
Show a tip only when a user clicks on the chart,
display text in Times Bold font, set the background
color to light blue, and display the chart in 3-D.
Create a pie chart using the SumByDept salary sum
values from the DeptSalares 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 pound
signs prevent ColdFusion from trying to interpret
the color data as variable names.
tag:
html
tag, round the salary sums to the
cfchart

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents