FusionCharts for Flex > Chart Creation > Stacked Charts > Data from Array

In this section we'll explain the method of creating a stacked chart using Array as a medium for providing data.

 
Before you continue, we recommend that you go through "Your First Chart" section, as we start off from the concepts explained in that section.
 

In the following code chart data is provided through an Array object:

<?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="StackedColumn3D">
          <ns1:FCChartData FCData="{chartData}" FCParams="{chartParams}"/>
     </ns1:FusionCharts>

     <mx:Script>
          <![CDATA[

          import mx.collections.ArrayCollection;

          // Create an ArrayCollection object for chart data
          [Bindable]
          private var chartData:ArrayCollection=new ArrayCollection([

              {label:'Jan'},
              {label:'Feb'},
              {label:'Mar'},
              {label:'Apr'},
              {label:'May'},
              {label:'Jun'},
              {seriesName:'Product A'},
              {value:'27400'},
              {value:'29800'},
              {value:'25800'},
              {value:'26800'},
              {value:'29600'},
              {value:'23600'},
              {seriesName:'Product B'},
              {value:'10000'},
              {value:'11500'},
              {value:'12500'},
              {value:'15000'},
              {value:'11000'},
              {value:'9800'}
          ]);

          //Create an ArrayCollection object as a data source for chart parameters

          [Bindable]
          private var chartParams:ArrayCollection=new ArrayCollection([                
                           { caption:'Company Revenue' },
                           { xAxisName:'Month' },
                           { yAxisName:'Sales' },
                           { numberPrefix:'$' },
                           { showValues:'0' }                
              ]);


    
     ]]>
     </mx:Script>
</mx:Application>

 
In the code, we have passed data through an ArrayCollection object named chartData. It is essential that only data in appropriate format be provided to the object. We have also created another ArrayCollection object named chartParams for storing chart parameters and binding them to FCParams attribute. The following chart will be produced upon execution of the code: