将 JFreeChart 添加到 JPanel 中
如果我有一个 Jpanel 和一个 JFreeChart。如何将此图表添加到 JPanel 中?
XYSeries series = new XYSeries("XYGraph");
series.add(1, 1);
series.add(1, 2);
series.add(2, 1);
series.add(3, 9);
series.add(4, 10);
// Add the series to your data set
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(series);
// Generate the graph
JFreeChart chart = ChartFactory.createXYLineChart(
"XY Chart", // Title
"x-axis", // x-axis Label
"y-axis", // y-axis Label
dataset, // Dataset
PlotOrientation.VERTICAL, // Plot Orientation
true, // Show Legend
true, // Use tooltips
false // Configure chart to generate URLs?
);
现在,我如何在 JPanle 中添加图表?
if i have a my Jpanel and a my JFreeChart. How can I add this Chart in to the JPanel?
XYSeries series = new XYSeries("XYGraph");
series.add(1, 1);
series.add(1, 2);
series.add(2, 1);
series.add(3, 9);
series.add(4, 10);
// Add the series to your data set
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(series);
// Generate the graph
JFreeChart chart = ChartFactory.createXYLineChart(
"XY Chart", // Title
"x-axis", // x-axis Label
"y-axis", // y-axis Label
dataset, // Dataset
PlotOrientation.VERTICAL, // Plot Orientation
true, // Show Legend
true, // Use tooltips
false // Configure chart to generate URLs?
);
and now, how can i add chart in my JPanle?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
来自旧的 Java 论坛主题< /a>
From an old java forums thread
这是一个很好的教程,可以进一步引导您:如何将 JFreeChart 嵌入 JPanel
Here is a good tutorial to lead you further : How to embed JFreeChart in JPanel
我遇到了同样的问题,但我能够找到解决此问题的方法。
希望这有帮助
I was having the same problem but I was able to identify a way to solve this.
Hope this helps