CombinedDomainCategoryPlot Alignment of Subplots

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Reggie3
Posts: 12
Joined: Mon Mar 10, 2008 5:19 pm

CombinedDomainCategoryPlot Alignment of Subplots

Post by Reggie3 » Wed Apr 02, 2008 9:12 pm

I have a CombinedDomainCategoryPlot made up of several supblots. Each subplot may have up to 15 bars in it (3 series in 5 categories). However one subplot only has 1 bar in the 3rd series of the 5th category. In my case this causes the single bar to be drawn in the middle of the chart in which case it is aligned in the wrong category. Additionally, it is being rendered as if it is a member of the 1st series in it's category, when it is actually the 3rd. I'm assuming this is because it's the only bar being rendered, and the renderer renders the bar based on the order it receives it as opposed to it's actual series (please correct me if I'm wrong).
Anyway, is there a built in solution to fix this? If not, I'm thinking I'd need to pad the DefaultCategoryDataset and fill it with the maximum number of series that I can expect. If I have to do this, I'd like to avoid using a bunch of 0 values because some of my actual series are equal to 0, and this would cause some confusion. Is there a way to deal with this? One option would be to use a negative value, and render bars with negative values in a way that they would not be visible.

Summary: I have a subplot on a Combined Plot that only has one bar. It's single bar is being rendered in the middle of the chart, and is not aligned with bars from the same category and series in the other subplots. How do I fix this?

RichardWest
Posts: 844
Joined: Fri Oct 13, 2006 9:29 pm
Location: Sunnyvale, CA

Re: CombinedDomainCategoryPlot Alignment of Subplots

Post by RichardWest » Wed Apr 02, 2008 9:36 pm

Reggie3 wrote:Summary: I have a subplot on a Combined Plot that only has one bar. It's single bar is being rendered in the middle of the chart, and is not aligned with bars from the same category and series in the other subplots. How do I fix this?
You could insert null values into the dataset. The null value would not be drawn (unlike 0 or a negative value), but it will pad out the data to have the bars line up. The other option is to create a custom dataset that implements the CategoryDataset interface to manage the data as you see fit.
Richard West
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA

Reggie3
Posts: 12
Joined: Mon Mar 10, 2008 5:19 pm

Thanks

Post by Reggie3 » Thu Apr 03, 2008 2:06 pm

That works perfectly, thanks.

Locked