Sign in to follow this  
TEX

Loading data from external XML file

Recommended Posts

The Knowledge Base Q10068 - "HOWTO: I want to load an external XML file inside my chart loaded in a Flash movie/application" (http://www.fusioncharts.com/KB/article.aspx?id=10068&cNode=1F3K5Y) shows how to load data from external file, but id doesnt works on my SWF file.

 

 

 

The source is:

 

 

 

--------------

 


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

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



import com.fusioncharts.core.charts.Pie3DChart;



XMLFile = "Pie3D.xml";



var xmlData:XML = new XML();

xmlData.load(XMLFile);

xmlData.onLoad = function(exito) {



if (exito){

trace(xmlData)



var chartContainer1MC:MovieClip = this.createEmptyMovieClip("ChartHolder1", 1);

var chart1:Pie3DChart = new Pie3DChart(chartContainer1MC, 1, 380, 325, 20, 15, false, "EN", "noScale");

chart1.setXMLData(xmlData);

chart1.render();



}

else trace("Where is " + XMLFile + "?");



};



stop();

 

--------

 

 

 

PD: the smile is ": P", [ code ][ / code ] doesnt works with the emoticons.

 

 

 

If you publish the movie the charts doesnt appears on the movie.

 

 

 

Any suggestion?

 

 

 

Thanks.

Share this post


Link to post
Share on other sites
Pallav (3/14/2007)
You'll need to load the XML file in your custom XML objects in Flash and then pass that XMl to the loaded chart.

 

 

 

How to do this?? can you give me the example?

Share this post


Link to post
Share on other sites

Hello, I made some changes to the code:

 

 

 

XMLFile = "datos.xml";

 

 

 

 

 

var xmlData:XML = new XML();

 

xmlData.ignoreWhite = true;

 

xmlData.load(XMLFile);

 

xmlData.onLoad = function(exito) {

 

 

 

if (exito){

 

trace(xmlData)

 

 

 

}

 

else trace("Where is " + XMLFile + "?");

 

 

 

};

 

 

 

var chartContainer1MC:MovieClip = this.createEmptyMovieClip("ChartHolder1", 1);

 

var chart1:MSColumn3DChart = new MSColumn3DChart(chartContainer1MC, 1, 380, 325, 20, 15, true, "EN", "noScale");

 

chart1.setXMLData(xmlData);

 

chart1.render();

 

 

 

stop();

 

 

 

I get the debugger to work, the xml traces perfectly, but syill no char snowing...please try this an see the debuging message:

 

 

 

Info: Chart loaded and initialized.

 

Initial Width: 380

 

Initial Height: 325

 

Scale Mode: noScale

 

Debug Mode: Yes

 

Application Message Language: EN

 

Version: 3.0.2

 

Chart Type: Multi Series 3D Column Chart

 

Chart Objects:

 

BACKGROUND

 

CANVAS

 

CAPTION

 

SUBCAPTION

 

YAXISNAME

 

XAXISNAME

 

DIVLINES

 

YAXISVALUES

 

DATALABELS

 

DATAVALUES

 

TRENDLINES

 

TRENDVALUES

 

DATAPLOT

 

TOOLTIP

 

VLINES

 

LEGEND

 

 

 

ERROR: No data to display. There isn't any node/element in the XML document. Please check if your dataURL is properly URL Encoded or, if XML has been correctly embedded in case of dataXML.

 

No Data to Display: No data was found in the XML data document provided. Possible cases can be:

 

There isn't any data generated by your system. If your system generates data based on parameters passed to it using dataURL, please make sure dataURL is URL Encoded.

 

You might be using a Single Series Chart .swf file instead of Multi-series .swf file and providing multi-series data or vice-versa.

Share this post


Link to post
Share on other sites

Hello again, I managed to make it work, not loading an xml but putting the xml code inside flash:

 

 

 

var strXML:String = "pasteheretheXMLfilecontentwithnospaces";

 

 

 

var xmlData:XML = new XML(strXML);

 

 

 

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

 

var myChart:MSColumn3DChart = new MSColumn3DChart(chartContainerMC, 1, 450, 325, 5, 38, false, "EN", "noScale");

 

myChart.setXMLData(xmlData);

 

myChart.render();

 

 

 

the thing is that the xml should be with no spaces, I've made the same for the xml file but it didn't work, it has to be done inside flash.....hope this work for you too.

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