Page 1 of 1

update timeseries chart every 15 seconds

Posted: Sat Jul 07, 2012 9:49 pm
by malli108
Hi, i developed a timeseries chart using DynamicTimeSeriesCollection my code is

Code: Select all

final DynamicTimeSeriesCollection dataset = new DynamicTimeSeriesCollection(15, COUNT, new Second());
dataset.setTimeBase(new Second(seconds, minutes, hours, date, month, year));

    dataset.addSeries(gaussianData(), 0, "Currency Rate");

       chart= createChart(dataset);

        timer = new Timer(15000, new ActionListener() {

            float[] newData = new float[15];

            @Override
            public void actionPerformed(ActionEvent e) {
              for(i=0;i<15;i++)
                newData[i] = randomValue();
                
                dataset.advanceTime();
                dataset.appendData(newData);
            }
        });
this is the code to invoke chart panl

Code: Select all

EventQueue.invokeLater(new Runnable() {
            public void run() {
                PrepareChart chart = new PrepareChart(); 
                System.out.println("In caht getter methoed");
                chart.start();[i]// call start method of this class which start timer[/i]
            }
        });
My problem is in this graph it is adding only one value in the graph. due to that the graph time base is delaying values. Please help me on this.
Thanks in advance....