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)
Dynamically scale SVG graph
Ernie2705
Hi all,
we are using Birt in our application to render reports via Birt API in html format and display it in a Eclipse RCP application. The reports are displayed in browser controls each one placed in a RCP View. The generation of reports is a quite expensive task, so once a report is generated we save the results in a cache and reuse it if someone wants to display the same report (with the same paremeters etc.).
Everythings working fine except the scaling of the diagrams: The HTML output Birt is generating contains the svg diagram in an <embedded> HTML tag and also contains absolute width and height data in pixel although we left the width and height details in the report design blank.
If I change the width and height values in HTML output to 100%, the diagram scales as expected but I did not find a solution to make this settings in report design (maybe i?m just to blind?!?).
The (ugly) result is that I have several views in my Eclipse RCP perspective for which their content does not scale if I change the size of the views. It is not a RCP problem cause the graphs also do not scale in browser (testet with Firefox, Chrome and IE).
Can somebody tell me how I could set the size deetails of the embedded svg to a relative declaration like 100%?
Thx,
Bjarne
PS: I attached the report designfile and the HTML/SVG results.
Find more posts tagged with
Comments
Ernie2705
Hi all,
we are using Birt in our application to render reports via Birt API in html format and display it in a Eclipse RCP application. The reports are displayed in browser controls each one placed in a RCP View. The generation of reports is a quite expensive task, so once a report is generated we save the results in a cache and reuse it if someone wants to display the same report (with the same paremeters etc.).
Everythings working fine except the scaling of the diagrams: The HTML output Birt is generating contains the svg diagram in an <embedded> HTML tag and also contains absolute width and height data in pixel although we left the width and height details in the report design blank.
If I change the width and height values in HTML output to 100%, the diagram scales as expected but I did not find a solution to make this settings in report design (maybe i?m just to blind?!?).
The (ugly) result is that I have several views in my Eclipse RCP perspective for which their content does not scale if I change the size of the views. It is not a RCP problem cause the graphs also do not scale in browser (testet with Firefox, Chrome and IE).
Can somebody tell me how I could set the size deetails of the embedded svg to a relative declaration like 100%?
Thx,
Bjarne
PS: I attached the report designfile and the HTML/SVG results.
mwilliams
It appears you're only allowed to set an absolute size on a chart, unfortunately. This is probably due to the scaling of the different blocks of a chart to keep your text at the specified size (Just a guess). You could always use client side script in a text box to grab the chart and set its width to 100%, but this skews the text a little if you only stretch horizontally.
Ernie2705
Hi Michael,
thx for your answer. Can you give me an example how to do this? I think I have to put a text element in the report with "No Display" set and then create a script for the OnRender event, right? But how can I grab the chart and set its width/height?
mwilliams
In my design, I added a bookmark to the chart, as "chart".<br />
<br />
In an HTML text box in my design, I put this:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
<script type="text/javascript">
document.getElementById("chart").style.width = "100%"
</script>
</pre>
<br />
This will stretch your chart out.
Ernie2705
Thanks, this works!
mwilliams
You're welcome! Let us know whenever you have questions!