Controlling bar width for bar charts

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Girish

Controlling bar width for bar charts

Post by Girish » Sun Sep 29, 2002 10:37 am

Hi all,
I am using JFreeChart for creating bar charts - vertical bar charts, horizontal bar charts, 3D Bar charts, and 3D Stacked Bar charts.

When I have more data the chart is very good, but when I have less data say 1 or 2 data only the bar covers the whole chart and are very big bars.

I wish some one of you help me in getting a decent good chart even when I have less data.

Regards
Girish

David Gilbert

Re: Controlling bar width for bar charts

Post by David Gilbert » Mon Sep 30, 2002 9:36 am

It will require some modification to JFreeChart to make it handle small numbers of bars differently. But if you have the chance to intervene in your own code, you can change the values of these attributes (all in the CategoryPlot class) to alter the bar widths:

- introGapPercent
- trailGapPercent
- itemGapsPercent
- categoryGapsPercent

The bar widths are automatically calculated to use whatever space is available after the above amounts have been distributed across the chart as the "gaps".

Regards,

DG.

Girish

Re: Controlling bar width for bar charts

Post by Girish » Fri Oct 04, 2002 12:32 pm

Hi DG,

Thanks.
Had to do lots of calculations to check how much data I have before setting the gaps.
Some times if there are 2 data (2 bars would be displayed), and I set maximum gaps then therewas no bars at all.
Any way this helped me.

Thanks

Girish

Locked