Bug report: DefaultCategorySet problem when repeating catego
Bug report: DefaultCategorySet problem when repeating catego
Hello I'm using JFreeChart 0.7.4 and when using this constructor:
public DefaultCategoryDataset(java.lang.String[] seriesNames,
java.lang.Object[] categories,
java.lang.Number[][] data)
I used a blank String " " repeatedly in the categories[] array. The result is, that in all following categories with a blank String the value is the same as in the first categorie with the blank String. You will have the same effect if you use any other object repeatedly in categories[].
My workaround for this was to use increasingly longer blank Strings when I wanted a blank String(" ", " ", " ", " ",...)
After that change, it worked fine. So the problem was not in the data[][].
Remember that Strings like " " are all represented by the same run-time object.
I wanted the blank String to have less clutter in the output, because in this chart I have lots of categories...actually I'm making a time series with each category representing one month.
BugHunter
public DefaultCategoryDataset(java.lang.String[] seriesNames,
java.lang.Object[] categories,
java.lang.Number[][] data)
I used a blank String " " repeatedly in the categories[] array. The result is, that in all following categories with a blank String the value is the same as in the first categorie with the blank String. You will have the same effect if you use any other object repeatedly in categories[].
My workaround for this was to use increasingly longer blank Strings when I wanted a blank String(" ", " ", " ", " ",...)
After that change, it worked fine. So the problem was not in the data[][].
Remember that Strings like " " are all represented by the same run-time object.
I wanted the blank String to have less clutter in the output, because in this chart I have lots of categories...actually I'm making a time series with each category representing one month.
BugHunter
Re: Bug report: DefaultCategorySet problem when repeating ca
> wanted a blank String(" ", " ", " ", " ",...)
The above didn't show up correctly. It is a list of increasingly longer blank strings... I think this forum automatically reduces successive spaces to one space. Not a good thing, if those spaces are in a String though...
The above didn't show up correctly. It is a list of increasingly longer blank strings... I think this forum automatically reduces successive spaces to one space. Not a good thing, if those spaces are in a String though...
Re: Bug report: DefaultCategorySet problem when repeating ca
The categories are required to be unique, as you have discovered. I will modify the code to check for uniqueness in the constructor, and throw an exception if there are duplicate categories.
If you don't want to see the category names on your chart, just call setTickLabelsVisible(false) on the category axis, and they should disappear.
Regards,
DG.
If you don't want to see the category names on your chart, just call setTickLabelsVisible(false) on the category axis, and they should disappear.
Regards,
DG.
Re: Bug report: DefaultCategorySet problem when repeating ca
>The categories are required to be unique, as you have discovered. I will >modify the code to check for uniqueness in the constructor, and throw an >exception if there are duplicate categories.
Why do they have to be unique? I think this is a big drawback. There is no need for them being unique so why force it? What if I want several categories to have the same name, like in my case?
>If you don't want to see the category names on your chart, just call >setTickLabelsVisible(false) on the category axis, and they should >disappear.
But I don't want all of them to disappear, only some of them. This is because the output is being cluttered with too much Strings and one is overlapping the other. The only solution was to set some of them to blank. But I don't want all of them to be blank...
BugHunter
Why do they have to be unique? I think this is a big drawback. There is no need for them being unique so why force it? What if I want several categories to have the same name, like in my case?
>If you don't want to see the category names on your chart, just call >setTickLabelsVisible(false) on the category axis, and they should >disappear.
But I don't want all of them to disappear, only some of them. This is because the output is being cluttered with too much Strings and one is overlapping the other. The only solution was to set some of them to blank. But I don't want all of them to be blank...
BugHunter
Re: Bug report: DefaultCategorySet problem when repeating ca
The way I look at it, if two categories have the same name and different values, the person looking at the chart is going to get confused.
DG
DG
Re: Bug report: DefaultCategorySet problem when repeating ca
David Gilbert wrote:
>
> The way I look at it, if two categories have the same name
> and different values, the person looking at the chart is
> going to get confused.
>
> DG
It depends on the chart. This are my categories:
2002-01
2002-02
2002-03
2002-04
2002-05
2002-06
2002-07
2002-08
2002-09
2002-10
2002-11
2002-12
Obviously it is a kind of TimeSeries. But I don't want to use the TimeSeries chart because it is not working correctly.
Now, to make the output less cluttered I want to replace some of those categorie names with a blank:
2002-01
<blank>
<blank>
2002-04
<blank>
<blank>
2002-07
<blank>
<blank>
<blank>
<blank>
2002-12
As you can imagine most users won't be confused, rather the output will be much clearer. In cases like these it makes sense to be able to use the same categorie name...
BugHunter
>
> The way I look at it, if two categories have the same name
> and different values, the person looking at the chart is
> going to get confused.
>
> DG
It depends on the chart. This are my categories:
2002-01
2002-02
2002-03
2002-04
2002-05
2002-06
2002-07
2002-08
2002-09
2002-10
2002-11
2002-12
Obviously it is a kind of TimeSeries. But I don't want to use the TimeSeries chart because it is not working correctly.
Now, to make the output less cluttered I want to replace some of those categorie names with a blank:
2002-01
<blank>
<blank>
2002-04
<blank>
<blank>
2002-07
<blank>
<blank>
<blank>
<blank>
2002-12
As you can imagine most users won't be confused, rather the output will be much clearer. In cases like these it makes sense to be able to use the same categorie name...
BugHunter
Re: Bug report: DefaultCategorySet problem when repeating ca
Hi BugHunter,
OK, how about I create a new interface named CategoryInfo with these methods:
public boolean isCategoryLabelVisible();
public String getCategoryLabel();
Then I'll write a new class Category that implements CategoryInfo, which you can use to represent your categories, at your option.
Last I'll modify the category axis classes to check each category (which can still be any subclass of Object) to see if the category implements CategoryInfo in which case the axis will use the above methods to determine whether or not to draw the label and what the label will be, otherwise it reverts to the current behaviour (that is, all categories are visible and the toString() method is used to create the label string).
That's my idea for now, any feedback is appreciated.
By the way, I think the TimeSeries chart is working correctly in version 0.8.0. If it is not, post a bug report and I'll look at it again.
Regards,
DG.
OK, how about I create a new interface named CategoryInfo with these methods:
public boolean isCategoryLabelVisible();
public String getCategoryLabel();
Then I'll write a new class Category that implements CategoryInfo, which you can use to represent your categories, at your option.
Last I'll modify the category axis classes to check each category (which can still be any subclass of Object) to see if the category implements CategoryInfo in which case the axis will use the above methods to determine whether or not to draw the label and what the label will be, otherwise it reverts to the current behaviour (that is, all categories are visible and the toString() method is used to create the label string).
That's my idea for now, any feedback is appreciated.
By the way, I think the TimeSeries chart is working correctly in version 0.8.0. If it is not, post a bug report and I'll look at it again.
Regards,
DG.
Re: Bug report: DefaultCategorySet problem when repeating ca
Personally I think the category stuff is almost overkill. For me it would be ok to have just an array or Vector of Strings representing the names.
BUT... making a Category class with those two functions is ok.
Why do you want to make it an interface? I don't think this will be used anywhere else, but the code will be more complex. I just would make it a simple class. Correct me if I didn't see something here.
Regards,...
Btw...I see the phorum is improving. Can we have the "quote" button back again?
BUT... making a Category class with those two functions is ok.
Why do you want to make it an interface? I don't think this will be used anywhere else, but the code will be more complex. I just would make it a simple class. Correct me if I didn't see something here.
Regards,...
Btw...I see the phorum is improving. Can we have the "quote" button back again?
Re: Bug report: DefaultCategorySet problem when repeating ca
BugHunter wrote:
>
> Personally I think the category stuff is almost overkill. For
> me it would be ok to have just an array or Vector of Strings
> representing the names.
You have the source, the change wouldn't be difficult to make.
> BUT... making a Category class with those two functions is ok.
> Why do you want to make it an interface? I don't think this
> will be used anywhere else, but the code will be more
> complex. I just would make it a simple class. Correct me if I
> didn't see something here.
So that I don't break my existing code which uses arbitrary subclasses of Object as the categories. It is easy to check if the interface is implemented or not and react accordingly.
Personally I think an array of names which would need to parallel another array of categories (since you want to allow duplicate and/or empty names) would shift the complexity elsewhere, not eliminate it.
>
> Btw...I see the phorum is improving. Can we have the "quote"
> button back again?
I also like the new version of Phorum better than the version I had installed previously. Just switch to "threaded" view and the quote button is available. Here's the explanation from the Phorum team:
http://phorum.org/support/read.php?f=2&i=10363&t=10353
Regards,
DG.
>
> Personally I think the category stuff is almost overkill. For
> me it would be ok to have just an array or Vector of Strings
> representing the names.
You have the source, the change wouldn't be difficult to make.
> BUT... making a Category class with those two functions is ok.
> Why do you want to make it an interface? I don't think this
> will be used anywhere else, but the code will be more
> complex. I just would make it a simple class. Correct me if I
> didn't see something here.
So that I don't break my existing code which uses arbitrary subclasses of Object as the categories. It is easy to check if the interface is implemented or not and react accordingly.
Personally I think an array of names which would need to parallel another array of categories (since you want to allow duplicate and/or empty names) would shift the complexity elsewhere, not eliminate it.
>
> Btw...I see the phorum is improving. Can we have the "quote"
> button back again?
I also like the new version of Phorum better than the version I had installed previously. Just switch to "threaded" view and the quote button is available. Here's the explanation from the Phorum team:
http://phorum.org/support/read.php?f=2&i=10363&t=10353
Regards,
DG.