I want to create a graph using JFreeChart and display it in a java swing GUI. At the moment I have the following code to display it in a separate frame, please can someone help me out with the code I need in order to display it my GUI?
JFreeChart chart = ChartFactory.createScatterPlot(
"Title",
"",
"",
myDataset,
PlotOrientation.VERTICAL,
true,
true,
false
);
ChartFrame frame = new ChartFrame("Results", chart);
frame.pack();
frame.setVisible(true);
A little searching suggests that:
JFreeChart
instance can also be added to a ChartPanel
.ChartPanel
extends JPanel
so can be added to a JFrame
(JApplet
, JDialog
, JWindow
, JPanel
, JDesktopPane
..).