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
| public static void setGraphe(int nbcourbe,String[] nomCourbe){
double x=0;
double y=0;
XYSeries []series=new XYSeries[nbcourbe];
for (int j=0;j<nbcourbe;j++){
series[j] = new XYSeries(nomCourbe[j]);
for (int i=0;i<100;i++){
x=j*Math.pow(i, 3)*Math.random();
y=j*Math.pow(i, 5)*Math.random();
series[j].add(x,y);}
}
XYSeriesCollection dataset=new XYSeriesCollection();
for (int j=0;j<nbcourbe;j++)
dataset.addSeries(series[j]);
JFreeChart chart2 = ChartFactory.createXYLineChart(
"dessin 2",
"x",
"y",
dataset,
PlotOrientation.VERTICAL,
true,
true,
false);
//creation de la fenetre
ChartPanel dessin1=new ChartPanel(chart2);
JFrame fenetre =new JFrame("fenetre dessin");
GridLayout gr=new GridLayout(1,1);
fenetre.setVisible(true);
fenetre.setSize(500, 500);
JPanel panneau =new JPanel();
panneau.setLayout(gr);
panneau.add(dessin1);
fenetre.add(panneau);
} |
Partager