这个问题部分与 my previous post关于这个问题有关. 在构建ChartPanel之后我想知道: public ChartPanel buildChart(){ XYSeriesCollection dataset = new XYSeriesCollection();... FreeChart chart = ChartFactory.createXYLineCh
在构建ChartPanel之后我想知道:
public ChartPanel buildChart(){
XYSeriesCollection dataset = new XYSeriesCollection();
...
FreeChart chart = ChartFactory.createXYLineChart("line chart example",
"X", "Y", dataset, PlotOrientation.VERTICAL, true, true, false);
ChartPanel chartPanel = new ChartPanel(chart);
return chartPanel;
}
我可以检索用于生成图表的数据集,但只能引用chartPanel吗?
ChartPanel panel = buildChart(); panel.getDataset; //I'm looking for a way to retrieve the dataset, or XYSeriesCollection..
那可能吗?有人能把我放在正确的方向吗?
提前致谢
最简单的方法是使数据集引用可用于视图,如图7000所示.或者,您可以从ChartPanel向下钻取,如下所示.
ChartPanel chartPanel; JFreeChart chart = chartPanel.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); XYDataset data = plot.getDataset();
