O'Reilly logo

PrimeFaces Beginner's Guide by K. Siva Prasad Reddy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – creating a Pie chart using the JFreeChart API

In this section, we will demonstrate how to create a Pie chart using the JFreeChart API and rendering it using the <p:graphicImage> and StreamedContent API.

  1. Create a Pie chart using the JFreeChart API and attach the PrimeFaces StreamedContent to a stream-generated chart image.
    import java.io.File; import java.io.FileInputStream; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartUtilities; import org.jfree.chart.JFreeChart; import org.jfree.data.general.DefaultPieDataset; import org.jfree.data.general.PieDataset; import org.primefaces.model.DefaultStreamedContent; import org.primefaces.model.StreamedContent; public StreamedContent getJfreeChart() { StreamedContent content ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required