setBackground of chart area

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

setBackground of chart area

Post by Isabelle Gheysens » Fri May 31, 2002 12:37 pm

Hello,

JFreeChart has a method setBackGround(...) to set the background color of the chart.
Is it also possible to change the color of the area where the chart is drawn?
Now that area is always white.

Thanx in advance

Isabelle

David Gilbert

Re: setBackground of chart area

Post by David Gilbert » Fri May 31, 2002 1:21 pm

Yes it is:

Plot plot = myChart.getPlot();
plot.setBackgroundPaint(myPaint);

Regards,

DG.

Isabelle Gheysens

Re: setBackground of chart area

Post by Isabelle Gheysens » Fri May 31, 2002 1:30 pm

Hey David,

I 've tried this method before, but it has no effect. That area of the chart stays white.
Can it be that this is because my chart is in fact a vertically combined chart which consists of 2 overlaid charts or am I doing something wrong?

This is my code:

JFreeChart chart = new JFreeChart(dataset, combinedPlot, "Peak Shaver", JFreeChart.DEFAULT_TITLE_FONT, true);

chart.setBackgroundPaint(Color.yellow);

Plot plot = chart.getPlot();

plot.setBackgroundPaint(Color.yellow);


Thanx,

Isabelle

David Gilbert

Re: setBackground of chart area

Post by David Gilbert » Fri May 31, 2002 4:17 pm

If you can, check out the CVS version of JFreeChart from SourceForge. It works correctly.

With 0.8.1 you will probably find that you have to set the background color on one (or maybe all) of the subplots as well as the parent plot (I have to guess a little here because I don't have a copy of 0.8.1 handy right now). But the code has been changed for the next release...in which only the parent plot background is drawn for an overlaid plot.

Regards,

DG.

Locked