JFree Chart Custom Tag up on RiaForge

I finally managed to get around and upload Version 1 of my JFree Chart custom tag onto riaforge.

I typically use the import statement when using custom tags in the below examples I have imported the custom tag line so:


<cfimport taglib="jfreeChart" prefix="jf">
Here are a few screen shots and some example code

Bar Chart



<jf:jfreechart chartType="bar" height="650" width="450" showmarkers="true" showlabels="true" title="Bar Chart Example" categoryAxisLabel="Tasks" categoryValueLabel="Date" createImageMap="true">
    <jf:jfSeries seriesLabel="Series 1" serieslinethickness="3" query="#s1#" itemColumn="column" valueColumn="value" seriesColorHEX='cc0000' colorlist="cc0000,F5A529,999999">
    <jf:jfSeries seriesLabel="Series 2" serieslinethickness="3" query="#s2#" itemColumn="column" valueColumn="value" seriesColorHEX='F5A529' colorlist="cc0000,F5A529,999999">
    <jf:jfSeries seriesLabel="Series 3" serieslinethickness="3" query="#s3#" itemColumn="column" valueColumn="value" seriesColorHEX='999999' colorlist="cc0000,F5A529,999999">
</jf:jfreechart>

Pie Chart



<jf:jfreechart chartType="pie" height="650" width="450" showmarkers="true" showlabels="true" title="Pie Chart Example" categoryAxisLabel="Tasks" categoryValueLabel="Date" createImageMap="true">
    <jf:jfSeries seriesLabel="Pie Series" serieslinethickness="3" query="#s3#" itemColumn="column" valueColumn="value" colorlist="cc0000,F5A529,999999">
</jf:jfreechart>

Scatter Chart



<jf:jfreechart chartType="scatter" height="550" width="450" showmarkers="true" showlabels="true" title="Scatter Chart Example" categoryAxisLabel="Random" categoryValueLabel="values" createImageMap="true">
    <jf:jfSeries seriesLabel="Scatter Series 1" serieslinethickness="3" query="#scatter1#" itemColumn="column" valueColumn="value" colorlist="cc0000,F5A529,999999">
    <jf:jfSeries seriesLabel="Scatter Series 2" serieslinethickness="3" query="#scatter2#" itemColumn="column" valueColumn="value" seriesColorHEX='F5A529' colorlist="cc0000,F5A529,999999">
    <jf:jfSeries seriesLabel="Scatter Series 3" serieslinethickness="3" query="#scatter3#" itemColumn="column" valueColumn="value" seriesColorHEX='F5A529' colorlist="cc0000,F5A529,999999">

</jf:jfreechart>


Gantt Chart



<jf:jfreechart chartType="gantt" height="650" width="450" showmarkers="true" showlabels="true" title="Gantt Chart Example    " categoryAxisLabel="Tasks" categoryValueLabel="Date" createImageMap="true">
    <jf:jfTaskSeries seriesLabel="Project Time Line" serieslinethickness="3" query="#gantt#" startdatecolumn="start" enddatecolumn="end" taskNameColumn="task" PercentCompleteColumn="complete" seriesColorHEX='cc0000' >
</jf:jfreechart>

Related Blog Entries

10 Comments to "JFree Chart Custom Tag up on RiaForge"- Add Yours
PaulH's Gravatar does jfree have high-low stock chart types? what exactly does it buy you over cfchart?
# Posted By PaulH | 2/16/08 5:07 PM
Gary's Gravatar Jfree indeed has high low stock chart types as well. The number of chart
options is really quite good.

What it buys you is an alternative charting option over cfchart. You can of course
access webcharts directly but using cfchart alone you are limited to 11 chart types.

I also decided to build this as a custom component because we are doing a project where we are integrating a Pentaho Reporting solution which, I believe, uses JFree chart as its charting engine.
# Posted By Gary | 2/16/08 1:53 AM
msj's Gravatar Hi,
can jfreechart create time line charts like this:
http://www.timelinemaker.com/product-samplecharts-...

thanks,
MsJ
# Posted By msj | 2/22/08 8:21 AM
PaulH's Gravatar gary,

i think i found a need for jfree chart, though mind if i ask if you've ever mixed graph types (say line & scatter) in the same chart? if so ever used sparse & dense data series? i need to plot a line chart w/2-3k worth of points as well as a scatter plot with only 2 or 3 points. cfchart interpolates the sparse series to match the dense one & borks the graph completely. a job for jfree chart?

thanks.
# Posted By PaulH | 3/31/08 1:07 PM
Gary's Gravatar @ Paul,

Jfree allows you to do overlaid charts which sounds like what you are trying to do.

You can also do multi-axis charts where the 2-3k datapoints can be on one axis, and your 2-3 points on another axis if they have at least one thing in common, if not
then overlaid sounds like the solution.
# Posted By Gary | 3/31/08 1:19 PM
PaulH's Gravatar this example takes a "clever" approach that might do the trick:

http://www.java2s.com/Code/Java/Chart/JFreeChartLi...

turns the lines off to create a "scatter" plot ;-)

btw i'm looking at your code & see "returnChartAsImage" attribute but don't see it used anywhere, am i missing something?

thanks.
# Posted By PaulH | 3/31/08 7:55 PM
Gary Gilbert's Gravatar Paul,

yeah that, well you see the thing is...erm...It's depreciated yeah thats it!

I decided to go with single attribute createImageMap (true/false) if it's false it returns just the
image if its true it returns an image map.

The next update will have that removed as well as provide for a spider chart.
# Posted By Gary Gilbert | 3/31/08 9:16 PM
William Dale's Gravatar I update cf code; added cachedirectory attribute. It now works on CF 8.

Also update line 64 in the jfrrechart.cfm fie where is "desc" not "asc" this way the oldest images are deleted and not the latest. This will prevent deleting images on a rendered pages ie no broken images links...

Great Job on the code.

Thanks.

-- Bill Dale

<cfdirectory action="list" directory="#expandpath(attributes.cacheDirectory)#" name="files" filter="*.png" sort="datelastmodified desc">



<cfset s1 = queryNew("value,column","Integer,VarChar")>
<cfloop from="1" to="5" index="x" step="1">
<cfset newRow = QueryAddRow(s1,1)>
<cfset a = x>
<cfset b = x+2>
<cfset c= x+3>
<cfset temp= querysetcell(s1,'value',#a#)>
<cfset temp= querysetcell(s1,'column',"KW #x#")>
</cfloop>
<cfset s2 = queryNew("value,column","Integer,VarChar")>
<cfloop from="1" to="5" index="x" step="1">
<cfset newRow = QueryAddRow(s2,1)>
<cfset a = x+2>
<cfset temp= querysetcell(s2,'value',#a#)>
<cfset temp= querysetcell(s2,'column',"KW #x#")>
</cfloop>
<cfset s3 = queryNew("value,column","Integer,VarChar")>
<cfloop from="1" to="5" index="x" step="1">
<cfset newRow = QueryAddRow(s3,1)>
<cfset a = x+3>
<cfset temp= querysetcell(s3,'value',#a#)>
<cfset temp= querysetcell(s3,'column',"KW #x#")>
</cfloop>
<!--- scatter graph --->
<cfset scatter1 = queryNew("value,column","Integer,VarChar")>
<cfloop from="1" to="40" index="x" step="1">
<cfset newRow = QueryAddRow(scatter1,1)>
<cfset a = (rand()-0.5)*200>
<cfset b = (rand()+0.5)* 6 * x + x>
<cfset temp= querysetcell(scatter1,'value',#a#)>
<cfset temp= querysetcell(scatter1,'column',"#b#")>
</cfloop>
<cfset scatter2 = queryNew("value,column","Integer,VarChar")>
<cfloop from="1" to="40" index="x" step="1">
<cfset newRow = QueryAddRow(scatter2,1)>
<cfset a = (rand()-0.5)*200>
<cfset b = (rand()+0.5)* 6 * x + x>
<cfset temp= querysetcell(scatter2,'value',#a#)>
<cfset temp= querysetcell(scatter2,'column',"#b#")>
</cfloop>
<cfset scatter3 = queryNew("value,column","Integer,VarChar")>
<cfloop from="1" to="40" index="x" step="1">
<cfset newRow = QueryAddRow(scatter3,1)>
<cfset a = (rand()-0.5)*200>
<cfset b = (rand()+0.5)* 6 * x + x>
<cfset temp= querysetcell(scatter3,'value',#a#)>
<cfset temp= querysetcell(scatter3,'column',"#b#")>
</cfloop>
<cfset taskNames="Write Proposal, Obtain Approval, Requirements Analysis, Requirements 1, Requirements 2,Testing, Final Implementation">
<cfset gantt = queryNew("")>
<cfset tasks =['Write Proposal', 'Obtain Approval', 'Requirements Analysis', 'Requirements 1', 'Requirements 2','Testing', 'Final Implementation']>
<cfset start =['04/01/2008', '04/10/2008', '06/02/2008', '06/03/2008', '08/01/2008','08/10/2008', '09/12/2008']>
<cfset end =['04/09/2008', '05/01/2008', '06/04/2008', '07/30/2008', '08/08/2008','08/10/2008', '10/30/2008']>
<cfset complete =[0.5, 0.74,0, 0, 0,0,1]>
<cfset test=QueryAddColumn(gantt, "task", "VarChar", tasks)>
<cfset test=QueryAddColumn(gantt, "start", "date", start)>
<cfset test=QueryAddColumn(gantt, "end", "date", end)>
<cfset test=QueryAddColumn(gantt, "complete", "decimal", complete)>
<cfimport taglib="jfreeChart" prefix="jf">
<!--- <cfset startDate = createObject("java","java.util.Date").init(s1.start)>--->
<html>
<head>
<title>Jfree Custom Component Examples</title>
</head>
<body>

<jf:jfreechart chartType="gantt" height="650" width="450" showmarkers="true" showlabels="true" title="Gantt Chart Example" categoryAxisLabel="Tasks" categoryValueLabel="Date" createImageMap="true" cachedirectory="\cachedirectory" maxCacheSize="10">
   <jf:jfTaskSeries seriesLabel="Project Time Line" serieslinethickness="3" query="#gantt#" startdatecolumn="start" enddatecolumn="end" taskNameColumn="task" PercentCompleteColumn="complete" seriesColorHEX='cc0000'>
</jf:jfreechart>

<jf:jfreechart chartType="bar" height="650" width="450" showmarkers="true" showlabels="true" title="Bar Chart Example" categoryAxisLabel="Tasks" categoryValueLabel="Date" createImageMap="true" cachedirectory="\cachedirectory" maxCacheSize="10">
<jf:jfSeries seriesLabel="Series 1" serieslinethickness="3" query="#s1#" itemColumn="column" valueColumn="value" seriesColorHEX='cc0000' colorlist="cc0000,F5A529,999999">
<jf:jfSeries seriesLabel="Series 2" serieslinethickness="3" query="#s2#" itemColumn="column" valueColumn="value" seriesColorHEX='F5A529' colorlist="cc0000,F5A529,999999">
<jf:jfSeries seriesLabel="Series 3" serieslinethickness="3" query="#s3#" itemColumn="column" valueColumn="value" seriesColorHEX='999999' colorlist="cc0000,F5A529,999999">
</jf:jfreechart>

<jf:jfreechart chartType="pie" height="650" width="450" showmarkers="true" showlabels="true" title="Pie Chart Example" categoryAxisLabel="Tasks" categoryValueLabel="Date" createImageMap="true" cachedirectory="\cachedirectory" maxCacheSize="10">
<jf:jfSeries seriesLabel="Pie Series" serieslinethickness="3" query="#s3#" itemColumn="column" valueColumn="value" colorlist="cc0000,F5A529,999999">
</jf:jfreechart>

<jf:jfreechart chartType="scatter" height="550" width="450" showmarkers="true" showlabels="true" title="Scatter Chart Example" categoryAxisLabel="Random" categoryValueLabel="values" createImageMap="true" cachedirectory="\cachedirectory" maxCacheSize="10">
<jf:jfSeries seriesLabel="Scatter Series 1" serieslinethickness="3" query="#scatter1#" itemColumn="column" valueColumn="value" colorlist="cc0000,F5A529,999999">
<jf:jfSeries seriesLabel="Scatter Series 2" serieslinethickness="3" query="#scatter2#" itemColumn="column" valueColumn="value" seriesColorHEX='F5A529' colorlist="cc0000,F5A529,999999">
<jf:jfSeries seriesLabel="Scatter Series 3" serieslinethickness="3" query="#scatter3#" itemColumn="column" valueColumn="value" seriesColorHEX='F5A529' colorlist="cc0000,F5A529,999999">
</jf:jfreechart>

</body>
</html>
# Posted By William Dale | 6/19/08 1:34 AM
t's Gravatar For some reason it wont let me import tag library?
# Posted By t | 9/17/08 7:16 PM
Gary Gilbert's Gravatar can you post you code sample or error message or something?
# Posted By Gary Gilbert | 9/18/08 2:46 PM

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 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