22.08.2013 Views

ColdFusion Developer's Guide

ColdFusion Developer's Guide

ColdFusion Developer's Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta<br />

query="DataTable"<br />

valueColumn="AvgByDept"<br />

itemColumn="Dept_Name"<br />

/><br />

<br />

This example displays the values in the AvgByDept column of the DataTable query. It displays<br />

the Dept_Name column value as the item label by each bar.<br />

The following table lists the attributes of the cfchartseries tag that you use when working<br />

with queries:<br />

Attribute Description<br />

query The query that contains the data. You must also specify the valueColumn<br />

and itemColumn.<br />

valueColumn The query column that contains the values to be charted.<br />

itemColumn The query column that contains the description for this data point. The<br />

item normally appears on the horizontal axis of bar and line charts, on the<br />

vertical axis of horizontalbar charts, and in the legend in pie charts.<br />

Charting a query of queries<br />

In addition to charting the results of a query, you can also chart the results of a queries of<br />

queries. For more information about using query of queries, see Chapter 24, “Using Query of<br />

Queries.” Query of queries provides significant power in generating the data for the chart. For<br />

example, you can use aggregating functions such as SUM, AVG, and GROUP BY to create a<br />

query of queries with statistical data based on a raw database query. For more information, see<br />

Chapter 24, “Using Query of Queries.”<br />

You can also take advantage of the ability to dynamically reference and modify query data. For<br />

example, you can loop through the entries in a query column and reformat the data to show<br />

whole dollar values.<br />

The example in the following procedure analyzes the salary data in the cfdocexamples<br />

database using a query of queries, and displays the data as a bar chart.<br />

To chart a query of queries:<br />

1. Create a new <strong>ColdFusion</strong> page with the following content:<br />

<br />

<br />

SELECT Departmt.Dept_Name,<br />

Employee.Salary<br />

FROM Departmt, Employee<br />

WHERE Departmt.Dept_ID = Employee.Dept_ID<br />

1120 Creating Charts and Graphs

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!