Hmm... your support is quite amazing... never come across such a blazing fast replies... thank you very much.
Actually, I'm usinng a rich faces component a4j:mediaOutput(
http://livedemo.exadel.com/richfaces-de ... ediaOutput) to display the buffered image in my JSP Page.
It'll display the buffered image in the web page on the fly(without storing in between).
Below is My Code
Code: Select all
class MyController {
public void getChartImage (OutputStream out, Object data) throws Exception {
ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
BufferedImage pageImage = getBufferedImageFromChart(info);
ChartUtilities.writeImageMap(new PrintWriter(out), "chart", info, true);
ImageIO.write(pageImage, "jpeg", out);
}
private BufferedImage getBufferedImageFromChart(ChartRenderingInfo info) throws Exception {
BufferedImage pageImage = null;
DefaultCategoryDataset dataSet = getDataSet(reportsVO);
if (dataSet != null) {
JFreeChart chart = ChartFactory.createStackedBarChart("Alerts as % of Total Programs"
, "Alerts", "%"
, dataSet, PlotOrientation.VERTICAL
, true, true, false);
CategoryPlot plot = (CategoryPlot) chart.getPlot ();
plot.setRenderer(getGroupedRenderer(infuserType, comparisonType));
if (dataSet.getColumnCount() > 5) {
CategoryAxis domainAxis = plot.getDomainAxis ();
domainAxis.setCategoryLabelPositions (CategoryLabelPositions.UP_90);
}
pageImage = chart.createBufferedImage (700, 500, BufferedImage.TYPE_INT_RGB , info);
}
return pageImage;
}
}
<a4j:mediaOutput element="img" cacheable="false" session="true" usemap="#chart"
createContent="#{myController.getChartImage}"
mimeType="image/jpeg" />