FusionCharts for Flex provides several XML attributes, which can be used to manipulate the export related properties such as default export format, default export file name, etc. The following example illustrates how these XML attributes are implemented. In the following example, the export action is enabled and the default file name is set to fusioncharts_export.
<?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 x="10" y="10" FCChartType="Column3D">
<ns1:FCChartData FCData="{chartData}" FCParams="{chartParams}"/>
</ns1:FusionCharts>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
//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:'$' },
{ exportEnabled:'1' },
{ exportFileName:'fusioncharts_export'}
]);
]]>
</mx:Script>
</mx:Application>
In the above code, data has been provided using standard ArrayCollection objects. The XML attributes - exportEnabled and exportFileName, enables the chart to export and specify a default file name for the chart/widget respectively.
The following XML attributes help in controlling all aspects of the export process. These attributes must be specified within the <chart> tag:
Attribute Name | Type | Description |
---|---|---|
exportEnabled | Boolean (0/1) | Using this attribute you can enable or disable the export feature. |
exportShowMenuItem | Boolean (0/1) | Using this attribute you get to determine whether or not should export related options (such as ‘Save as JPEG’) be displayed in the chart’s/widget's context menu. |
exportFormats | String | Using this attribute you can determine the list of conversion formats that are displayed in the context menu. The value of this attribute should be a delimiter separated key-value pair. The delimiter character to be used is '|' (pipe character). The syntax for the attribute value is KEY=Value[|KEY=Value]*. Example: The code required to enable PNG, JPG, and PDF type of export with custom context-menu message for PNG and PDF. exportType="PNG=Export as High Quality Image|JPG|PDF=Export as PDF File" |
exportFileName | String | Using this attribute you can specify a default name for the exported file. |