changing series names on the fly

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Allyson Gwin

changing series names on the fly

Post by Allyson Gwin » Thu Jan 30, 2003 9:06 pm

I want to do this:

for (int i = 0; i < SetupCount; i++) {
String stringi = "Setup " + "#" + new Integer(i+1).toString();
setups = stringi;
series = new XYSeries(setups);
for (int j = 0; j < SetupPoints.size()/2; j+=2) {
// System.out.println(j + "= " + SetupPoints.get(j) + " and " + SetupPoints.get(j+1));
double yy = new Double(SetupPoints.get(j+1).toString()).doubleValue();
double xx = new Double(SetupPoints.get(j).toString()).doubleValue();
series.add(xx,yy);
}
dataset.addSeries(series);
}

but I want to have the name series be series1, series2, series3, depending on what 'i' is in the loop. Is there a way to do this? I thought that if I did it this way, then each time thru the other loop, series would get set to the new set of values, but it doesn't. It just keeps the first set and uses that throughout the whole graph. So there is really only 1 set of data on the graph rather than 'SetupCount' sets.

Any ideas?

Thanks.

Allyson

David Gilbert

Re: changing series names on the fly

Post by David Gilbert » Thu Jan 30, 2003 9:31 pm

It looks to me like you will get multiple series, but all containing the same values read from the SetupPoints structure.

Regards,

Dave Gilbert

Allyson Gwin

Re: changing series names on the fly

Post by Allyson Gwin » Thu Jan 30, 2003 9:44 pm

Thanks, Dave. You are right. I didn't look closely enough at the inside loop. I have been working on this code forever so sometimes I can not see what is right in front of me. Thanks for your help.

Allyson

Locked