如何在JFreeChart的同一帧中放置更多图形?

时间:2018-09-20 15:13:39

标签: java jfreechart

我有以下代码,使用Java库JFreeChart生成了一个极坐标图。但是,我希望有四个图表作为以下图形,但是所有在同一框架中的图形不能分开。我该怎么办?

public class PolarChart extends ApplicationFrame {

public PolarChart(String titel) {
super(titel);

XYDataset dataset = createDataset();
JFreeChart chart = createChart(dataset);

ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(600, 600));
setContentPane(chartPanel);
}
private XYDataset createDataset() {
final XYSeriesCollection data = new XYSeriesCollection();
XYSeries series = new XYSeries("Average Size");
series.add(45, 40.0);
series.add(135.0, 45.0);
series.add(270.0, 40.0);
data.addSeries(series);
return data;
}
private JFreeChart createChart(XYDataset dataset) {
JFreeChart chart = ChartFactory.createPolarChart(
"Polar Chart", dataset, true, true, false
); 
return chart;
}
public static void main(final String[] args) {
PolarChart chart = new PolarChart("Polar Chart");
chart.pack();
RefineryUtilities.centerFrameOnScreen(chart);
chart.setVisible(true);
}

}

enter image description here

0 个答案:

没有答案