Recently Susan Davis and I were developing a series of macros to provide the project metrics that are on a typical Project Report Card. These macros are driven by data directly from the Unanet database.
To reproduce the charts that appear on a report card we are using JFreeChart as our rendering tool. JFreeChart is an open source Java chart library. So far, we have found it easy to produce simple graphs using JFreeChart. Be warned however that the documentation for JFreeChart is poor but for only $39.95 you can purchase the JFreeChart developers guide here.
A Simple Example
One of the charts we were interested in creating was a Pie Chart representing Story Progress. This chart would detail story points delivered, in progress and remaining for a given project.
In order to create this simple chart the first step was to create a Dataset. For our pie chart we created a DefaultPieDataset:
DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("Completed", project.getPointsDelivered().doubleValue()); dataset.setValue("In Progress", project.getPointsInProgress().doubleValue()); dataset.setValue("Remaining", project.getPointsRemaining().doubleValue());
The next step was to create the chart itself by asking the ChartFactory for a pie chart and feeding it our dataset as well as parameters for the title, tooltips, legend etc:
JFreeChart chart = ChartFactory.createPieChart(title, dataset, true, false, false);
And voila…here is the result.