1 pièce(s) jointe(s)
JFreeChart pb graduation axe des x
Bonjour
J'édite un graphe (createXYLineChart) représantant des qté par semaine avec JFreeChart et mes pb sont:
comment démarrer l'absisse à 1
que les N° de semaine sont convertis en décimal alors que les données du dataset sont Integer.
Code:
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
|
public static JFreeChart pointXY(String titre, String etiquette_x, String etiquette_y, final XYDataset dataset) {
// creation du graphique
final JFreeChart chart = ChartFactory.createXYLineChart(
titre, // titre
etiquette_x, // étiquette
etiquette_y, // étiquette
dataset, // données
PlotOrientation.VERTICAL,
true,
true,
false
);
// customisation
chart.setBackgroundPaint(Color.white);
chart.getLegend();
// fond
final XYPlot plot = chart.getXYPlot();
plot.setBackgroundPaint(Color.white);
plot.setDomainGridlinePaint(Color.gray);
plot.setRangeGridlinePaint(Color.gray);
// courbes
final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
for(int y=0;y<dataset.getSeriesCount()+1;y++)
{//n° courbe visible
renderer.setSeriesLinesVisible(y, true);
//marqueur visible
renderer.setSeriesShapesVisible(y, false);}
plot.setRenderer(renderer);
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
rangeAxis.setAutoRangeIncludesZero(true);
rangeAxis.setUpperMargin(0.20);
rangeAxis.setLabelAngle(Math.PI / 2.0);
return chart;
} |
Merci