我有一个动态ArrayCollection
,它将包含未知数量的类型对象MyObj
:
class MyObj
{
type:String
value:long
}
每个MyObj
对象都有不同的值type
。
如何从该数组构建单个堆叠条,其中堆叠条的每个部分表示MyObj
(表示 a type
)的对象,其长度为value
?
我有一个动态ArrayCollection
,它将包含未知数量的类型对象MyObj
:
class MyObj
{
type:String
value:long
}
每个MyObj
对象都有不同的值type
。
如何从该数组构建单个堆叠条,其中堆叠条的每个部分表示MyObj
(表示 a type
)的对象,其长度为value
?
检查此代码:
<?xml version="1.0" encoding="utf-8"?>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
private var countries:ArrayCollection = new ArrayCollection( [
{ Country: "Romania", Romanians: 0.7, Hungarians:0.2, Germans: 0.1 }]);
]]>
</mx:Script>
<mx:Panel title="BarChart Control" layout="horizontal" color="0xffffff" borderAlpha="0.15" width="600" height="240"
paddingTop="10" paddingRight="5" paddingBottom="10" paddingLeft="5" horizontalAlign="center">
<mx:BarChart id="bar" height="100%" color="0x323232" type="stacked"
showDataTips="true" dataProvider="{countries}">
<mx:verticalAxis>
<mx:CategoryAxis categoryField="Country"/>
</mx:verticalAxis>
<mx:series>
<mx:BarSeries yField="Country" xField="Romanians" displayName="Romanians"/>
<mx:BarSeries yField="Country" xField="Hungarians" displayName="Hungarians"/>
<mx:BarSeries yField="Country" xField="Germans" displayName="Germans"/>
</mx:series>
</mx:BarChart>
<mx:Legend dataProvider="{bar}" color="0x323232"/>
</mx:Panel>