Any help is appreciated, please?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Post Reply
scullsold
Posts: 1
Joined: Sun May 20, 2018 9:58 am
antibot: No, of course not.

Any help is appreciated, please?

Post by scullsold » Sun May 20, 2018 10:19 am

Hi,

I just found out that I can not have duplicated item on the X axis when using a bar chart ???

If I have a DefaultCategoryDataset with these values :

90,"Global","name 1"
78,"Global","name 2"
56,"Global","name 3"
34,"Global","name 3"
12,"Global","name 4"
01,"Global","name 4"

the output graphic will have these values (which is incorrect) :

90,"Global","name 1"
78,"Global","name 2"
56,"Global","name 3"
12,"Global","name 4"

"Global" is the series name, I only want one.
01..90 are the values for the name x items.
"name x" the name of the multiple occurence items.

What can I do to solve this. Because I have to use a Bar chart and I need to keep and display the duplicated items. They can not just vanish like it does now :? .

The only solution I found was to add a number in front of the name so that it would not delete them from the dataset in java in the dataset.addValues method (ie.: count + "." + rset.getString("name")).

Any help is appreciated.


Top
JFreeChart Project Leader
Posts: 11666
Joined: Fri Mar 14, 2003 4:29 pm
antibot: No, of course not.
Contact: Contact alice
Post by david.gilbert » Tue Mar 20, 2007 12:19 am

The categories must be unique.

If you really do want to confuse the people reading the charts, by presenting two different values for apparently the same category, you can make use of the fact that (a) a category key can be any instance of Comparable, and (b) the displayed label is derived from the toString() method.

In other words, write your own CustomCategory class that implements Comparable, then create two unique / distinct instances that happen to return the same text via the toString() method.

Post Reply