View Javadoc

1   /*
2    * Created on 28/02/2005
3    *
4    */
5   package ecar.grafico;
6   
7   import java.io.File;
8   import java.io.IOException;
9   
10  import org.apache.log4j.Logger;
11  import org.jfree.chart.ChartFactory;
12  import org.jfree.chart.ChartUtilities;
13  import org.jfree.chart.JFreeChart;
14  import org.jfree.data.general.DefaultPieDataset;
15  
16  /**
17   * @author garten
18   */
19  public class GraficoPizza {
20  	
21  	private Logger logger = null;
22  
23      /**
24       * Mostra Grafico Pizza.<br>
25       * 
26       * @author N/C
27       * @since N/C
28       * @version N/C
29       */
30      public GraficoPizza() {
31      	this.logger = Logger.getLogger(this.getClass());
32          JFreeChart grafico;
33          
34          /* declara o dataSet */
35          DefaultPieDataset pieDataset = new DefaultPieDataset();
36          pieDataset.setValue("Java", Integer.valueOf(80));
37          pieDataset.setValue("C++", Integer.valueOf(15));
38          pieDataset.setValue("Php", Integer.valueOf(5));
39  
40          
41          grafico = ChartFactory.createPieChart("Primeiro Grafico",
42          									   pieDataset,
43          									   true,
44          									   true,
45          									   true);
46          
47          try {
48              ChartUtilities.saveChartAsJPEG(new File("/home/felipev/grafico.jpg"), grafico, 500, 300);
49          } catch (IOException e) {
50              this.logger.error(e);
51          }
52      }
53  
54  }