Integrating JFree Charts

If you haven't heard of JFree charts you should really take a look at what it can do. It's a completely free charting engine written entirely in Java by David Gilbert (no relation, at least none that I know of), and has a heck of a lot of charting options.

I spent a bit of time working with the samples trying to get it to work through Coldfusion and finally had some luck. I have found that trying to integrate complex Java applications in CF is not all that easy as we begin to bump up against some of the limitations of CF.

Firstly forget about trying to use Abstract classes or nested classes they just don't work (at least every way I tried didn't). In the code below I am trying to create a 2D ellipse to add to my data points on the line chart to make the data points more visible. If you do a search for java.awt.geom.Ellipse2D you find two nested classes: Ellipse2D.Double and Ellipse2D.Float. Any attempt to call the Double class as below just up an fails.


createObject("java","java.awt.geom.Ellipse2D").Double(javacast("double",'-5.0'), javacast("double",'-5.0'),javacast("double", '10.0'),javacast("double",'10.0'));

The Double method was not found.

Great! No luck there then....

But other than that, I managed to create a couple sample charts (bar and line) and now just need to wrap the entire process into either a component or custom tag. I am thinking custom tag would be somewhat easier to use instead of a component as the number of attributes available for each series is quite large.

Conversly I could create a Java wrapper class that hides all of the Java complexity from Coldfusion and that way would only need to instantiate my Java class and pass in the appropriate values instead of having to try and mess with nested classes...

Related Blog Entries

3 Comments to "Integrating JFree Charts"- Add Yours
PaulH's Gravatar tried this? seems to work for me.

<cfscript>
   ell=createObject("java","java.awt.geom.Ellipse2D$Double").init(10,10,10,10);
</cfscript>

<cfdump var="#ell#">
# Posted By PaulH | 1/31/08 10:50 AM
Gary Gilbert's Gravatar Erm, no I didn't try with the "$Double", I've only tinkered with Java in the past and had no idea that what you have there was even possible :)

Thanks Paul!
# Posted By Gary Gilbert | 1/31/08 12:39 PM
Chris's Gravatar Thanks for the "$" hint. Where is that documented? I've been Googling for hours, and this blog is the only place I've found that mentions that. It seems like an incredibly obscure "feature".
# Posted By Chris | 6/1/09 4:56 AM

Powered By Railo

Subscribe

Subscribe via RSS
Follow garyrgilbert on Twitter Follow me on Twitter
Or, Receive daily updates via email.

Tags

adobe air ajax apple cf community cfml coldfusion examples ext flash flex google javascript jquery max2007 max2008 misc open source programming railo software technology ui

Recent Entries

No recent entries.

Blogroll

An Architect's View
CFSilence
Rey Bango
TalkingTree

Wish List

My Amazon.com Wish List