[JFreeChart] Afficher semaine(1 à 52)
Bonjour à tous,
Je développe actuellement une applet java contenant un diagramme de gantt généré par Jfreechart ce qui fonctionne correctement. Maintenant je veux custumiser un peu mon graphique et le forcer à m'afficher mon échelle de temps en semaine et non en moi, ou jour soit S1 | S2 | S3 | ... | S52.
J'ai donc essayé en changeant mon format de date mais j'ai une erreur que je n'arrive pas à résoudre.
Voici mon code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| private JFreeChart createChart(IntervalCategoryDataset dataset) {
JFreeChart chart = ChartFactory.createGanttChart(
"", // chart title
"", // domain axis label (Task)
"", // range axis label (Date)
dataset, // data
false, // include legend
true, // tooltips
false // urls
);
XYPlot plot = chart.getXYPlot();
DateAxis axis = (DateAxis) plot.getDomainAxis();
axis.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 7));
axis.setDateFormatOverride(new SimpleDateFormat("W"));
return chart;
} |
Et voici l'erreur générée :
Code:
1 2 3 4 5
| java.lang.ClassCastException: org.jfree.chart.plot.CategoryPlot
at Graphique.AppletGantt.createChart(AppletGantt.java:106)
at Graphique.AppletGantt.genererGantt(AppletGantt.java:134)
at Graphique.AppletGantt.<init>(AppletGantt.java:248)
at Graphique.AppletGantt.main(AppletGantt.java:252) |
Mon objet chart attend un CategoryPlot qui ne contient malheureusement pas de fonction getDomainAxis() ou équivalent...
Est-ce que quelqu'un peut m'aider à ce sujet ?
Merci d'avance pour vos réponses.