multiple stacked bar graphs in same category

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
moraleslos
Posts: 6
Joined: Tue May 04, 2004 9:06 pm

multiple stacked bar graphs in same category

Post by moraleslos » Mon May 17, 2004 4:27 pm

Hi,

I have 2 stacked bar graphs that I would like to display side-by-side, i.e. in the same category. I know how to do each one separately, but not together. Seems like the data for the rows is interpreted differently when doing a normal bar graph vs. a stacked bar graph.

Any help/suggestions would be appreciated. Thanks in advance!

-los

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Mon May 17, 2004 10:38 pm

Grouped stacked bar charts will be supported in the 0.9.19 release (or you can try out the code now in CVS).
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

moraleslos
Posts: 6
Joined: Tue May 04, 2004 9:06 pm

Post by moraleslos » Tue May 18, 2004 7:46 pm

Hi David,

Thanks for the tip. I just retrieved the code from CVS and did a successful build. When I run my existing code, I get the following error:

/////////////////////////////////////////////////////////////////////
java.lang.NoSuchMethodError: org.jfree.util.Log.createContext(Ljava/lang/Class;)
Lorg/jfree/util/LogContext;
at org.jfree.chart.axis.Axis.<clinit>(Axis.java:170)
at org.jfree.chart.ChartFactory.createStackedBarChart(ChartFactory.java:
......
/////////////////////////////////////////////////////////////////////

I verified this by checking out the LogContext class and that method does not exist.

-los

moraleslos
Posts: 6
Joined: Tue May 04, 2004 9:06 pm

Post by moraleslos » Tue May 18, 2004 9:20 pm

Well, I "fixed" the bug in the CVS source and tried to do a grouped stacked bar chart but to no avail. What I did was create two CategoryDatasets (the stacked data), created two StackedAreaRenderers, one for each stacked dataset, created a CategoryPlot, and then added each dataset with respective renderer to the plot. When I created a JFreechart from this plot and displayed it, I get a really weird looking graph. Any suggestions on how to actually use the grouped stacked bar feature? Thanks!

-los

Mimil
JFreeReport Staff Member
Posts: 69
Joined: Tue Mar 25, 2003 7:33 pm

Post by Mimil » Tue May 18, 2004 9:25 pm

Hi,

these classes belong from JCommon package. As you just retrieved the code from the CVS, you have retrieved all JCommon files in the same time (JCommon files are a part of JFreeChart classes).
I have just check that in last JCommon "binary" (JCommon-0.9.3) the function createContext from org.jfree.util.Log does not exist, but it exists in the class comming from the CVS.
The line below (from the README.txt from jcommon directory of JFreeChart) could have put us on the picture about this matter too:
0.9.3 : (15-Apr-2004) Update to coincide with JFreeChart 0.9.18.
because you have retrieved JFreeChart 0.9.19.

So (yes, i will answer :) ), i think that you just have to remove the jcommon package from your classpath and all will be okay (i guess java loads the first comming in order)

Bye,
Mimil

PS: let me know if it was that :)
Last edited by Mimil on Tue May 18, 2004 9:32 pm, edited 1 time in total.

moraleslos
Posts: 6
Joined: Tue May 04, 2004 9:06 pm

Post by moraleslos » Tue May 18, 2004 9:31 pm

Hi Mimil,

Yes, that was it. As I previously posted, I did "fix" this up so that it does not read from the old jcommons. Now I'm stuck with my original problem of grouping together stacked bar charts... Any ideas on how to do this with the new code?

As I mentioned before, I tried using a StackedAreaRenderer (this was one of the classes documented to have added grouped stacked bar charts as a new feature)... but got nowhere with it.

Again, any help/suggestions would be appreciated. Thanks in advanced!

-los

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Tue May 18, 2004 9:32 pm

Mimil is correct, you need to build the latest JCommon as well. The source files are in the same CVS repository as the JFreeChart code - it all needs sorting out. You can run the 'ant -f ant/jcommon.xml' if you want to build a new jcommon.jar file, or just compile all the JFreeChart/JCommon source files together (which is what I do while I'm working on the code).

StackedBarChartDemo4.java provides an example for the new GroupedStackedBarRenderer class.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Mimil
JFreeReport Staff Member
Posts: 69
Joined: Tue Mar 25, 2003 7:33 pm

Post by Mimil » Tue May 18, 2004 9:35 pm

Re,

damm, not the time write my post surely that 3 other posts are done ... :)
(yes i tried to verify all what i said, that's why it took me some time to do my post)

Bye,
Mimil

Locked