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)
Chart Rendering Difference in IE/Firefox
drogina
I have a chart with a 1px border on the left and right sides. If I set the width to display correctly in IE, it is incorrect in Firefox (and Chrome is all messed up, too). IE seems to calculate the width including the borders and Firefox calculates it without, meaning that in Firefox, it displays two pixels too short/long. From what I've read, this is a known difference between IE and other browsers, but it's not supposed to happen after IE6 and I'm using IE8 (and Firefox 14, if that's relevant).
Since I cannot set the width by %, I was hoping I could just detect the browser and set the width in the beforeFactory method of the report.
I tried:
var agt = navigator.userAgent.toLowerCase();
if (agt.indexOf("firefox") != -1) {
this.getReportElement("chart").setWidth("509px");
} else if (agt.indexOf("msie") != -1) {
this.getReportElement("chart").setWidth("511px");
}
With this, I get the following error:
ReferenceError: "navigator" is not defined.
I'm not a huge fan of hard-coding the width of the object, so alternative suggestions are welcome as well.
Thanks in advance.
Find more posts tagged with
Comments
mwilliams
You could always try something like this, in an HTML text box, if you're wanting it to be set to 100%:
<script type="text/JavaScript">
document.getElementById("myChart").style.width = "100%";
</script>
Just be sure to bookmark your chart as "myChart" in the property editor. Then, you wouldn't have hard coded values for the chart. Also, make sure it's sized close to what you want, in the designer, or the client side script will skew the chart image.
drogina
I gave that a shot, but it doesn't seem to be working.<br />
<br />
I set the bookmark and it shows up like this in the XML source:<br />
<expression name="bookmark" type="javascript">"chart"</expression><br />
<br />
The HTML for the chart renders like this:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
<table id="AUTOGENBOOKMARK_5_251e8351-0cce-453e-a81b-b6fb08a867fb" style="border-collapse: collapse; empty-cells: show; height: 0.427in; width: 100%; overflow:hidden; table-layout:fixed;">
<colgroup><col style=" width: 10px;">
<col>
<col style=" width: 10px;">
</colgroup><tbody><tr valign="top" align="left" style=" height: 10px;" class="style_4">
<td valign="top" style=" overflow:hidden; padding: 0px;">
<div style="position: relative; height: 100%;">
<div style=" height: 10px; width: 100%; position: absolute; left: 0px; overflow:hidden;">
<div>
<img style=" width: 0.104in; height: 0.104in;display: block;" alt="" src="/viewer/preview?__sessionId=20120817_152821_827&__imageid=file7233bb1113935fac7fc16.gif" id="AUTOGENBOOKMARK_6_02bf0a95-885f-4c32-8427-e4e67ed646e5">
</div>
</div>
</div>
</td>
<td valign="top" style=" overflow:hidden; padding: 0px;">
<div style="position: relative; height: 100%;">
<div style=" height: 10px; width: 100%; position: absolute; left: 0px; overflow:hidden;"></div>
</div>
</td>
<td valign="top" style=" overflow:hidden; padding: 0px;">
<div style="position: relative; height: 100%;">
<div style=" height: 10px; width: 100%; position: absolute; left: 0px; overflow:hidden;">
<div>
<img style=" width: 0.104in; height: 0.104in;display: block;" alt="" src="/viewer/preview?__sessionId=20120817_152821_827&__imageid=file7233bb1113935fac7fc17.gif" id="AUTOGENBOOKMARK_7_568788ef-0982-4749-b916-8ed0e1c4f3c5">
</div>
</div>
</div>
</td>
</tr>
<tr valign="top" align="left" class="style_6">
<td valign="top" style=" overflow:hidden;" colspan="3">
<div style=" text-align:left;" id="AUTOGENBOOKMARK_8_7b0c0196-d4b4-466f-976d-cd3ea2f02e10" class="style_7"></div>
</td>
</tr>
</tbody></table></pre>
<br />
Looks like the element ids don't get set properly. I also get a ReferenceError: "chart" is not defined. I set the bookmark property to "chart" (quotes included). Did I miss something?
mwilliams
Can you attach your design? Or send it to me via email?