Sunday, 4 March 2012

Simple Charts(bar chart)


<?xml version="1.0"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
  <mx:Script><![CDATA[
     import mx.collections.ArrayCollection;
     [Bindable]
     public var arr:ArrayCollection = new ArrayCollection([
        {Month:"Jan", Income:2000, Expenditure:1500},
        {Month:"Feb", Income:1000, Expenditure:200},
        {Month:"Mar", Income:1500, Expenditure:500},
{Month:"Apr", Income:1002, Expenditure:226},
{Month:"May", Income:2566, Expenditure:566},
{Month:"Jun", Income:4478, Expenditure:476},
{Month:"Jul", Income:7654, Expenditure:3654},
{Month:"Aug", Income:1112, Expenditure:655},
{Month:"Sep", Income:6546, Expenditure:244},
{Month:"Oct", Income:545, Expenditure:445},
{Month:"Nov", Income:2435, Expenditure:654},
{Month:"Dec", Income:6354, Expenditure:356}

     ]);
  ]]></mx:Script>
  <mx:Panel title="My Bar Chart">
     <mx:BarChart id="BarChart" dataProvider="{arr}" showDataTips="true">
        <mx:verticalAxis>
           <mx:CategoryAxis
                dataProvider="{arr}"
                categoryField="Month"
           />
        </mx:verticalAxis>
        <mx:series>
           <mx:BarSeries
                yField="Month"
                xField="Income"
                displayName="Income"
           />
           <mx:BarSeries
                yField="Month"
                xField="Expenditure"
                displayName="Expenditure"
           />
        </mx:series>
     </mx:BarChart>
     <mx:Legend dataProvider="{BarChart}"/>
  </mx:Panel>
</mx:Application>

No comments:

Post a Comment