Overlayed chart with 2 bar

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
edu_neri
Posts: 4
Joined: Wed Sep 29, 2010 9:14 pm
antibot: No, of course not.

Overlayed chart with 2 bar

Post by edu_neri » Wed Sep 29, 2010 9:36 pm

Hi,

I'd like to create a barchart with 2 or more categories using XYplot, but when i add the 2nd category, it just get over the 1st one. How can I solve this to render like DefaultCategoryDataset? I'm not using DefaultCategoryDataset class because I want to write a linechart over the bars.

Ty
Luiz Eduardo

edu_neri
Posts: 4
Joined: Wed Sep 29, 2010 9:14 pm
antibot: No, of course not.

Re: Overlayed chart with 2 bar

Post by edu_neri » Thu Sep 30, 2010 2:21 pm

Here a SS of how it is now
Image

Uploaded with ImageShack.us

and how I want the bars show like this (including the line)
Image

Uploaded with ImageShack.us

mkivinie
Posts: 51
Joined: Wed Jul 06, 2005 8:35 am

Re: Overlayed chart with 2 bar

Post by mkivinie » Fri Oct 01, 2010 6:50 am

Perhaps ClusteredXYBarRenderer is what you need:

http://www.jfree.org/jfreechart/api/jav ... derer.html

edu_neri
Posts: 4
Joined: Wed Sep 29, 2010 9:14 pm
antibot: No, of course not.

Re: Overlayed chart with 2 bar

Post by edu_neri » Fri Oct 01, 2010 6:20 pm

mkivinie thx man, that did the trick.

But now i'm facing another problem. I've mixed values of other old years and now i'm having another problem. He is priting the old years with months.

Is there any way to create categories using strings, instead of numbers or dates?

skunk
Posts: 1087
Joined: Thu Jun 02, 2005 10:14 pm
Location: Brisbane, Australia

Re: Overlayed chart with 2 bar

Post by skunk » Fri Oct 01, 2010 6:47 pm

You can specify what format you want the dates to appear using this method

Code: Select all

public void setDateFormatOverride(java.text.DateFormat formatter)

edu_neri
Posts: 4
Joined: Wed Sep 29, 2010 9:14 pm
antibot: No, of course not.

Re: Overlayed chart with 2 bar

Post by edu_neri » Fri Oct 01, 2010 7:25 pm

Skunk,
Thx for reply, but I do not want to set same date to all data. The 1st 3 will appear only year and the other will have month.

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: Overlayed chart with 2 bar

Post by paradoxoff » Wed Oct 06, 2010 7:41 pm

edu_neri wrote: Thx for reply, but I do not want to set same date to all data. The 1st 3 will appear only year and the other will have month.
You should be able to achieve that with a custom DateFormat implementation that is using either a default SimpleDateFormat or, if a specific condition is met, a second SimpleDateFormat.

Locked