This asset creates a pie for the data given. The pie chart depicts the no: of Jobs in each status. Each job is coloured specifically based on its status and the area of the sector is proportional to no. of jobs in particular status.
import java.awt.Color; import java.awt.Font; import java.io.File; import java.io.IOException; import org.jfree.chart.ChartRenderingInfo; import org.jfree.chart.ChartUtilities; import org.jfree.chart.JFreeChart; import org.jfree.chart.entity.StandardEntityCollection; import org.jfree.chart.plot.PiePlot; import org.jfree.data.general.DefaultPieDataset; import org.jfree.ui.RectangleInsets; public class Sample { public static void main(String args[]){ DefaultPieDataset pieDataset = new DefaultPieDataset(); pieDataset.setValue("SUCCESS", new Integer(5)); pieDataset.setValue("FAILED", new Integer(1)); pieDataset.setValue("RUNNING", new Integer(2)); pieDataset.setValue("NOT_STARTED", new Integer(4)); pieDataset.setValue("HANGING", new Integer(3)); final PiePlot jobStatusPlot = new PiePlot(pieDataset); Font font=new Font("Arial Bold", 5, 11); jobStatusPlot.setLabelBackgroundPaint(Color.PINK); jobStatusPlot.setLabelPaint(Color.BLACK); jobStatusPlot.setLabelFont(font); RectangleInsets padding=new RectangleInsets(3, 10, 5, 10); jobStatusPlot.setLabelPadding(padding); jobStatusPlot.setSectionPaint("SUCCESS", Color.GREEN); jobStatusPlot.setSectionPaint("FAILED", Color.RED); jobStatusPlot.setSectionPaint("RUNNING", Color.ORANGE); jobStatusPlot.setSectionPaint("NOT_STARTED", Color.YELLOW); jobStatusPlot.setSectionPaint("HANGING", Color.RED); JFreeChart chart = new JFreeChart("Job Status Chart", JFreeChart.DEFAULT_TITLE_FONT, jobStatusPlot, true); chart.setBackgroundPaint(java.awt.Color.white); try { final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File pieChartImage = new File(JobStatusConstants.CHART_PATH); ChartUtilities.saveChartAsPNG(pieChartImage, chart, 500, 500, info); } catch (IOException e) { System.out.println(e.toString()); } } }