JFreeChart XY图表刷新与新的数据集?例? [英] JFreeChart XY-chart that refreshes with new set of data? Example?

查看:217
本文介绍了JFreeChart XY图表刷新与新的数据集?例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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?

提前感谢,

Andreas

推荐答案

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

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
}

这篇关于JFreeChart XY图表刷新与新的数据集?例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆