Adding multiple series using an array
Posted: Tue Oct 19, 2010 1:28 pm
Hi All.
I have spent hours looking through the forum for a simple way to add mutiple series using arrays with no luck
So i have come for some help.... let me explain.
I have a application where the user can select a variable number of series to chart. Its working with a fixed number of variables... but not a dynamic set.
I get the data from the database and it comes back in a result set.
I calculate how many rows and columns are in my result set and put the data into a two dimensional array of the same size. (The method that works loads into 3 arraylists, which i later on convert into an array of doubles.)
I then declare my array of FastLine objects
Now i want to go through each series that is selected and add it to the chart.
So since my data is in a two dimenstional array... im trying to put it into one dimensional array. so i can use the add method.
Unfortunately it doesnt seem to be working and im not sure why. There is no error thrown but the graph just displays as straight lines.
When i look at the data that is in the graph it is all 0. but when i debug the array is populated correctly when the add method is called.
Any help greatly appreciated.
Asim
I have spent hours looking through the forum for a simple way to add mutiple series using arrays with no luck
So i have come for some help.... let me explain.
I have a application where the user can select a variable number of series to chart. Its working with a fixed number of variables... but not a dynamic set.
I get the data from the database and it comes back in a result set.
I calculate how many rows and columns are in my result set and put the data into a two dimensional array of the same size. (The method that works loads into 3 arraylists, which i later on convert into an array of doubles.)
Code: Select all
int m = 0;
while(rs.next()) {
lsx.add((double)rs.getLong(1));
lsy.add(rs.getDouble(2));
lsy2.add(rs.getDouble(3));
a[0][m] = (double)rs.getLong(1);
for (l=1; l < selections.length; l++) {
a[l][m] = rs.getDouble(l+1);
}
m++;
}
Code: Select all
FastLine Line1[] = new FastLine[selections.length];
Code: Select all
xarray = new double[countRows];
yarray = new double[countRows];
for (int k=0; k<selections.length; k++) {
Line1[k] = new FastLine(tChart1.getChart()); //instantiate the object
for (l=0; l < countRows; l++) { //load data into one dimension array
xarray[l] = a[0][l];
yarray[l] = a[k+1][l];
}
Line1[k].add(xarray,yarray); //add to chart
numberOfPoints += countRows;
}
Unfortunately it doesnt seem to be working and im not sure why. There is no error thrown but the graph just displays as straight lines.
When i look at the data that is in the graph it is all 0. but when i debug the array is populated correctly when the add method is called.
Any help greatly appreciated.
Asim