Space at start and end of X axis

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

Space at start and end of X axis

Post by Mike Isaacs » Wed May 22, 2002 11:52 am

Hello,

I'm using a VerticalBarChart and the x axis is a HorizontalCategoryAxis.

The graph displays with a 1 inch space before the first category is plotted, and also after the last category.

e.g.

|
|
| x x
| x
| x x x x
|__________________
A B C D E F G

How can I remove the space left befor the first category?

I've got the x-axis using getHorizontalAxis() on the plot, but there is no method on the HorizontalCategoryAxis class that is related to this.

Help appreciated.

Regards,

Mike

Mike Isaacs

Re: Space at start and end of X axis

Post by Mike Isaacs » Wed May 22, 2002 11:53 am

Spaces were stripped in diagram above, but basically the category A would start an inch further right..

David Gilbert

Re: Space at start and end of X axis

Post by David Gilbert » Wed May 22, 2002 12:46 pm

Hi Mike,

The CategoryPlot class has the following methods for controlling gaps in bar charts:

public void setIntroGapPercent(double);
public void setTrailGapPercent(double);
public void setSeriesGapPercent(double);
public void setCategoryGapPercent(double);

The double values are expressed as a percentage of the available drawing space for the plot (for example 0.05 is five percent).

So you'll probably want to do this:

CategoryPlot plot = myChart.getCategoryPlot();
plot.setIntroGapPercent(0.0);
plot.setTrailGapPercent(0.0);

Regards,

DG.

Mike Isaacs

Re: Space at start and end of X axis

Post by Mike Isaacs » Wed May 22, 2002 1:19 pm

Hi David,

I had: Plot plot = (Plot)chart.getPlot();

But I changed it to:

CategoryPlot plot = myChart.getCategoryPlot();
plot.setIntroGapPercent(0.0);
plot.setTrailGapPercent(0.0);

However I get the following runtime error:

java.lang.VerifyError: (class: myweb/graphs/stats/Charting, method: drawGraph signature: (Ljava/util/vector;Ljava/lang/String;Ljava/lang/String;)V) Incompatible object arguement for function call

Any ideas..

Regards, Mike

Locked