3

I have created a function that processes some value. Now, my problem is that the graph i create displays the values generated after ALL the values have been calculated. i want to generate the graph such that the as and when the data is calculated; it must be plotted on the data. The calculation and the display of data in the graph must appear parallel. I have generated the graph as:

 dataset.addSeries(series1); 
 dataset = new XYSeriesCollection();

 series1 = new XYSeries("% ERROR");
 chart = ChartFactory.createXYLineChart("Percent Error", "Number of Records", "% Error", dataset,PlotOrientation.VERTICAL,true, true, true);
 chart.setBackgroundPaint(Color.WHITE);
 frame = new ChartFrame("Error graph", chart);
 frame.pack();
 frame.setVisible(true);

The series1 is plotted on the graph.the values in series1 is added on every iteration of the loop which generates some value. Can it be done using wait and notify? I am not really sure about this functions. Please help

AMadmanTriumphs
  • 4,888
  • 3
  • 28
  • 44
sunandan
  • 31
  • 2

2 Answers2

1

The add() method of XYSeries "Adds a data item to the series and sends a SeriesChangeEvent to all registered listeners." One approach is to invoke add() using javax.swing.Timer, as shown in this example.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
0

If your data are computed within a fix period what about using DinamycTimeSeriesCollection? They are very usefull.

You can find an example in this question where I managed the problem of having periods multiple of a millisecond.

Community
  • 1
  • 1
Maverik
  • 2,358
  • 6
  • 34
  • 44