Apache flex 向ArrayCollection Flex添加关键字
我正在通过一个循环创建一个ArrayCollection,然后想使用这个ArrayCollection来构建一个折线图。唯一的问题是,我的ArrayCollection中只有值,没有用于构建折线图的关键字。如何将关键字添加到ArrayCollection?或者,有没有一种方法可以构建一个没有关键字的折线图 以下是创建arraycollection的代码:Apache flex 向ArrayCollection Flex添加关键字,apache-flex,actionscript,flex4,Apache Flex,Actionscript,Flex4,我正在通过一个循环创建一个ArrayCollection,然后想使用这个ArrayCollection来构建一个折线图。唯一的问题是,我的ArrayCollection中只有值,没有用于构建折线图的关键字。如何将关键字添加到ArrayCollection?或者,有没有一种方法可以构建一个没有关键字的折线图 以下是创建arraycollection的代码: [Bindable] public var Graph_:ArrayCollection; public function
[Bindable] public var Graph_:ArrayCollection;
public function populateArray():void {
var Graph_:ArrayCollection = new ArrayCollection();
for (var i:int=0; i<=500; i++){
var depth_:Number = i*10;
var pressure:Number = 100+i;
Graph_.addItem([depth_,pressure]);
}
// I want to use it further in this way:
<mx:LineChart id="chart"
dataProvider= "{Graph_}"
showDataTips="true">
<mx:horizontalAxis>
<mx:CategoryAxis categoryField="Depth" />
</mx:horizontalAxis>
<mx:series>
<mx:LineSeries yField="Pressure" form="curve" displayName="Pressure"/>
</mx:series>
</mx:LineChart>
[Bindable]公共var图\数组集合;
公共函数populateArray():void{
变量图:ArrayCollection=新的ArrayCollection();
对于(var i:int=0;i这是@Brian Bishop建议您做的:
public function populateArray():void {
Graph_ = new ArrayCollection();
for (var i:int=0; i<=500; i++) {
var depth_:Number = i*10;
var pressure:Number = 100+i;
// add an object who's property names are "depth", "pressure"
// use these names when configuring the axis/line series of the chart
Graph_.addItem({ depth: depth_, pressure: pressure });
}
}
公共函数populateArray():void{
Graph_1;=新的ArrayCollection();
对于(var i:int=0;i创建一个对象,将字段添加到其中,将对象添加到arrayCollection