FusionCharts for Flex > Chart Creation > Stacked Charts > Data from XML List

Here, we'll show how to send data to a Stacked chart using XMLList. For example, here we will build a Stacked Column 3D Chart using XMLList as data source.

Before you go further, we recommend you to see the section "Your First Chart" , as we start off from the concepts explained in that page.
 
We would follow the previous Array example and modify the code a bit. Here, we would bind FCData and FCParams attributes to XMLList objects. The code will look like given below:

 

<?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.data[0]}" FCParams="{chartParams.param[0]}"/>
   </ns1:FusionCharts>   <mx:Script>
         <![CDATA[

         // Create a XMLList object for chart data
         [Bindable]
         private var chartData:XML=
              <main>
                   <data>
                         <categories>
                                <data label='Jan'/>
                                <data label='Feb'/>
                                <data label='Mar'/>
                                <data label='Apr'/>
                                <data label='May'/>
                                <data label='Jun'/>
                         </categories>
                         <dataset seriesName='Product A'>
                                <data value='27400' />
                                <data value='29800' />
                                <data value='25800' />
                                <data value='26800' />
                                <data value='29600' />
                                <data value='23600' />
                         </dataset>
                         <dataset seriesName='Product B'>
                                <data value='10000' />
                                <data value='11500' />
                                <data value='12500' />
                                <data value='15000' />
                                <data value='11000' />
                                <data value='9800' />
                         </dataset>
                    </data>
              </main>;

          //Create a XMLList object for chart parameters
          [Bindable]
          private var chartParams:XML=
              <main>
                   <param>
                         <params caption='Company Revenue' 
                         xAxisName='Month' yAxisName='Revenue' 
                         numberPrefix='$' showValues='0' />
                   </param>
              

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

 
As you see in the above code, we passed data through a XMLList object named chartData. For this, we created the object with valid chart data. We also created another xmlList object, chartParams, to store the chart parameters and bind it to FCParams attribute. Now, if you run the above code you will get the following figure.