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
| private CategoryDataset createDataset_coutParMois() throws SQLException {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.setValue(Integer.parseInt(jTFCout.getText()), "Mois","Septembre");
dataset.setValue(Integer.parseInt(jTFDepense.getText()), "Mois","Octobre");
dataset.setValue(Integer.parseInt(jTFCoutDep.getText()), "Mois","Novembre");
return dataset;}
private JFreeChart createChart_coutParMois(CategoryDataset dataset) {
JFreeChart chart = ChartFactory.createBarChart(
"Coût / mois", // chart title
"Mois", // domain axis label
"En dinar", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
true, // tooltips?
false // URLs?
);
chart.setBackgroundPaint(Color.white);
CategoryPlot plot = chart.getCategoryPlot();
plot.setBackgroundPaint(Color.lightGray);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
CategoryAxis categoryAxis = plot.getDomainAxis();
BarRenderer renderer = (BarRenderer) plot.getRenderer();
renderer.setDrawBarOutline(false);
GradientPaint gp0 = new GradientPaint(
0.0f, 0.0f, Color.blue,
0.0f, 0.0f, Color.lightGray
);
GradientPaint gp1 = new GradientPaint(
0.0f, 0.0f, Color.green,
0.0f, 0.0f, Color.lightGray
);
GradientPaint gp2 = new GradientPaint(
0.0f, 0.0f, Color.red,
0.0f, 0.0f, Color.lightGray
);
renderer.setSeriesPaint(0, gp0);
renderer.setSeriesPaint(1, gp1);
renderer.setSeriesPaint(2, gp2);
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(
CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)
);
return chart;
} |
Partager