Tuesday, March 3, 2009

jfcTags is out

jfcTags 0.4 is released (alpha release) under LGPL license and you can download it here .

So what is jfcTags?
It is an easy way to build charts in web applications by defining the charts using jfcTags tag library. The goal was to make it easy for web developers to use jfreeChart charting library. Using it the traditional way was, lets say, a decent amount of work per chart, and if you are making an application with many charts, writing that many servlets can be daunting, not to mention all the chart display properties would be compiled in. So I decided to make it easy on myself and wrote this library and I thought to share with others in the open source community. So, how do you build charts?

Lets say, you have a JFreeChart PieDataset 'chartData' in request scope, and you want to build a pie chart. Here is how you would do it.

1. set it up
a. Include jfcTags and JFreeChart jar files and all the JFreeChart dependencies.
b. define jfcTags chart servlet in web.xml
<servlet>
<servlet-name>chart</servlet-name>
<servlet-class>
com.logific.jfctags.servlet.ChartServlet
</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>chart</servlet-name>
<url-pattern>
/chart/*
</url-pattern>
</servlet-mapping>
2. use it
a. Include jfcTags taglib declaration
<%@ taglib prefix="jfct" uri="http://www.logific.com/jfctags" %>
b. Define chart
<jfct:chart chartservletmapping="/chart"
id="pieChartStrData"
charttype="p"
dataset="${chartData}"
width="360"
height="300"
title="Coffee Pie Chart"
sectionpaintlist="#FFB728|#FF5432|#2889FF"
plotbackgroundpaint="#fdfdfd"
backgroundpaint="#ffffff"
generateurls="true"
imagecssclass="noborder"
urlprefix="/pieDetail.jsp"
urlcategoryparamname="beverageName"
urlindexparamname="pieIndex"
maximumlabelwidth="20"
valueformat="percent"
valueformatstring="#0.00%"
labelfont="helvetica"
labelpaint="#679ed2"
labelbackgroundpaint="#feeffe">
</jfct:chart>
This generates the following chart.

To make this post short, I'll just mention some other features:
  • Supply data to chart using JFreeChart Datasets or String based formatted data
  • URL support with Drill down capabilities
  • ToolTips support
  • Currently supports Pie, 3D Pie, Line, Bar and Stacked Bar charts
This release package contains:
  1. jfcTags tag library jar file
  2. jfcTags-sample-webapp war file
  3. jfcTags user guide and tag library reference pdf.
Download it. Try it. Provide your valuable feedback here.

No comments:

Post a Comment