Bonjour,
Comment je pourrai integrer une jfreechart a une jpanel?
Version imprimable
Bonjour,
Comment je pourrai integrer une jfreechart a une jpanel?
Voici mon code:
Il ne marche pas!:aie:Citation:
public NewJFrame() {
initComponents();
XYSeries series = new XYSeries("Average Size");
series.add(20.0, 10.0);
series.add(40.0, 20.0);
series.add(70.0, 50.0);
XYDataset xyDataset = new XYSeriesCollection(series);
JFreeChart chart = ChartFactory.createXYAreaChart("", "", "", xyDataset, PlotOrientation.HORIZONTAL, true, true, true);
ChartPanel crepart = new ChartPanel(chart);
this.jPanel1.add(crepart);
}
Il semble y avoir un problème avec la méthode .add, :(
J'ai tenté un add entre 2 Panel et on se rend facilement compte du problème de la méthode: elle prend les coordonnées du premier Panel puis l'affiche dans le second Panel en conservant les anciennes coordonnées. :calim2:
Pas évident mon charabia, faite un test plutôt...:ccool:
Problème résolu! :mouarf:
Citation:
public NewJFrame() {
initComponents();
this.setSize(800, 600);
this.setLocationRelativeTo(null);
XYSeries series = new XYSeries("Average Size");
series.add(0,0);
series.add(20.0, 10.0);
series.add(40.0, 20.0);
series.add(70.0, 50.0);
XYDataset xyDataset = new XYSeriesCollection(series);
JFreeChart chart = ChartFactory.createXYAreaChart("", "", "", xyDataset, PlotOrientation.HORIZONTAL, true, true, true);
ChartPanel crepart = new ChartPanel(chart);
getContentPane().add(jPanel1);
BoxLayout Box = new BoxLayout(jPanel1, BoxLayout.Y_AXIS);
jPanel1.setLayout(Box);
jPanel1.add(crepart);
}