Ask a Jedi: Having CFCHART Links in a new window

Dez asks:

I have a chart that I want to link to another application in order to drill down further. Do you know how to setup the links within a chart to open into a new window.

Turns out this is rather trivial, and even explained in the docs. CFCHART takes a URL attribute. You can supply a URL to hit along with 3 custom variables: $ITEMLABEL$, $SERIESLABEL$, and $VALUE$. When clicked, the code will translate these three variables based on where you click. What you may not realize is that you can easily use a JavaScript URL:

<cfchart url="javascript:newWin('$ITEMLABEL$','$SERIESLABEL$','$VALUE$')">

In this example, each click will result in a call to newWin, passing the values along:

<script> function newWin(itemlabel,serieslabel,value) { alert(itemlabel + ' ' + serieslabel + ' ' + value); } </script>

In my sample above I just alerted the values, but you could easily open a new window. Or use one of the new ColdFusion 8 Ajax features to load detailed information inside a cfdiv.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Comments