charts4j Overview

charts4j is a Java chart library that enables developers to programmatically generate nearly all 1 the charts available in the Google Chart API . charts4j can be incorporated into any Internet enabled Java (e.g. Swing) or web application environment (e.g. JSPs / Servlets, Spring MVC, GWT, etc.)

### Installation

Developers only need to include the charts4j.jar in their classpath. It is available in the charts4j.zip file. The application must also be connected to the Internet because the charts are ultimately rendered by the Google Chart API server.

### Usage

Developers who are using charts4j for the first time should start off by examining the {@link com.googlecode.charts4j.Data} and {@link com.googlecode.charts4j.DataUtil} classes. Next, they can build charts via the {@link com.googlecode.charts4j.GCharts} static factory class.

All data provided to charts4j is expressed as numbers between 0 and 100. If your data does not fall in that range, you will have to scale it so it does fall in that range. The {@link com.googlecode.charts4j.DataUtil} class can help scale data. Also note that {@link com.googlecode.charts4j.AbstractAxisChart#setGrid(double,double,int,int) grids}, {@link com.googlecode.charts4j.AxisLabelsFactory axis labels positions}, {@link com.googlecode.charts4j.Markers markers} are all expressed in the 0 to 100 range so that chart elements defined by the developer snap together consistently and nicely.

Another interesting feature of charts4j: {@link com.googlecode.charts4j.Plot}s can be incorporated into more than one chart type. In particular, they can be incorporated into

- {@link com.googlecode.charts4j.LineChart}s
- {@link com.googlecode.charts4j.XYLineChart}s
- {@link com.googlecode.charts4j.BarChart}s
- {@link com.googlecode.charts4j.ScatterPlot}s
- {@link com.googlecode.charts4j.RadarChart}s

{@link com.googlecode.charts4j.Plot}s are created via the {@link com.googlecode.charts4j.Plots} static factory class. {@link com.googlecode.charts4j.GChart}s are created via the {@link com.googlecode.charts4j.GCharts} static factory class.

Chart URLs {@link com.googlecode.charts4j.GChart#toURLString() generated} by charts4j can then be incorporated into a web or Internet application. In a JSP / Servlet environment, generate the URL in the servlet and insert that URL in the JSP for display of the chart.

Code examples can be found here .
For additional information, see:

- charts4j
- Google Chart API
- Google Chart API Group

@author Julien Chastang (julien.c.chastang at gmail dot com)

1. As of May 2009, the chart types that are not supported are QR Codes, map pins, sticky notes, information bubbles, text with outline. There are also a few other Google Chart API features that have not been exposed in charts4j. If this is a problem for you please submit an issue, and we will look into it as soon as possible.