In ColdFusion 5, one of the biggest
complaints about the
cfgraph tag was its inability
to graph more than a single series of data. For many developers
looking to use ColdFusion for creating graphical representations of
their data, this limitation was a disappointment. The engineers at
Macromedia took this to heart when integrating ColdFusion
MX’s new charting engine used by
As I mentioned earlier in the chapter, the
tag is capable of graphing up to 16 different series of data in a
single chart. When graphing more than one series of data, you can mix
and match chart types, with one exception. If you choose to create a
pie chart, it can contain only one series of data, and
it’s not possible to have both a pie chart and
another chart type overlaid.
Consider the need to graph both the average salary in each department
and the maximum salary in each department. You can write a single
query to return both the average salary and the maximum salary for
each department using the
AVG( ) and
) aggregate functions discussed in Chapter 11. Example 17-4 shows the code
for the query as well as the code for generating both data series.
Example 17-4. Graphing more than one data series
<cfquery name="GetSalary" datasource="ProgrammingCF"> SELECT Department, AVG(Salary) AS AvgSalary, MAX(Salary) AS MaxSalary FROM EmployeeDirectory GROUP BY Department </cfquery> <h3>Average vs. Max Salary by Department</h3> <cfchart format="Flash" chartheight="360" ...