使用新数据集刷新的 JFreeChart XY 图表?例子?

发布于 2024-11-06 03:27:38 字数 340 浏览 6 评论 0原文

我想学习如何学习如何使用 jfreechart 和 google 创建一些图表的一些示例。但我找不到我需要的东西。这里很好 http://www.java2s.com/Code/Java/Chart /CatalogChart.htm 但没有带有新显示值的刷新图表。

我想每隔 n 秒重新绘制一个图表,因为我用一组我想在此处显示的值更新外部 dile。 那么如何告诉 jfreechart 刷新绘制的图形并将其显示在画布上呢?

预先感谢,

安德烈亚斯

I want to learn how to learn how to create some charts with jfreechart and googlefor some examples. but I couldn't find what I need. This here is good http://www.java2s.com/Code/Java/Chart/CatalogChart.htm but doesn't have a refreshing graph with new displayed values.

I would like to redraw a chart every nth seconds because I update an external dile witha set of values I want to display here.
So how do I tell jfreechart to refresh the drawn graph and display it onthe canvas?

Thanks in advance,

Andreas

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

明媚殇 2024-11-13 03:27:38

示例具有已更新的图表使用 javax.swing.Timer 实例以可选择的速率。

附录:JFreeChart 遵循 Swing separable-model MVC 的变体ChartPanel 是一个方便的顶级视图,如以下 示例。对于世俗数据,TimeSeriesTimeSeriesCollection 构成了一个简单的数据模型。

This example features a chart that is updated at a selectable rate using an instance of javax.swing.Timer.

Addendum: JFreeChart follows the Swing separable-model variation of MVC. ChartPanel is a convenient top-level view, as seen in this example. For secular data, a TimeSeriesCollection of TimeSeries makes a straightforward data model.

笑饮青盏花 2024-11-13 03:27:38

我遇到了同样的问题,这对我有用:

private void refreshChart(){
    jPanel_GraphicsTop.removeAll();
    jPanel_GraphicsTop.revalidate(); // This removes the old chart aChart = createChart();
    aChart.removeLegend();
    ChartPanel chartPanel = new ChartPanel(aChart);
    jPanel_GraphicsTop.setLayout(new BorderLayout());
    jPanel_GraphicsTop.add(chartPanel);
    jPanel_GraphicsTop.repaint(); // This method makes the new chart appear
}

I had the same issue, this worked for me:

private void refreshChart(){
    jPanel_GraphicsTop.removeAll();
    jPanel_GraphicsTop.revalidate(); // This removes the old chart aChart = createChart();
    aChart.removeLegend();
    ChartPanel chartPanel = new ChartPanel(aChart);
    jPanel_GraphicsTop.setLayout(new BorderLayout());
    jPanel_GraphicsTop.add(chartPanel);
    jPanel_GraphicsTop.repaint(); // This method makes the new chart appear
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文