Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
To save a dynamically generated chart as an image
manojsanjo
Hello all,
I am having a web application that uses only the Report Engine. In the rptdesign file I use, there is a chart I am inserted. At runtime, the chart should be dynamically generated/changed. Using the BIRT plugin in Eclipse, I am able to generate the preview successfully, but when I run my app, the chart does not show up and the web page shows an empty placeholder (which links to an image). Has anyone encountered this?
I am checking if it is possible to save the dynamically generated chart as an image and then render the HTML via a servlet to display this image.
Has anyone encountered anything like this and has anyone done a solution like this? I am seeking experienced answers to help my situation.
Thanks,
Manoj.
Find more posts tagged with
Comments
JasonW
What is the img src tag look like in the generated html? Is the image created on the server?
Jason
manojsanjo
Jason,<br />
<br />
Here are the answers:<br />
1) What is the img src tag look like in the generated html?<br />
A) See attachment. The view source shows...<br />
<img id="__bookmark_7" alt="" style=" width: 212pt; height: 130pt;display: block;"></img><br />
<br />
<br />
2) Is the image created on the server?<br />
A) I could not find the file. I checked the directory which was mentioned in the web.xml under <param-name>BIRT_VIEWER_IMAGE_DIR</param-name>. I do not know if I am looking @ the right directory. <br />
<br />
Thanks for your help. Please let me know if you find anything.<br />
<br />
Manoj.<br />
<br />
<blockquote class='ipsBlockquote' data-author="'JasonW'" data-cid="81287" data-time="1312833775" data-date="08 August 2011 - 01:02 PM"><p>
What is the img src tag look like in the generated html? Is the image created on the server?<br />
<br />
Jason<br /></p></blockquote>
manojsanjo
Friends,
I was able to get the solution to the problem. THanks for looking and the suggesttion given. Here is what I have done.
I was using only the ReportEngine within my web application. (Note: That means I did not use the BIRT viewer). In my code, I created a HTMLRenderOption object with a HTMLImageHandler() object. This was the problem especially since I was using only ReportEngine. I switched to use HTMLServerImageHandler() and also set the BaseImageURL. This helped me to see the image of the chart that was created.
http://www.eclipse.org/birt/phoenix/deploy/reportEngineAPI.php
Well, the next step was to present this image onto the file. This is simple and I am assuming most of you know it. But I will still write it. I wrote a servlet to push out the image into a BufferedOutputStream. See example here...
http://balusc.blogspot.com/2007/04/imageservlet.html
Thanks again.
Manoj.
cypherdj
Hi,
If I understand correctly, you're programmatically running and rendering a report (presumably in a servlet) and when you display the report in a browser, the image is "broken", right?
It's probably just that you're not setting something either in your PlatformConfig or in the RenderOptions I think, but if you could provide some code, it might be easier to see what you might be doing wrong.
Rgds,
Cedric
cypherdj
Hmmm, yep, I thought you might not be setting the image base url indeed
manojsanjo
Yes, when I used HTMLServerImageHandler() and set the BaseImageURL, the image for the chart started to generate in my ImageDirectory. Thanks.<br />
<br />
<blockquote class='ipsBlockquote' data-author="'cypherdj'" data-cid="81352" data-time="1312928728" data-date="09 August 2011 - 03:25 PM"><p>
Hmmm, yep, I thought you might not be setting the image base url indeed
<br /></p></blockquote>
JasonW
If you set the image directory in the options it should automatically create the proper url for you. Like:
options.setImageHandler(new HTMLServerImageHandler());
options.setBaseImageURL(req.getContextPath()+"/images");
options.setImageDirectory(sc.getRealPath("/images"));
Jason
manojsanjo
Jason,<br />
<br />
I was able to get a resolution to the problem. Like I mentioned in my earlier entry, I have followed these steps and was able to get the chart on the web app now.<br />
<br />
Thanks,<br />
Manoj.<br />
<br />
<blockquote class='ipsBlockquote' data-author="'JasonW'" data-cid="81371" data-time="1312950098" data-date="09 August 2011 - 09:21 PM"><p>
If you set the image directory in the options it should automatically create the proper url for you. Like:<br />
<br />
options.setImageHandler(new HTMLServerImageHandler());<br />
options.setBaseImageURL(req.getContextPath()+"/images");<br />
options.setImageDirectory(sc.getRealPath("/images"));<br />
<br />
Jason<br /></p></blockquote>