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
| private JFreeChart createChart(XYDataset dataset) {
// create the chart...
JFreeChart chart = ChartFactory.createXYLineChart(
("Mesure du champ éléctrique (KV/m) dans le temps"), // chart title
"X", // x axis label
"Y", // y axis label
dataset, // data
PlotOrientation.VERTICAL,
true, // include legend
true, // tooltips
false // urls
);
chart.setBackgroundPaint(Color.white);
plot = chart.getXYPlot();
plot.setBackgroundPaint(Color.lightGray);
plot.addDomainMarker(new IntervalMarker(100, 60, Color.red));
plot.addDomainMarker(new IntervalMarker(60, 40, Color.orange));
plot.addDomainMarker(new IntervalMarker(40, 20, Color.yellow));
plot.addDomainMarker(new IntervalMarker(-20, 20, Color.green));
plot.addDomainMarker(new IntervalMarker(-40, -20, Color.yellow));
plot.addDomainMarker(new IntervalMarker(-60, -40, Color.orange));
plot.addDomainMarker(new IntervalMarker(-100, -60, Color.red));
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
return chart;
} |
Partager