FusionCharts for Flex API is used to retrieve the chart/widget data as XML.
The following code demonstrates the process of implementing the methods of FusionCharts for Flex API to obtain chart/widget data as XML string:<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
xmlns:ns1="com.fusioncharts.components.*" >
<ns1:FusionCharts id="myChart" x="200" y="150" FCChartType="Column3D" FCRenderEvent="showXML()">
<ns1:FCChartData FCData="{chartData}" FCParams="{chartParams}"/>
</ns1:FusionCharts>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import com.events.FCEvent;
//Create an ArrayCollection object as a data source for chart
[Bindable]
private var chartData:ArrayCollection=new ArrayCollection([
{ label:'Jan', value:'17400' },
{ label:'Feb', value:'19800' },
{ label:'Mar', value:'21800' },
{ label:'Apr', value:'23000' },
{ label:'May', value:'29000' },
{ label:'Jun', value:'27600' }
]);
//Create an ArrayCollection object as a data source for chart parameters
[Bindable]
private var chartParams:ArrayCollection=new ArrayCollection([
{ caption:'Half Yearly Sales Summary' },
{ subcaption:'For the year 2008 - First Half' },
{ xAxisName:'Month' },
{ yAxisName:'Sales' },
{ numberPrefix:'$' }
]);
private function showXML():void { // Get XML data using FusionCharts For Flex API function - FCGetXMLData()
var str:String = myChart.FCGetXMLData();
Alert.show(str);
}
]]>
</mx:Script>
</mx:Application>
In the code, showXML() function is attached to the FCRender event. This function invokes the FCGetXMLData() method of the FusionCharts object. The XML string generated by the method is returned through an alert box. Following output screen will be displayed when the code is executed.