|
|
Create Pie Chart | jfreechart | dashboards
In order to create a Pie Chart, your SQL should return two columns as shown below   select account , sum(amount) as Expense from [qb_data$] where "Account Type" = 'Expense' and date between #10/1/2007# and #05/23/2008# and class like '%' group by account  
  In the above SQL, account is the base column and Expense is the column on which the pie sections are created.   When you create the pie chart the first time, it appears in the default look and feel
  You can change the look and feel by manipulating the java script   //import the necessary classes import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.PiePlot; import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
plot =((PiePlot) chart.getPlot());   /* by setting the alpha setting you can add transparency to the pie chart, the values should be between 0.1f to 0.9f */ plot.setForegroundAlpha(0.5f);
//chart.setBackgroundPaint(new GradientPaint(0,0,Color.white,0,displayFrame.getHeight(), Color.white));
float h = displayFrame.getHeight(); float w = displayFrame.getWidth(); GradientPaint gradientPaint = new GradientPaint(0.0F, 10.0F, Color.white, 0, h, Color.cyan); plot.setBackgroundPaint(gradientPaint); chart.getTitle().setPaint(Color.blue);
/* This piece of code indicates the format to use for the labels in the Pie Chart for e.g 15% 6413 Officers Salary = 25,465.07 */ plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{2} {0}={1}")); | ||||||||||||||||||||||||||||||||
|