<?xml version="1.0"?>
<!-- Simple example to demonstrate the ColumnChart and BarChart controls. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.charts.chartClasses.Series;
import mx.charts.series.ColumnSeries;
import mx.collections.ArrayCollection;
[Bindable]
private var medalsAC:ArrayCollection=new ArrayCollection([
{Country: "第一组", Gold: 35, Silver: 39, Bronze: 29},
{Country: "第二组", Gold: 10, Silver: 20, Bronze: 29}
]);
private function init():void
{
var arr:Array=new Array();
var c1:ColumnSeries=new ColumnSeries();
c1.xField="Country";
c1.yField="Gold";
c1.displayName="Gold";
var c2:ColumnSeries=new ColumnSeries();
c2.xField="Country";
c2.yField="Silver";
c2.displayName="Silver";
var c3:ColumnSeries=new ColumnSeries();
c3.xField="Country";
c3.yField="Bronze";
c3.displayName="Bronze";
arr.push(c1);
arr.push(c2);
arr.push(c3);
column.series=arr;
column.dataProvider=medalsAC;
}
]]>
</mx:Script>
<mx:Panel title="ColumnChart and BarChart Controls Example"
height="100%"
width="100%"
layout="horizontal">
<mx:ColumnChart id="column"
height="100%"
width="100%"
paddingLeft="5"
paddingRight="5"
showDataTips="true"
dataProvider="{medalsAC}">
<mx:horizontalAxis>
<mx:CategoryAxis categoryField="Country"/>
</mx:horizontalAxis>
</mx:ColumnChart>
<mx:Legend dataProvider="{column}"/>
</mx:Panel>
</mx:Application>转载于:https://blog.51cto.com/programmer/1255923
