Jfreechart - Refresh a chart according to changing data

后端 未结 6 1616
旧时难觅i
旧时难觅i 2020-12-16 18:23

I would like to know how to refresh a chart if we want to change \"in live\" some piece of data. I mean for instance, I have a chart with a TaskSeries which appears on 3 yea

6条回答
  •  轮回少年
    2020-12-16 18:58

    I had this issue; I did it using this:

    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
    }
    

提交回复
热议问题