Help me to set a transparent background for PieChart
Thanks,
Gopi
Transparent Background
Re: Transparent Background
Call setBackgroundPaint(null) on the chart and on its plot, the legend, etc. If you want a partially transparent color instead of full transparency, use the appropriate constructor for java.awt.Color and pass that object to the same setBackgroundPaint() methods. Output to an image format that supports transparency. If this is going on the web, be aware of the limitations of the Internet Explorer browser and transparency in png.
Re: Transparent Background
Dear jleech,
Thanks for your reply.
plot.setBackgroundPaint(null) with backgroundAlpha(0.0f) gives plot with transparent background and it reflects the color of the chart.
but
chart.setBackgroundPaint(null) gives black background and hence the whole background appears black.
Is there any possibility to generate transparent background image such that the background color of the html container(in browser) is appears to be the image background.
Thanks,
Gopi.
Thanks for your reply.
plot.setBackgroundPaint(null) with backgroundAlpha(0.0f) gives plot with transparent background and it reflects the color of the chart.
but
chart.setBackgroundPaint(null) gives black background and hence the whole background appears black.
Is there any possibility to generate transparent background image such that the background color of the html container(in browser) is appears to be the image background.
Thanks,
Gopi.
Re: Transparent Background
What kind of image are you creating? I had a similar issue with PNG images, though I was doing some non-standard JFreeChart stuff though. I am not sure which of the following was necessary with standard JFreechart output to an image, and which was self-imposed... I ended up making a 256 color indexed BufferedImage, setting every pixel to white before calling chart.draw() on it, then using JAI to modify the palette transparency to fully opaque for all colors but white, and fully transparent for white, and encode to png. (So that anti-aliased text would look good in all browsers, otherwise text was unreadable in IE with its half-assed PNG support). There is likely an easier way, but the above worked for me. Creating a transparent GIF, or a non-indexed PNG, and/or not using anti-aliasing probably works fine.