Sign in to follow this  
mie131085

Best Approach In Accessing Xmldata Inside Fusionchart Object

Recommended Posts

Hi there,

 

just some question here. is this the right way in accessing the XMLdata inside the fusionchart object?

what im trying to achieve is accessing the object fusionchart xmldata that is generated by the server.

 

 

e.g. step 1 : server sending the chartobject to the client side

 


<?php

// serverside programming
// generate fusionchart object on the clientside

echo renderChart("Charts/column3d.swf", "", "<chart><set label='dummy data' value='10000'/></chart>", "myFirst", 400, 300, false, true);

?>

 

Step 2 : on client side, the output will be as in the following format :

 


<!-- START Code Block for Chart myFirst -->
<div id="myFirstDiv">Chart</div>
<script type="text/javascript" ><!--
// Instantiate the Chart 
if ( FusionCharts("myFirst") && FusionCharts("myFirst").dispose ) FusionCharts("myFirst").dispose();
var chart_myFirst = new FusionCharts( {  "swfUrl" : "Charts/column3d.swf",  "width" : "400",  "height" : "300",  "renderAt" : "myFirstDiv",  "dataFormat" : "xml",  "id" : "myFirst",  "dataSource" : "<chart><set label='dummy data' value='10000'/></chart>" } ).render();
// --></script>
<!-- END Script Block for Chart myFirst -->


 

 

 

STEP 3 : question that i wanna ask is regarding on this part.

 


<script type="text/javascript">

// On javascript

// accessing object
var myFusionObject = FusionCharts('myFirst');

// accessing fusionchart xmldata

var myXMLData = myFusionObject.flashVars.dataXML;

</script>

 

is it wise for me to accessing the dataXML thru flashvars? as i can access the xmldata thru IE but didn't seem

to find any other solution in accessing the dataXML on other browser (mozilla, opera, etc) .

hope someone here can help me out on this one as i'm trying to make the chart compatible with other browsers

as well thru javascript

Edited by mie131085

Share this post


Link to post
Share on other sites

Hi,

 

FusionCharts XT provides a plathora of JavaScript functions to make your life easier.

 

For your case, you can use getXMLData() function to get the chart's XML.

 

CODE:

 

<script type="text/javascript">

   // On javascript

   // accessing object
   var myFusionObject = FusionCharts('myFirst');

   // accessing fusionchart xmldata

   var myXMLData = myFusionObject.getXMLData();

</script>

 

The again, there are other ways. For more information please read: FusionCharts XT Documentation > FusionCharts and JavaScript > Getting Data back from chart

 

[EDIT]

 

Plus, it is not wise to use flashvars.

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