Sign in to follow this  
Ross

Ie & Chrome Xml (Php Generated) Issue - Firefox Is Fine Fusioncharts

Recommended Posts

Greetings,

 

I've been testing writing code with you Fusioncharts library and I'm running into a problem whereby I'm generating XML output using PHP and calling the PHP file via fusionchart Javascript call setXMLUrl. The chart displays fine in Firefox, but in IE9 or Chrome, the chart simply shows "Error in Loading Data" in IE9 and "Invalid Data" in Chrome.

 

The code I'm using to create the chart is:

 

 	var skuArr= id.split("_");
 	var strURL = "./usa_npalerts.php?id=graph&sku=" + skuArr[0];
 	var timestamp = Math.round(new Date().getTime() / 1000);
 	strURL = strURL + "&token=" + timestamp;
 	strURL = escape(strURL);		
 	FusionCharts.setCurrentRenderer('javascript'); 
 	FusionCharts.debugMode.enabled(true);
 	FusionCharts.debugMode.outputTo(console.log);
 	FusionCharts.debugMode.outputFormat('verbose');
 	//FusionCharts.debugMode._enableFirebugLite();
 	if( FusionCharts( "Sales" ) )  FusionCharts( "Sales" ).dispose();
 	var chartObj = new FusionCharts("../FusionChartsXT/Charts/Line.swf","Sales","442","380","0","1");
 	//strURL="test.xml";
 	chartObj.setXMLUrl(strURL);

 

A couple more pieces of info:

 

The site is using SSL, however I have already elimintated the pragma headers as described numerous times on these forums.

 

If I save the XML output of the PHP file to an xml file on the server and call it the xml file directly, the chart displays in IE and Chrome and Firefox.

 

If I try to debug the issue in IE9 - I get the following error which is cryptic:

 

ie_debug.JPG

In Chrome, I get yet another error:

 

chrome_err.JPG

 

 

The raw xml that the PHP file generates is below and will render fine, but when calling PHP file directly, I get an error in IE and Chrome:

<chart bgAlpha='0' useRoundedEdges='1' showBorder='0' bgcolor='000000' caption='Weekly Unit Sales - 533829' xAxisName='Week Ending' yAxisName='Sales' decimalPrecision='0' formatNumberScale='0'>
 <set showValue='1' name='21' value='1737' color='AFD8F8' link='j-LimitNPMap-21' />
 <set showValue='0' name='22' value='1834' color='AFD8F8' link='j-LimitNPMap-22' />
 <set showValue='0' name='23' value='1995' color='AFD8F8' link='j-LimitNPMap-23' />
 <set showValue='0' name='24' value='2229' color='AFD8F8' link='j-LimitNPMap-24' />
 <set showValue='1' name='25' value='2016' color='AFD8F8' link='j-LimitNPMap-25' />
 <set showValue='0' name='26' value='1988' color='AFD8F8' link='j-LimitNPMap-26' />
 <set showValue='0' name='27' value='2160' color='AFD8F8' link='j-LimitNPMap-27' />
 <set showValue='0' name='28' value='1349' color='AFD8F8' link='j-LimitNPMap-28' />
 <set showValue='1' name='29' value='1817' color='AFD8F8' link='j-LimitNPMap-29' />
 <set showValue='0' name='30' value='2022' color='AFD8F8' link='j-LimitNPMap-30' />
 <set showValue='0' name='31' value='2136' color='AFD8F8' link='j-LimitNPMap-31' />
 <set showValue='0' name='32' value='1276' color='AFD8F8' link='j-LimitNPMap-32' />
 <set showValue='1' name='33' value='1646' color='AFD8F8' link='j-LimitNPMap-33' />
 <set showValue='0' name='34' value='1771' color='AFD8F8' link='j-LimitNPMap-34' />
 <set showValue='0' name='35' value='1128' color='AFD8F8' link='j-LimitNPMap-35' />
 <set showValue='0' name='36' value='1596' color='AFD8F8' link='j-LimitNPMap-36' />
 <set showValue='1' name='37' value='1093' color='AFD8F8' link='j-LimitNPMap-37' />
 <trendLines>
<line isTrendZone='1' alpha='20' startValue='1737' endValue='1093' color='FF0000' displayValue='Average'></line>
 </trendLines>
</chart>

 

I'm guessing there must be some leading or trailing garbage that is messing up the auto-generated php, but unfortunately I can't use Firebug because it works fine in Firefox!

 

Any help would be appreciated!

 

R

Share this post


Link to post
Share on other sites

Ok, here is the simple answer - it appears that IE and Chrome expect a \n character after the last output of your XML, so make sure this is in there. Firefox doesn't care either way. BTW for those folks having similar errors - I ended up finding this our by writing the output to a file and using

diff

from linux command linebetween the two files - it faithfully reported the lack of a newline. When I had copied and pasted the output into a local file the editor i pasted it in must have created a trailing \n when pasted which is why the flat xml file I referenced above worked and not the straight PHP output.

 

Cheers,

 

R

Edited by Ross

Share this post


Link to post
Share on other sites
Guest Angshu

Hi,

 

Welcome to FusionCharts Forum! smile.gif

 

Thank you very much for your valuable feedback.

 

Happy FusionCharting! biggrin.gif

Share this post


Link to post
Share on other sites
Guest Rishi Choudhari

Ok, here is the simple answer - it appears that IE and Chrome expect a \n character after the last output of your XML, so make sure this is in there. Firefox doesn't care either way. BTW for those folks having similar errors - I ended up finding this our by writing the output to a file and using

diff

from linux command linebetween the two files - it faithfully reported the lack of a newline. When I had copied and pasted the output into a local file the editor i pasted it in must have created a trailing \n when pasted which is why the flat xml file I referenced above worked and not the straight PHP output.

 

Cheers,

 

R

 

When you're using dynamically generated XML to create charts, you should use 'setXMLData' to pass this XML string.

 

'setXMLUrl' should be used when the XML is in a static file.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this