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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
| import java.io.File;
import java.io.IOException;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
public class XYChartExample {
public static void main(String[] args) {
// Create a simple XY charts
XYSeries = new XYSeries("");
.add(0, 1);
.add(1, 1);
.add(1.5476 , 0);
XYSeries btl = new XYSeries("Brise très légère");
btl.add(0.4524, 0);
btl.add(1, 1);
btl.add(5, 1);
btl.add(5.37, 0);
XYSeries bl = new XYSeries("Brise légère");
bl.add(4.63, 0);
bl.add(5, 1);
bl.add(11, 1);
bl.add(11.825, 0);
XYSeries pb = new XYSeries("Petite Brise");
pb.add(10.175, 0);
pb.add(11, 1);
pb.add(19, 1);
pb.add(20.406, 0);
XYSeries jb = new XYSeries("Jolie Brise");
jb.add(17.594, 0);
jb.add(19, 1);
jb.add(28, 1);
jb.add(30.072, 0);
// Add the series to your data set
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries();
dataset.addSeries(btl);
dataset.addSeries(bl);
dataset.addSeries(pb);
dataset.addSeries(jb);
// Generate the graph
JFreeChart chart = ChartFactory.createXYLineChart("Fuzzyfication du vent", // Title
"x-axis", // x-axis Label
"y-axis", // y-axis Label
dataset, // Dataset
PlotOrientation.VERTICAL, // Plot Orientation
true, // Show Legend
true, // Use tooltips
false // Configure chart to generate URLs?
);
try {
ChartUtilities.saveChartAsJPEG(new File("C:/chart.jpg"), chart, 800,600);
} catch (IOException e) {
System.err.println("Problem occurred creating chart.");
}
ChartFrame fen = new ChartFrame("Fuzzyfication du vent",chart);
fen.pack();
fen.setLocationRelativeTo(null);
fen.setVisible(true);
}
} |
Partager