When the export of charts/widgets to image or PDF is completed, an event named FCExported is triggered.
The FCExported event returns an object of FCEvent type. This object contains three export callback parameters:
The following example shows, how to trap the FCExported event. The parameters returned by the event will be displayed in an alert box:
<?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="10" y="10" FCChartType="Column3D"
FCExported="callBack(event)">
<ns1:FCChartData FCData="{chartData}" FCParams="{chartParams}"/>
</ns1:FusionCharts>
<mx:Script>
<![CDATA[
import com.events.FCEvent;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
//Create an object as a data source for chart
[Bindable]
private var chartData:ArrayCollection=new ArrayCollection([
{ label:'Jan', value:'17400' },
...
{ label:'Jun', value:'27600' }
]);
//Create an object as a data source for chart parameters
[Bindable]
private var chartParams:ArrayCollection=new ArrayCollection([
{ caption:'Half Yearly Sales Summary' },
...
{ numberPrefix:'$' }
]);
private function callBack(e:FCEvent):void {
Alert.show(
e.param.success + "\n"
+ e.param.fileFormat + "\n"
+ e.param.fileName);
}
]]>
</mx:Script>
<mx:Button x="200" y="320" label="Export Chart"
click="myChart.FCExportChart('PNG')" />
</mx:Application>
Firstly, we register our callback function callBack with the FCExported event in the FusionCharts tag.
<ns1:FusionCharts ... FCExported="callBack(event)">
Next, we define a callback function, which will return the three parameters through an alert box.
The export operation is initiated by a click event associated with a button.