Reputation: 603
"I have a Problem of adding double variable "gdataset" values to "series.add()". Any help please regarding this"
private static XYDataset samplexydataset2() {
double[][]gdataset;
XYSeriesCollection xySeriesCollection = new XYSeriesCollection();
XYSeries series = new XYSeries("Distances");
gdataset= test.generateDataset();//which calls Method in other Class
for(int row=0;row<gdataset.length;row++)
{
for(int column=0;column<gdataset[row].length;column++)
{
series.add(gdataset[row],gdataset[column]);//I am getting error at "add"
//System.out.printf("%f" +" ",gdataset[row][column]);
}
System.out.println();
xySeriesCollection.addSeries(series);
return xySeriesCollection;
}
Thanks..U are correct!...what if I have another 3/4 Columns.So I want to make it Dynamic. For Example: My OuptPut looks like (X,Y)
0.611787 2.304051
1.636265 2.261579
1.073176 1.188980
and If I have 3 Colums(X,Y,Z) its like this
0.142197 1.440918 0.217366
0.149352 0.748124 3.214357
0.536232 0.107004 4.198831
And in this Way my Columns will be Increasing..So i want to put another For loop in this way and Display on the ScatterPlot.Any suggestions reg this will be helpful.
for(int column=0;column<gdataset[row].length;column++)
{
//series.add(gdataset[row][column],gdataset[row][column++]);
}
Upvotes: 2
Views: 2331
Reputation: 205785
Assuming the structure of gdataset
is one xy pair per row, it looks like you meant to say:
for (int row = 0; row < gdataset.length; row++) {
series.add(gdataset[row][0], gdataset[row][1]);
}
xySeriesCollection.addSeries(series);
return xySeriesCollection;
Upvotes: 1