Adding series names to dataset

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

Adding series names to dataset

Post by Allyson Gwin » Mon Jan 27, 2003 7:02 pm

I am trying to add seriesnames to my defaultcategorydataset, but can't seem to do it. I don't know how many names I will need, tnough, and the argument that it takes in a string[]. How can I do this? I have this:

DefaultCategoryDataset dataset = new DefaultCategoryDataset(data);
datasetSeriesNames(s);

s is this:

for (int i = 1; i <= 3; i++) {
String stringi = new Integer(i).toString();
dataset.setSeriesName(i,stringi);
}

I am getting this error:

java.lang.IllegalArgumentException: DefaultCategoryDataset.setSeriesName(...): no such series.

at com.jrefinery.data.DefaultCategoryDataset.setSeriesName(Unknown Source)

I can't seem to find any examples of what I want to do in the demos and I am very new to jfreechart so I have no ideas where to look for other help. I hope someone knows how to do this easily. Thanks.

Allyson

Allyson Gwin

Re: Adding series names to dataset

Post by Allyson Gwin » Mon Jan 27, 2003 7:07 pm

Oops! A typo just in this example. My code does not have this typo:

datasetSeriesNames(s);

should be:

dataset.setSeriesNames(s);

Allyson Gwin

Re: Adding series names to dataset

Post by Allyson Gwin » Mon Jan 27, 2003 7:09 pm

Gosh, I have no idea where my head is. There is no s. DUH! This is the code:

for (int i = 1; i <= 3; i++) {
String stringi = new Integer(i).toString();
dataset.setSeriesName(i,stringi);
}

That is it. With these errors:

java.lang.IllegalArgumentException: DefaultCategoryDataset.setSeriesName(...): no such series.

at com.jrefinery.data.DefaultCategoryDataset.setSeriesName(Unknown Source)

Ignore the person behind the curtain. She has not had enough coffee today. Sorry about that.

Allyson

Allyson Gwin

Re: Adding series names to dataset

Post by Allyson Gwin » Mon Jan 27, 2003 7:17 pm

And once again, I kind of figured out the error. I am using the wrong setSeriesNames. I want to have multiple names and you have to use the String[] and the setStringNames with an "s" for that. But I don't know how many names I will have. So, does that mean I can't use the setSeriesNames since an array has to know how many things it will have? UGH! I am so sorry about all this. I guess I should have looked more closely at the code before I posted it.

Anyway, is there any way to ...

As I was typing this I think I figured out the problem. I DO know how many names there will be. Loser that I am. I wish I could just delete this whole message.

Don't read this. Sorry everyone.

Allyson

Locked