User Guide

Table Of Contents
Charting data 737
valueColumn="AvgByDept"
itemColumn="Dept_Name"
/>
</cfchart>
This example displays the values in the AvgByDept column of the DataTable query. It displays the
Dept_Name column value as the item label by each bar.
The following table lists the attributes of the
cfchartseries tag that you use when working with
queries:
Charting a query of queries
In addition to charting the results of a query, you can also chart the results of a queries of queries.
For more information about using query of queries, see Chapter 22, “Using Query of Queries,
on page 489. Query of queries provides significant power in generating the data for the chart. For
example, you can use aggregating functions such as SUM, AVG, and GROUP BY to create a
query of queries with statistical data based on a raw database query. For more information, see
Chapter 22, “Using Query of Queries,” on page 489.
You can also take advantage of the ability to dynamically reference and modify query data. For
example, you can loop through the entries in a query column and reformat the data to show
whole dollar values.
The example in the following procedure analyzes the salary data in the cfdocexamples database
using a query of queries, and displays the data as a bar chart.
To chart a query of queries:
1.
Create a new ColdFusion page with the following content:
<!-- Get the raw data from the database. -->
<cfquery name="GetSalaries" datasource="cfdocexamples">
SELECT Departmt.Dept_Name,
Employee.Salary
FROM Departmt, Employee
WHERE Departmt.Dept_ID = Employee.Dept_ID
</cfquery>
<!-- Generate a query with statistical data for each department. -->
<cfquery dbtype = "query" name = "DeptSalaries">
SELECT
Dept_Name,
AVG(Salary) AS AvgByDept
FROM GetSalaries
Attribute Description
query
The query that contains the data. You must also specify the valueColumn and
itemColumn.
valueColumn
The query column that contains the values to be charted.
itemColumn
The query column that contains the description for this data point. The item
normally appears on the horizontal axis of bar and line charts, on the vertical axis
of horizontalbar charts, and in the legend in pie charts.