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
setBackground of chart area
Re: setBackground of chart area
Yes it is:
Plot plot = myChart.getPlot();
plot.setBackgroundPaint(myPaint);
Regards,
DG.
Plot plot = myChart.getPlot();
plot.setBackgroundPaint(myPaint);
Regards,
DG.
Re: setBackground of chart area
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
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
Re: setBackground of chart area
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.
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.