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)
birt report issue
johnalex14
hello all,
i am having a fairly simple issue (i believe) with trying to display a birt graph is a location on my page but my graph keeps shifting to the next line of my page.....
let me try to explain:
i have created an application that dynamically displays an up to the minute graph within my application using struts. I use java to build the graph, then i call it from the jsp.
so in my jsp i have the following code:
<div id="portlet2" class="portlet2">
<birt:report
id="reportDash"
reportDesign="smallChart.rptdesign"
isHostPage="false"
position="relative"
reportContainer="div"
scrolling="no"
height="250"
style="display:block
width="444"
format="html">
</birt:report>
</div>
after running my application in IE and viewing the source code i get the following:
<div id="portlet2" class="portlet2">
<div class="stylereportDash_0">
<table cellpadding="0" rules="none" border="0" style="empty-cells: show; width:6in; overflow: hidden; table-layout:fixed;">
<col></col>
<tr>
<td></td>
</tr>
<tr>
<td valign="top">
<div>
<img id="birtGraph" src="/reportApp/preview?__sessionId=20145103_107356_323&__imageid=custom456dc923c00d4a3d82.png" alt="" style=" width: 325pt; height: 200pt;display: block;"></img>
</div>
</td>
</tr>
<tr>
<td></td>
</tr>
</table>
</div>
</div>
now to the question... its fairly straight forward (i hope...). If you look, the report viewer generates its own DIV ( class: stylereportDash_0)... within that DIV it also creates a table. What i would like to do is alter the "width" and "table-layout" properties on this table using java.. is anyone aware of how to achieve this? ive looked everywhere for examples, and played with my code for hours on end...
thanks,
John
Find more posts tagged with
Comments
kclark
Can you post a screenshot of the jsp page?
johnalex14
<blockquote class='ipsBlockquote' data-author="'kclark'" data-cid="112951" data-time="1357250458" data-date="03 January 2013 - 03:00 PM"><p>
Can you post a screenshot of the jsp page?<br /></p></blockquote>
<br />
kclark,<br />
<br />
thanks for taking the time to look into this for me. I am really stumped... i put up 2 different images, the one titled "birtIntended" is a screen shot of how i want it to look (i had to change the table width to "auto" or remove it completely to make it work like that using a 3rd party CSS editor)... the other image (birtBad) is showing how it is appearing currently. I have messed around with GridHandle and even been able to create another table and move my graph image into that table.... but the inital table remains. I dont need to remove the table, i just need the java code to alter the current table (or remove it completely and just rebuild my own table using the GridHandle).<br />
<br />
It seems like such a silly issue, but its got me beat, thanks again!<br />
john
Clement Wong
John,<br />
<br />
Without looking at your design (smallChart.rptdesign), I believe you are looking for the Layout Preference of the report. By default, reports will be Fixed Layout.<br />
<br />
You can change this at the Report level component, under the General Properties.<br />
<br />
For example, the HTML will have table-layout:fixed (by default):<br />
<pre class='_prettyXprint _lang-auto _linenums:0'><table cellpadding="0" rules="none" style="empty-cells: show; border-collapse:collapse; width:8in; overflow: hidden; table-layout:fixed;"></pre>
<br />
But if you change this to Auto Layout, you'll get:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'><table cellpadding="0" rules="none" style="empty-cells: show; border-collapse:collapse; width:100%;"></pre>
<br />
Can you try changing Layout Preference to Auto Layout, and test if that works for you?
johnalex14
Clement,<br />
<br />
I agree with you 100% that is my issue, however, i am not using the report designer to build my chart/graphs... I am using the JAVA api, and it is all done dynamically from within my application...<br />
<br />
My question is how to alter the layout preferences and the width of that table (which i am not creating, birt is generating that table behind the scenes somehow) using java code.<br />
<br />
if you are aware of any way to either remove that table completely, or to alter the layout/size, please let me know, i have been stumped on this for days!<br />
<br />
thanks for your time,<br />
John<br />
<br />
<br />
<br />
<blockquote class='ipsBlockquote' data-author="'Clement Wong'" data-cid="112989" data-time="1357340999" data-date="04 January 2013 - 04:09 PM"><p>
John,<br />
<br />
Without looking at your design (smallChart.rptdesign), I believe you are looking for the Layout Preference of the report. By default, reports will be Fixed Layout.<br />
<br />
You can change this at the Report level component, under the General Properties.<br />
<br />
For example, the HTML will have table-layout:fixed (by default):<br />
<pre class='_prettyXprint _lang-auto _linenums:0'><table cellpadding="0" rules="none" style="empty-cells: show; border-collapse:collapse; width:8in; overflow: hidden; table-layout:fixed;"></pre>
<br />
But if you change this to Auto Layout, you'll get:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'><table cellpadding="0" rules="none" style="empty-cells: show; border-collapse:collapse; width:100%;"></pre>
<br />
Can you try changing Layout Preference to Auto Layout, and test if that works for you?<br /></p></blockquote>
kclark
john, to set the report layout to auto instead of fixed in java you would do something like this when setting your HTML options.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>((HTMLRenderOption) options).setLayoutPreference(HTMLRenderOption.LAYOUT_PREFERENCE_AUTO);</pre>
johnalex14
kclark,
In my head im 100% sure thats what im looking for... The problem is that i cant get it to work correctly so i cant prove it. My java file that i use to create my graphs was built on the fly using a ton of guess and check and bits and pieces of tons of different code that i found browsing the web... Ive attached it to this response, do you think you could take a look at it and show me where/how you would add this piece of code?
The examples i have found online look like they take a previously created .rptdesign file; open it, then alter it... whereas i am attempting to do it all in one sever side response. I almost feel like creating a graph, then opening it again to alter the file all at once will slow down my application too much... unless thats the only way its possible then ill go for it...
thanks again for your help, i just know that the code ive created is sort of "off the beaten path" and all the examples ive seen dont seem to mesh with my code
-john
Clement Wong
John,<br />
<br />
You can set the layout preferences in your design via the setLayoutPreferences method of the ReportDesignHandle. (<a class='bbc_url' href='
http://help.eclipse.org/helios/topic/org.eclipse.birt.doc.isv/model/api/org/eclipse/birt/report/model/api/ReportDesignHandle.html#setLayoutPreference(java.lang.String)'>ReportDesignHandle
class info reference here</a>)<br />
<br />
In your attached Java code, you would just add the second line to your existing code:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>reportDesignHandle = session.createDesign( );
reportDesignHandle.setLayoutPreference("auto layout");
elementFactory = reportDesignHandle.getElementFactory( );</pre>
<br />
Ideally, you'll want to import the constants instead of hard-coding the auto layout string:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>import org.eclipse.birt.report.model.api.elements.DesignChoiceConstants;
..
reportDesignHandle.setLayoutPreference(DesignChoiceConstants.REPORT_LAYOUT_PREFERENCE_AUTO_LAYOUT);
</pre>
In your resulting smallChart.rptdesign file, you'll see in the XML source (near the top):<br />
<pre class='_prettyXprint _lang-auto _linenums:0'><property name="layoutPreference">auto layout</property></pre>
johnalex14
clement,<br />
<br />
that was it... i cant believe i couldnt find/figure that out...<br />
<br />
thanks a lot to both yourself and kclark!<br />
-john<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<blockquote class='ipsBlockquote' data-author="'Clement Wong'" data-cid="113081" data-time="1357691442" data-date="08 January 2013 - 05:30 PM"><p>
John,<br />
<br />
You can set the layout preferences in your design via the setLayoutPreferences method of the ReportDesignHandle. (<a class='bbc_url' href='
http://help.eclipse.org/helios/topic/org.eclipse.birt.doc.isv/model/api/org/eclipse/birt/report/model/api/ReportDesignHandle.html#setLayoutPreference(java.lang.String)'>ReportDesignHandle
class info reference here</a>)<br />
<br />
In your attached Java code, you would just add the second line to your existing code:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>reportDesignHandle = session.createDesign( );
reportDesignHandle.setLayoutPreference("auto layout");
elementFactory = reportDesignHandle.getElementFactory( );</pre>
<br />
Ideally, you'll want to import the constants instead of hard-coding the auto layout string:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>import org.eclipse.birt.report.model.api.elements.DesignChoiceConstants;
..
reportDesignHandle.setLayoutPreference(DesignChoiceConstants.REPORT_LAYOUT_PREFERENCE_AUTO_LAYOUT);
</pre>
In your resulting smallChart.rptdesign file, you'll see in the XML source (near the top):<br />
<pre class='_prettyXprint _lang-auto _linenums:0'><property name="layoutPreference">auto layout</property></pre></p></blockquote>