FusionCharts Support

External XML

Recommended Posts

Hi.

 

 

 

I'm brand new to Fusion Charts, and I'm trying to get MyFirstChart working with an external XML doc, rather than what's hardcoded in Flash. This will be for a standalone desktop application, so it will not be run through a web browser.

 

 

 

I got the chart operational as a Multi-Series 3DChart with this hardcoded:

 

 

 

var strXML:String = "";

strXML = strXML + "";

strXML = strXML + "";

strXML = strXML + "";

strXML = strXML + "";

strXML = strXML + "";

strXML = strXML + "";

strXML = strXML + "";

strXML = strXML + "";

strXML = strXML + "";

strXML = strXML + "";

strXML = strXML + "";

strXML = strXML + "";

strXML = strXML + "";

strXML = strXML + "";

strXML = strXML + "";

strXML = strXML + "";

strXML = strXML + "";

strXML = strXML + "";

strXML = strXML + "";

strXML = strXML + "";

strXML = strXML + "";

strXML = strXML + "";



//FusionCharts chart classes accept XML data as XML Object

//and not XML String.

//So, if you've an XML string, first create an XML object from it

//and then pass to the chart. We do the same.

var xmlData:XML = new XML(strXML);

// --------------------------------------------------- //



// -------------- Actual Code to create the chart ------------//

//To create a chart, you first need to create an empty movie clip to act as chart holder.

var chartContainerMC:MovieClip = this.createEmptyMovieClip("ChartHolder",1);

//Now, instantiate the chart using Constructor function of the chart.

var myFirstChart:MSColumn3DChart = new MSColumn3DChart(mc_chartHolder, 1, 645, 436, 0, 0, false, "EN", "noScale");

//Convey the XML data to chart.

myFirstChart.setXMLData(xmlData);

//Draw the chart

myFirstChart.render();

//Stop

stop();

 

 

 

Sorry to bug you guys with something so basic, but I am stuck stuck stuck. So how do I adjust the actionscript to access an external XML?

Edited by Guest

Share this post


Link to post
Share on other sites

Hi,

Can try with the following code?

 

#include "com/fusioncharts/includes/LoadingFunctions.as"

 

#include "com/fusioncharts/includes/AppMessages.as"

 

import com.fusioncharts.core.charts.Column2DChart;

var xmlData:XML = new XML();

xmlData.onload=function(success){

 

var chartContainerMC:MovieClip = createEmptyMovieClip("ChartHolder",1);

var myFirstChart:Column2DChart = new Column2DChart(chartContainerMC, 1, 450, 225, 20, 0, false, "EN", "noScale");

myFirstChart.setXMLData(xmlData);

myFirstChart.render();

}

xmlData.load("myxmlfile.xml");

stop();

ALGO:

1. import classes required for chart

2. Create XML object

3. use XML.load() to load XML from external file

4. **IMPORTANT** create .onLoad event listner which would be called when the XML is completly loaded

5. Render the chart once the XML is Loaded

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