I am facing problems in adding points to XYSeries. I have two classes. One is Sample
(it has a main
method) and the other class is JfreeChart
(it has JfreeChart
Code). In my Sample
class I have a 2D array sample[row][2]
which has initially 10 rows, and then I need to call the JfreeChart
class and add them to XYSeries and display a scatter plot. I managed to do this, but the next time I call the Jfreechart
class my Array has 25 rows.
I need to add the values to XYSeries and plot them on a scatter plot which should display the earlier 10 rows' values with different colors and now 25 rows values with different colors… and this goes on. Can anyone give some suggestions or examples?
class Sample {
public static void main(String args[]) {
System.out.print("(X,Y) Paired Values");
double[][] sample = new double[row][2];
for (int g = 0; g < sampe.length; g++) {
for (int h = 0; h < 2; h++) {
System.out.print("" + sample[g][h] + ",");
}
}
JfreeChart sample = new JfreeChart("Demo", sample);
}
static XYDataset samplexydataset2(double[][] sample) {
XYSeriesCollection xySeriesCollection = new XYSeriesCollection();
XYSeries series = new XYSeries("DataSet");
for (int x = 0; x < sample.length; x++) {
series.add(sample[x][0], sample[x][1]);
}
xySeriesCollection.addSeries(series);
return xySeriesCollection;
}
}
1)When I call "First Time" JfreeChart Class I will be having these Pairs in my Sample Array
(0.78,0.80) (0.21,0.19) (0.181,0.187)
2)When I call JfreeChart Class "Second time" I will having Diffrent values in my Sample Array (0.20,0.19) (0.8,0.79) (0.41,0.45) (0.77,0.79) (0.54,0.65)
And this goes for few times(10 times)So I need add this to "XYSeries" and "XYSeriesCollection" and display the "First time" Values and "Second time" Values when I call Second time JFreeChart Class