Get a dataset that has only a ChartPanel link (Java + JFreeChart)

This question is partially related to my previous post on this topic.

I would like to know after creating a 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; } 

Is it possible to get a dataset used to create a chart, but with only a link to chartPanel?

 ChartPanel panel = buildChart(); panel.getDataset; //I'm looking for a way to retrieve the dataset, or XYSeriesCollection.. 

Is it possible? Can someone put me in the right direction?

early

+4
source share
1 answer

The easiest way is to make the dataset link dataset , as shown here . Alternatively, you can upgrade from ChartPanel , as suggested below.

 ChartPanel chartPanel; JFreeChart chart = chartPanel.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); XYDataset data = plot.getDataset(); 
+3
source

All Articles