大家好:
我正在使用下面来显示折线图。当我运行下面的代码时,我得到了窗口,但它是空白的并且不显示图表。请帮助我,并告诉我如何使用下面的代码在 html 页面中显示折线图。
import org.jfree.chart.*;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.xy.*;
public class xyLine {
public static void main(String arg[]) {
XYSeries series = new XYSeries("Average Weight");
series.add(20.0, 20.0);
series.add(40.0, 25.0);
series.add(55.0, 50.0);
series.add(70.0, 65.0);
XYDataset xyDataset = new XYSeriesCollection(series);
JFreeChart chart = ChartFactory.createXYLineChart(
"XYLine Chart using JFreeChart", "Age", "Weight",
xyDataset, PlotOrientation.VERTICAL, true, true, false);
ChartFrame frame1 = new ChartFrame("XYLine Chart", chart);
frame1.setVisible(true);
frame1.setSize(300, 300);
}
}