spaces in the plot

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

spaces in the plot

Post by Joachim Schuler » Wed Jul 10, 2002 4:05 pm

Hi,

how can I change the space in a plot, before the chartline begins and after the chartline ends. The spaces are actually to broad.

I didn't found a method in the javadoc and no comments in the docs.

Thanks

Joachim Schuler

Sean

Re: spaces in the plot

Post by Sean » Wed Jul 10, 2002 5:52 pm

Place this code in your createLineChart or createBarChart method and you should be fine. To increase or decrease the spaces just change the value inside the perenthesis.

plot.setIntroGapPercent(0.01);
plot.setTrailGapPercent(0.01);

Good luck

Sean

Joachim Schuler

Re: spaces in the plot

Post by Joachim Schuler » Thu Jul 11, 2002 9:52 am

Hi,

sorry, I forgot to mention, that I have a TimeSeriesChart.

Can I change the start- and end-spaces in a TimeSeriesChart ?

Thanks,

Joachim Schuler

Sean

Re: spaces in the plot

Post by Sean » Thu Jul 11, 2002 4:34 pm

Those lines will work for any chart besides Pie. So you should be good to go.


Sean

David Gilbert

Re: spaces in the plot

Post by David Gilbert » Thu Jul 11, 2002 11:13 pm

Hi Joachim,

In the NumberAxis class, there are two methods:

setLowerMargin(double);
setUpperMargin(double);

When the axis range is being calculated automatically, JFreeChart works out the smallest and largest values in the dataset. Then a margin (a percentage of the overall range) is added to each end of the axis. The default is 5%. You probably want to set it to something closer to zero.

The methods that Sean mentions are used for spacing items in a CategoryPlot along the category axis.

Regards,

DG.

Joachim Schuler

Re: spaces in the plot

Post by Joachim Schuler » Mon Jul 22, 2002 1:12 pm

Thanks to all,

who answers to my questions.

But the problem is, that I have a HorizontalDateAxis and I couldn't change the margins with the mentioned methods.

Has anybody a solution ?

Thanks,

Joachim

David Gilbert

Re: spaces in the plot

Post by David Gilbert » Mon Jul 22, 2002 2:22 pm

You've uncovered another inconsistency! If you look in the autoAdjustRange() method in the HorizontalDateAxis class, you'll see two lines that increase the range of the axis by 5 percent (hard-coded) at each end as follows:

upper = upper+(range/20);
lower = lower-(range/20);

That should get changed to use the lowerMargin and upperMargin attributes (which will need to be moved from NumberAxis to ValueAxis to allow this). I'll add that to my to-do list.

Regards,

DG.

Locked