jreechart 设置背景透明

1.首先设置背景透明

chart.setTextAntiAlias(false);//必须设置文本抗锯齿为false,防止乱码
chart.setBackgroundPaint(null);
ChartUtilities.writeChartAsPNG(res.getOutputStream(),chart,30,50,null);   

注意:主要就是第二句设置背景透明,第三句必须是PNG格式的图片,否则背景会变成黑色


2.设置数据区域透明

 CategoryPlot plot = (CategoryPlot) chart.getPlot();
plot.setBackgroundAlpha((float) 0.0); // 数据区的背景透明度(0.0~1.0)
plot.setBackgroundPaint(null);

持续更新中。。。

你可能感兴趣的:(jreechart)