如何在Java Swing GUI中显示JFreeChart?
我想使用 JFreeChart 创建一个图表并在 java swing GUI 中显示它。目前我有以下代码可以在单独的框架中显示它,请问有人可以帮助我编写我需要的代码以便在我的 GUI 中显示它吗?
JFreeChart chart = ChartFactory.createScatterPlot(
"Title",
"",
"",
myDataset,
PlotOrientation.VERTICAL,
true,
true,
false
);
ChartFrame frame = new ChartFrame("Results", chart);
frame.pack();
frame.setVisible(true);
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一些搜索表明:
JFreeChart
实例也可以添加到图表面板
。ChartPanel
扩展了JPanel
,因此可以添加到JFrame
(JApplet
、JDialog
、JWindow
、JPanel
、JDesktopPane
..)。A little searching suggests that:
JFreeChart
instance can also be added to aChartPanel
.ChartPanel
extendsJPanel
so can be added to aJFrame
(JApplet
,JDialog
,JWindow
,JPanel
,JDesktopPane
..).