Introduction

ChartCreator is a custom JSF component and serves for creating charts in JSF pages. Currently 27 types of charts are supported.

Dependencies

ChartCreator depends on JFreeChart library for rendering of the charts. As a transitive dependency JFreeChart uses JCommon library. Versions jfreechart 1.0.5 and jcommon-1.0.9 are suggested to be used with chartcreator-1.2.0-M2.

JFreeChart and JCommon
JFreeChart 1.0.5

In addition to the libraries of JSF implementation;

chartcreator-x.x.x.jar
jfreechart-1.0.5.jar
jcommon-1.0.9.jar

Installation and Configuration

Charts are either generated by a servlet called chartlet(by default) or a phaselistener. It can be configured by a context param.

<context-param>
	<param-name>net.sf.jsfcomp.chartcreator.USE_CHARTLET</param-name>
	<param-value>true</param-value>
</context-param>
				

Chartlet

Chartlet config must be done in web.xml if the servlet will be used for the chart creation

<servlet>
	<servlet-name>Chartlet</servlet-name>
	<servlet-class>net.sf.jsfcomp.chartcreator.Chartlet</servlet-class>
</servlet>
	
<servlet-mapping>
	<servlet-name>Chartlet</servlet-name>
	<url-pattern>*.chart</url-pattern>
</servlet-mapping>
				

ChartListener

ChartListener is a special phaselistener that can be used to generate the charts instead of a servlet, it does not require any configuration other then setting the USE_CHARTLET context param to false

Taglib/Namespace

If you're using JSP as the view definition of JSF pages,following taglib must be added to the page. Facelets users should check out the Facelets section

<%@ taglib uri="http://sourceforge.net/projects/jsf-comp" prefix="c" %>				
				

QuickStart Example

An example pie chart

public DefaultPieDataset getPieDataSet() {
DefaultPieDataset pieDataSet = new
DefaultPieDataset();
pieDataSet.setValue("A",52);
pieDataSet.setValue("B", 18);
pieDataSet.setValue("C", 30); return pieDataSet;
}
				

The code in the jsf page

<c:chart id="chart1" datasource="#{YourManagedBeanName.pieDataSet}" type="pie" is3d="true" antialias="true" title="Example Chart" xlabel="X Label" ylabel="Y Label" height="300" width="400"></c:chart>

Facelets

Facelets taglib file is included in the chartcreator distribution, after getting it you need to point facelets to the chartcreator taglib

<context-param>
	<param-name>facelets.LIBRARIES</param-name>
	<param-value>/WEB-INF/chartcreator.taglib.xml</param-value>
</context-param>
			

Remaining thing is to include the xml namespace, a complete example

<html xmlns="http://www.w3.org/1999/xhtml" 
        xmlns:ui="http://java.sun.com/jsf/facelets" 
        xmlns:h="http://java.sun.com/jsf/html" 
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:c="http://sourceforge.net/projects/jsf-comp" 
>
			

TLD and API Docs

TLD Documentation is the guide the attributes used for customizing the charts

API Documentation is also available

F.A.Q.

1) Is there a downloadable web application as an example?

Yes, in the jsf-comp download section. Contains many examples and also the sources are also included to demonstrate how the component is used.
				

2) What is the other chartAxis component?

ChartAxis is used as a child of chartcreator and it helps to customize a single axis(domain or range). See the example webapp for more info.

3) Is it possible click and attach events on chart sections?

Yes, there's an example bar chart in demo webapp that uses the generateMap attribute to automatically create clickable sections

Support

JSF Chart Creator has a support forum at JFreeChart's official forum. Please point your questions to;

Older Releases

Latest version is 1.2.0-M2 and the only difference between M1 and M2 is the jdk compliance, M1 has an ugly issue causing it to work only with Java6, M2 release fixes this and is compatible with Java 1.4+.

Team

Founder

Cagatay Civici, blog at JRoller

Committers

Cagatay Civici

Rogerio Araujo

Contributors

Paulo Schlup Santos