Search code examples
javapie-chart

Creating pie charts programmatically


How can I programmatically generate pie charts from java? I have some data that is processed by a program, then I want to create an image file (PNG, GIF, etc) that has a pie chart. Is there a library that does this, or at least which I can use to do this?

Alternately, would it be better to use a library that will draw pie charts in a JFrame and then somehow automatically screenshot those?


Solution

  • JFreeChart can generate pie charts and can save the resultant chart to JPEG format. Here is an example of how to do so. Here is a 3D example.

    There are more examples and documentation available in the developers guide.

    Other charting libraries which generate piecharts: