Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
writing chart output to a file..
venky
Guys ,
I am having issue writing chart output to a file.
i could able to see the output in a jsp. But the same code in servlet is writing
to file with same size but cudnt able to see the image..
May i know how to resolve this ? which renderoption to use for charts ? is there any better way for getting the stream from runtime engine ? here is my code ..
HTMLRenderOption htmlRenderOption = new HTMLRenderOption();
try{
htmlRenderOption.setOutputFormat("html");
htmlRenderOption.setOutputStream(response.getOutputStream());
htmlRenderOption.setImageHandler(new HTMLServerImageHandler());
IReportRunnable runnable = birtReportEngine.openReportDesign( request.getSession().getServletContext().getRealPath("/reports") + "/sidebarchart.rptdesign");
// create task to run and render report
IRunAndRenderTask task = birtReportEngine.createRunAndRenderTask(runnable);
htmlRenderOption.setImageDirectory(request.getSession().getServletContext().getRealPath("/images"));
htmlRenderOption.setBaseImageURL(request.getContextPath() + "/images");
task.setRenderOption(htmlRenderOption);
HashMap contextMap = new HashMap();
if(xmlString!=null)
contextMap.put("org.eclipse.birt.report.data.oda.xml.inputStream",
new ByteArrayInputStream(xmlString.getBytes()));
else
contextMap.put("org.eclipse.birt.report.data.oda.xml.inputStream",null);
contextMap.put("org.eclipse.birt.report.data.oda.xml.closeInputStream",
new Boolean(true));
task.setAppContext(contextMap);
// run report
task.run();
task.close();
}catch(Exception e){
e.printStackTrace();
}
File f=new File("c:testtest4.png" );
FileOutputStream fop=new FileOutputStream(f);
fop.write(out.toByteArray());
fop.flush();
fop.close();
Find more posts tagged with
Comments
venky
guys ,
i didnt see any value property type outputformat to set image type.( i see only
html & pdf ) . May i know how to store image file from chart ?
htmlRenderOption.setOutputFormat("html");
Virgil Dodson
You might find more information about exporting charts as images at <a class='bbc_url' href='
http://www.birt-exchange.org/wiki/BIRT:Charts2.2/#How_do_I_render_a_chart_into_an_image.3F'>BIRT:Charts2.2
- BIRT Wiki - BIRT Exchange</a>