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
|
import org.jfree.data.category.*;
import org.jfree.chart.*;
import org.jfree.chart.plot.*;
import java.awt.Color;
import java.awt.BorderLayout;
public class FrameSyntAchat extends javax.swing.JFrame {
/** Creates new form FrameSyntAchat */
public FrameSyntAchat() {
initComponents();
}
private void jButtonCreerGraphModeleActionPerformed(java.awt.event.ActionEvent evt) {
// creer le dataset
DefaultCategoryDataset barDataset = new DefaultCategoryDataset();
barDataset.setValue(2000,"montantAchat","Cedric");
barDataset.setValue(1000,"montantAchat","Yoann");
// mettre le dataSet dans un graph
JFreeChart barChart = ChartFactory.createBarChart("Sytnhese Achat","Personnes","montantAchat",barDataset,PlotOrientation.VERTICAL,false,true,false);
CategoryPlot barChartCatplot = barChart.getCategoryPlot();
barChartCatplot.setRangeGridlinePaint(Color.ORANGE);
//creer un ChartPanel et l'ajouter au jpanel
ChartPanel barChartPanel = new ChartPanel(barChart);
jPanelGraph.removeAll();
jPanelGraph.add(barChartPanel,BorderLayout.CENTER);
jPanelGraph.validate();
}
public static void main(String args[]) {
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new FrameSyntAchat().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButtonCreerGraphModele;
private javax.swing.JPanel jPanelGraph;
// End of variables declaration
} |
Partager