1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| package Chart;
import java.io.File;
import java.io.IOException;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.Plot;
import org.jfree.data.general.DefaultPieDataset;
public class Camembert {
JFreeChart jTest;
DefaultPieDataset dConteneur;
public Camembert()
{
dConteneur = CreateConteneur();
jTest = CreateCamembert(dConteneur);
ExportCamembert(jTest);
}
private static DefaultPieDataset CreateConteneur()
{
DefaultPieDataset union = new DefaultPieDataset();
union.setValue("Sans diplôme",5862);
union.setValue("CEP",4357);
union.setValue("BEPC Brevet",2691);
union.setValue("CAP BEP",9184);
union.setValue("BAC",5850);
union.setValue("BAC +2",5140);
union.setValue("Au delà de BAC +2",4173);
return union;
}
private static JFreeChart CreateCamembert(DefaultPieDataset union)
{
JFreeChart repart = ChartFactory.createPieChart3D("Répartition par type d'études",union,true, true, false);
Plot plot = repart.getPlot();
plot.setBackgroundPaint(null);
return repart;
}
private static void ExportCamembert(JFreeChart repart)
{
try {
ChartUtilities.saveChartAsPNG(new File("WebContent/WEB-INF/images/Histograme.png"), repart, 900, 600);
System.out.println("Image enregistrée");
} catch (IOException e) {}
}
} |
Partager