User Guide

Linking Dynamically from Graphs 77
Linking Dynamically from Graphs
You can make Flash-format bar and pie charts interactive so that ColdFusion
displays a new data pointspecific Web page when the user clicks a bar or pie wedge.
ColdFusion provides two methods for specifying the destination page:
For data points from queries, ColdFusion takes the value of the
cfgraph URL
attribute, appends the value of the query column specified by the
URLColumn
attribute, and sends the resulting Web request.
For data points from
cfgraphdata tags, ColdFusion uses the value of the tags
URL attribute as the page to link to.
Using ColdFusion you can combine a static URL component with a query column
component. This lets you link dynamically based on query column data without
having to format the column contents as a URL. For example, you can use the values
of the Dept_Name field in the CompanyInfo database to determine the data to
display. To do this, follow these guidelines:
In the cfgraph tag, specify a single Web page in the URL attribute.
In the URL attribute, include the name of a parameter, but not its value, in the
form ParameterName
=
In the URLColumn attribute, specify a query column that contains the value of the
parameter being passed.
In the target page, determine the data to be displayed based on the parameter
that gets passed.
The example code in the following procedure illustrates this technique.
Example: dynamically linking from a pie chart
In the following example, when you click a pie wedge, ColdFusion displays a table
containing the detailed salary information for the departments represented by the
wedge. The example is divided into two parts: creating the detail page and making
the graph dynamic.
Part 1: Creating the detail page
1 Create a new application page in ColdFusion Studio.
This page displays the drill-down information on the selected department based
on the department name passed as the URL parameter.
2 Edit the page so that it appears as follows:
<cfquery name="GetSalaryDetails" datasource="CompanyInfo">
SELECT Departmt.Dept_Name,
Employee.FirstName,
Employee.LastName,
Employee.StartDate,
Employee.Salary,
Employee.Contract
FROM Departmt, Employee
WHERE Departmt.Dept_Name = #URL.Dept_Name#
AND Departmt.Dept_ID = Employee.Dept_ID