Hi all,
I'm trying to set the background for my simple bar chart PNG to a
transparency.
I've tried setting the background colour with a 0 alpha value
// start code **
chart.setBackgroundPaint(new GradientPaint(0, 0, new Color(255,255,255,0), 1000, 0, new Color(255,255,255,0)));
// end code **
and creating my own slightly modified PNG creation method:
// start code **
BufferedImage chartImage = chart.createBufferedImage(width, height, info);
PngEncoder encoder = new PngEncoder(chartImage, true, 0, 9);
byte[] pngData = encoder.pngEncode();
out.write(pngData);
// end code **
but I still get a bar chart with a solid black background.
Does anyone have any ideas?
regards,
Paul.
how do I create a transparent PNG chart?
Re: how do I create a transparent PNG chart?
I habve exactly the same problem. Any solution would be greatly appreciated.
Re: how do I create a transparent PNG chart?
There seems to be a three-month-old feature request for this. Nobody has attempted at even looking at it though.
#577279 Transparent background for chart images
Would be nice to have this though as using JFreeChart is pointless unless you are going to use web backgrounds that are white.
#577279 Transparent background for chart images
Would be nice to have this though as using JFreeChart is pointless unless you are going to use web backgrounds that are white.
Re: how do I create a transparent PNG chart?
JD Degenaar wrote:
> There seems to be a three-month-old feature request for this.
> Nobody has attempted at even looking at it though.
Not quite true. I've looked at that feature request (and all of the others) but it has not yet risen high enough on *my* priority list to get implemented by *me*. But one of the key features of free (in the GNU sense) software is that you are not forced to depend on me to get new features implemented...you have other options.
> #577279 Transparent background for chart images
>
> Would be nice to have this though as using JFreeChart is
> pointless unless you are going to use web backgrounds that
> are white.
I think generating images with transparency would be a great feature, and I'm confident that it will be added to a future version (perhaps even by me). But I don't agree that JFreeChart is "pointless" without that feature though.
Regards,
DG
> There seems to be a three-month-old feature request for this.
> Nobody has attempted at even looking at it though.
Not quite true. I've looked at that feature request (and all of the others) but it has not yet risen high enough on *my* priority list to get implemented by *me*. But one of the key features of free (in the GNU sense) software is that you are not forced to depend on me to get new features implemented...you have other options.
> #577279 Transparent background for chart images
>
> Would be nice to have this though as using JFreeChart is
> pointless unless you are going to use web backgrounds that
> are white.
I think generating images with transparency would be a great feature, and I'm confident that it will be added to a future version (perhaps even by me). But I don't agree that JFreeChart is "pointless" without that feature though.
Regards,
DG
Re: how do I create a transparent PNG chart?
My apologies for coming on too strongly about the issue. JFreeChart according to me is still the best utility out on the net.
My reason for saying what I said though simply played a role in the fact that I implemented various charts into some of my pages and found that the chart background breaks the CSS color scheme horribly on any I try to use.
I have ( during my spare time ) started doing some investigation into my issues with the application. Will contact you with a solution as soon as I find a way to improve the creation of the chart image. Hopefully in the next month or so as time permits.
My reason for saying what I said though simply played a role in the fact that I implemented various charts into some of my pages and found that the chart background breaks the CSS color scheme horribly on any I try to use.
I have ( during my spare time ) started doing some investigation into my issues with the application. Will contact you with a solution as soon as I find a way to improve the creation of the chart image. Hopefully in the next month or so as time permits.