I had some time to kill today and I decide to mix cfchart up with some jQuery love. You can see the demo of this here. When the chart loads, click on the bars, and you will see a detail load beneath the graph.

The code behind this is fairly trivial. I've got a file I include to generate my chart data. Normally this would be a proper database query. The main template's code consists of:
<cfinclude template="data.cfm">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
function loadData(l) {
$("#detail").load('detail.cfm?name='+escape(l)).hide().fadeIn('slow')
}
</script>
<cfchart chartWidth="500" chartHeight="250" format="flash" url="javascript:loadData('$ITEMLABEL$')">
<cfchartseries type="bar" query="data" itemcolumn="name" valuecolumn="sales" />
</cfchart>
<div id="detail" style="width:500"></div>
The cfchart makes use of the url attribute to specify what should happen when you click. In this case, I'm simply calling a function, loadData(). This then uses jQuery to make a remote call to detail.cfm. Note that I pass the name. Normally you would pass a primary key, but we don't have (easy) access to that (see this entry for more info) value so we have to work with the name instead. That's it. All detail.cfm does is look up the detail information:
<cfinclude template="data.cfm">
<cfparam name="url.name" default="">
<!--- get detail based on label --->
<cfquery name="detail" dbtype="query">
select *
from data
where name = <cfqueryparam cfsqltype="cf_sql_varchar" value="#url.name#">
</cfquery>
<cfif detail.recordCount is 1>
<cfoutput>
<h2>#url.name#</h2>
<p>
Founded: #detail.yearfounded#<br/>
Sales: #dollarFormat(detail.sales)#<br/>
#paragraphFormat(detail.bio)#
</cfoutput>
</cfif>
Not terribly useful I guess, but fun.
Archived Comments
So strange. Demo wasn't working for me at all until I enabled Firebug. o_O
Yeah, if I disable firebug... it stops working again. o_O
Weird. I specifically removed the console.log message for folks who don't have Firebug.
Oh shoot. Caching. I'm clearing the cache now.
Should be ok now. Thanks for the warning!
Ray, I'm not sure why your in the coding business. Nukes and Burgers would be a great burger joint!
"nuke burger"
It doesn't seem to work for me in Firefox either.
Works fine for me in FF 3.0.10 with or without Firebug turned on.
That's the same version I am using. Weird. Maybe I need a reboot.