Over a million developers have joined DZone.

Groovy JFreechart builder, working on java.net's groovychart.

DZone's Guide to

Groovy JFreechart builder, working on java.net's groovychart.

· Java Zone
Free Resource

Learn how to troubleshoot and diagnose some of the most common performance issues in Java today. Brought to you in partnership with AppDynamics.

Here is an update to the groovy JFreeChart implementation.

I've decided after a lot of prototyping and experimenting to go with the groovychart implementation on java.net as the base to move forwards from. This implementation is already quite complete, and actually after a bit of refactoring its starting to look quite promising.

Currently, I'm still having problems getting developer access to the groovychart project at java.net. This means that I have taken a snapshot of the code from CVS and am working on that codebase. I've sent out several emails and requests so hopefully that will change soon; as I have nowhere to centrally share the source. Once I get a reply from java.net or host elsewhere I will update this post. Suggestions are most welcome..

In terms of looks, my current example may look like a step backwards if you remember my last presentation, but bear in mind that I have not had time to tidy up the edges yet. Also bear in mind that this chart was built using the groovychart builder, which supports a good percentage of JFreeCharts functionality already.

Here's an example of the source for a pie chart:

import net.java.dev.groovychart.chart.ChartBuilder
import groovy.swing.SwingBuilder
import java.awt.BorderLayout as BL
import javax.swing.JFrame
import java.awt.Color
import java.awt.Dimension
import org.jfree.chart.ChartPanel

ChartBuilder cb = new ChartBuilder();
def pieChart = cb.piechart3d(title: "Simple Pie Chart") {
defaultPieDataset {
antiAlias = true

def sb = new SwingBuilder()
def fr = sb.frame( title : 'Simple Pie Chart', size:[600, 400],
defaultCloseOperation: JFrame.EXIT_ON_CLOSE) {
widget(new ChartPanel(pieChart.chart), constraints: BL.CENTER)

And the above code produced this image:

GroovyChart example


Other notes

  • At the moment there is a slight flaw in the number of slices, I'm working on this..
  • Currently I cannot get write access to groovychart's CVS, therefore the source for above is not yet available. Once this changes I will commit.
  • Bear in mind that this is still a prototype and may take some time to productionize.

Understand the needs and benefits around implementing the right monitoring solution for a growing containerized market. Brought to you in partnership with AppDynamics.


Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}