Flex图表篇(mx:ColumnChart)

<?xml version="1.0"?>
<!-- Simple example to demonstrate the ColumnChart and BarChart controls. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

    <mx:Script>
        <![CDATA[
         
        import mx.collections.ArrayCollection;

        [Bindable]
        private var salesDept_1:ArrayCollection = new ArrayCollection( [
            { SalesDept: "销售一部", tract: 3500, gather:3400 },
            ]);
         private var salesDept_2:ArrayCollection = new ArrayCollection( [
            { SalesDept: "销售二部", tract: 2000, gather:1400 },
            ]);
         //这里定义的是数据源
        ]]>
    </mx:Script>

    <mx:Panel title="ColumnChart and BarChart Controls Example"
        height="100%" width="50%" layout="horizontal">

        <mx:ColumnChart id="column" height="100%" width="45%"
            paddingLeft="5" paddingRight="5"
            showDataTips="true" dataProvider="{salesDept_1}">
               
            <mx:horizontalAxis>
                <mx:CategoryAxis categoryField="SalesDept"/>
            </mx:horizontalAxis>

            先制定柱子按照数据源的什么分类,然后在后面的series中指定每一个分类中的具体小类
             //在中里我们指定柱子显示的方向,horizontalAxis表示竖向显示,

            /*

            <mx:verticalAxis>
                <mx:CategoryAxis categoryField="Country"/>
            </mx:verticalAxis>

           表示横向显示

 

           */
            <mx:series>
                <mx:ColumnSeries xField="SalesDept" yField="tract" displayName="签单"/>
                <mx:ColumnSeries xField="SalesDept" yField="gather" displayName="到帐"/>
               //displayName表示图表显示出来的名字yField表示数据显示的字段
            </mx:series>
        </mx:ColumnChart>

        <mx:Legend dataProvider="{column}"/>
 <mx:HBox>
            <mx:RadioButton groupName="stocks" label="销售一部"
                selected="true" click="column.dataProvider=salesDept_1;"/>
            <mx:RadioButton groupName="stocks" label="销售二部"
                click="column.dataProvider=salesDept_2;"/>
        </mx:HBox>
    </mx:Panel>
</mx:Application>

你可能感兴趣的:(xml,Flex,Adobe)