#51 transparent chart backgrounds + inner panes

open
nobody
None
5
2005-07-28
2005-07-28
Marcus Knappe
No

Hi, I just started using jcharts and mainly, I generate
static png files. A nice addition would be to support
transparent backgrounds.

You can see a modification of one of your examples,
that already generates a mostly transparent background.

----

ChartProperties chartProperties = new ChartProperties();
Color bgcolor = new Color((float) 0.0, (float) 1.0,
(float) 0.0, (float) 0.1);
chartProperties.setBackgroundPaint(bgcolor);
AxisProperties axisProperties = new AxisProperties();
LegendProperties legendProperties = new LegendProperties();
AxisChart axisChart = new AxisChart(dataSeries,
chartProperties, axisProperties,
legendProperties, 600, 300);
FileOutputStream outstream= new
FileOutputStream("chart.png");
ImageIO.setUseCache(false);
BufferedImage bufferedImage = new
BufferedImage(axisChart.getImageWidth(), axisChart
.getImageHeight(),
BufferedImage.TYPE_INT_ARGB);
axisChart.setGraphics2D(bufferedImage.createGraphics());
axisChart.render();
ImageIO.write(bufferedImage, "png", outstream);

---

Basically, I use ARGB as image type.

What is still missing: the inner pane is always white,
I did not figure out how to change that color.

Discussion

  • Marcus Knappe
    Marcus Knappe
    2005-07-28

     
    Attachments
  • Marcus Knappe
    Marcus Knappe
    2005-07-28

    Logged In: YES
    user_id=777754

    I just did a local patch of Properties.java :

    public static final Paint DEFAULT_BACKGROUND_PAINT = new
    Color((float) 1.0, (float) 1.0, (float) 1.0, (float) 0.0);

    That does it. Default white shall still come on top if not
    elsewhere changed.