Sign in to follow this  
compulsiveguile

Sample Chart Works With Setxmlurl But Not Setxmldata

Recommended Posts

I'm having the following issue while trying to embed a sample chart in my Grails project. Here is my sample code.

 


<title>Charts</title>

<meta name="layout" content="main" /> 

   <script type="text/javascript" src="/atpview/js/MyChart/FusionCharts/FusionCharts.js"></script>

</head>
<body>
	<div id="chartContainer">FusionCharts will load here!</div>          
   	<script type="text/javascript"><!--

     	FusionCharts._fallbackJSChartWhenNoFlash(); 

     		var myChart = new FusionCharts("atpview/js/MyChart/FusionCharts/Column3D.swf'",
     		"myChartId", "400", "300", "0", "1" );

     		myChart.setXMLData("<chart caption='Weekly Sales Summary'xAxisName='Week' yAxisName='Sales' numberPrefix='><set label='Week 1' value='14400' /><set label='Week 2' value='19600' /><set label='Week 3' value='24000' /><set label='Week 4' value='15700' /></chart>")

     		myChart.render("chartContainer");
  		// --> 	
	</div>
</body> 			
<html>

This works fine and shows up as expected when I navigate to the appropriate page in a flash capable browser. However when I view this on an iOS device, I get an invalid data error. If I replace the setXMLData with setXMLUrl (pulling from a static XML file), everything works fine. The flash chart shows up in a flash-enabled browser and the javascript chart shows up in the iOS browser.

 

If I also add FusionCharts.setCurrentRenderer('JavaScript') while using setXMLData, neither works. If I change it to setXMLUrl, both browsers (including Safari in iOS) display correctly.

I'm quite confused... Anyone know what I'm doing wrong?

Edited by compulsiveguile

Share this post


Link to post
Share on other sites
Guest Angie

Hi,

 

Welcome to FusionCharts Forum!smile.gif

 

Please find the modified code attached for your reference.

 

Please make sure to edit the path of js and swf file.

 

Hope this helps.smile.gif

testsample.html

Share this post


Link to post
Share on other sites

Thanks for the response! Still a little confused (and still don't have it working), though. So I gather that my issue is with reference paths to my js and swf files?... but this doesn't explain to me why I was having the issue I was. If my path to the swf or js file was wrong, I wouldn't see a graph at all, regardless of Flash or no Flash, right?

 

Also, I don't see how this explains why FusionCharts.setCurrentRenderer('JavaScript') works but only when I reference an XML static file opposed to a directly typed XML string. Unless I'm missing something, the xml string change you made is the exact same thing I had except it's a little cleaner.

 

How exactly does the FusionCharts._fallbackJSChartWhenNoFlash(); method work? Does an absolute path "break" things? In my Grails project, I dynamically link to a resource folder... which creates the "absolute" link I have specified. I'm wondering if there are some subtleties that I'm failing to understand in the context of Grails.

<script type="text/javascript"><!--

     	FusionCharts._fallbackJSChartWhenNoFlash(); 

     		var myChart = new FusionCharts( "${createLinkTo(dir:'MyChart/FusionCharts/Column3D.swf')}",

     		"myChartId", "400", "300", "0", "1" );



     		myChart.setXMLData("${xmlData}");

     		myChart.render("chartContainer");

  		// --> 	

 		</script>


I know this is potentially a lot of complication over a forum post. In case it's of relevance, I'm part of a company that is looking to incorporate FusionCharts into our software... we're using a trial right now and will definitely be buying if we can get our questions answered. I'd love to talk over the phone which I understand is only available if we shell out the $$$... but we're not going to shell out the $$$ unless we know we can get the support we'll need :).

 

 

Hi,

 

Welcome to FusionCharts Forum!smile.gif

 

Please find the modified code attached for your reference.

 

Please make sure to edit the path of js and swf file.

 

Hope this helps.smile.gif

Edited by compulsiveguile

Share this post


Link to post
Share on other sites

Figured out my issue... *head desk.* Forgot about the fact that I needed to output the right context for javascript ... thus I needed extra quotes and +'s. Apparently the swf is able to pick-up/recover from improper content... which made figuring out this issue way more complicated.

 

myChart.setXMLData("this should all 		//<-- newline here... INCORRECT
be on one line" );

 

is obviously not the same as

 

 

myChart.setXMLData("this should all" +   	// <-- CORRECT
"be on one line" );

 

Lose focus for a second and somebody will get hurt... :)

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