Chapter 24. Graphing and Charting

ColdFusion 5.0 provides you with a new way of looking at data, literally, in the form of a server-side graphing engine comprised of Macromedia’s JRun and Generator servers.[22] These servers, combined with the new CFGRAPH and CFGRAPHDATA tags allow you to add new charting and graphing capabilities to your ColdFusion applications.

Five types of graphs and charts are supported with this release of ColdFusion. They are bar and horizontal bar charts, line and area graphs, and pie charts. The CFGRAPH tag can generate graphs in Macromedia’s popular Flash format, as PNG images or as JPEG images. You can use the CFGRAPH and CFGRAPHDATA tags to graph static values, query data, or a combination of the two.

Creating a Simple Graph

Regardless of the type of graph you want to create, all graphing is handled via the CFGRAPH tag. The CFGRAPH tag is a paired tag, meaning it must always have opening and closing tags. To create a graph of any type from static data, you need to include one or more CFGRAPHDATA tags between your beginning and ending CFGRAPH tags. Example 24-1 shows how to generate a bar chart from static data.

Example 24-1. Simple Graphs

<CFGRAPH TYPE="Bar" FILEFORMAT="Flash" GRAPHHEIGHT="300" GRAPHWIDTH="400" BACKGROUNDCOLOR="White" BORDERWIDTH="1" BORDERCOLOR="Black" DEPTH="10" TITLE="Employee Salaries" TITLEFONT="Arial"> <CFGRAPHDATA ITEM="Greg" VALUE="96000" COLOR="Red" URL="http://www.example.com/index.cfm?ID=1"> <CFGRAPHDATA ITEM="Nick" ...

Get Programming ColdFusion now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.