<dependency>
<groupId>org.jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.5.0</version>
</dependency>
1. Creates a line chart (创建折线图)
JFreeChat chart = ChartFactory.createXYLineChart("", "time/min", "", null, PlotOrientation.VERTICAL, false, true, false);
2. Constructs a panel that displays the specified chart (构造用于显示图表的面板)
ChartPanel panel = new ChartPanel(chart);
3. Sets the dataset for the chart (设置图表的数据集)
XYSeriesCollection seriesCollection = new XYSeriesCollection(); // Constructs an empty dataset.
for (int i=0; i<16; i++) {
XYSeries series = new XYSeries(String.valueOf(i)); // Creates a new empty series.
for (int x=0; x<100; x++) {
series.add(x, y); // Adds a data item to the series
}
seriesCollection.addSeries(series); // Adds a series to the collection
}
XYPlot plot = (XYPlot) chart.getPlot(); // the plot of the chart
plot.setDataset(seriesCollection); // Sets the primary dataset for the plot