Apache flex 在折线图中创建动态线系列

Apache flex 在折线图中创建动态线系列,apache-flex,arraycollection,linechart,Apache Flex,Arraycollection,Linechart,这是我的数组集合 [Bindable]private var Projects:ArrayCollection = new ArrayCollection( [ { Department: "Software", TotalProjects: 73,Completed:30,Inprogress:30,Approved:13}, { Department: "XML",TotalProjects: 50,Completed:20,

这是我的数组集合

 [Bindable]private var Projects:ArrayCollection = new ArrayCollection( [
                { Department: "Software", TotalProjects: 73,Completed:30,Inprogress:30,Approved:13},
                { Department: "XML",TotalProjects: 50,Completed:20,Inprogress:20,Approved:10},
                { Department: "Publishing",TotalProjects: 25,Completed:5,Inprogress:10,Approved:10},
                { Department: "Indesign", TotalProjects: 70,Completed:30,Inprogress:30,Approved:10},
                { Department: "Imaging", TotalProjects: 42,Completed:30,Inprogress:10,Approved:2}]);
折线图的线系列:

<mx:series>


<mx:LineSeries id="cs1"
                                   yField="TotalProjects"
                                   xField="Department"
                                   displayName="TotalProjects">

                </mx:LineSeries>
                <mx:LineSeries id="cs2"
                               yField="Inprogress"
                               xField="Department"
                               displayName="Inprogress">

                </mx:LineSeries>
                <mx:LineSeries id="cs3"
                               yField="Completed"
                               xField="Department"
                               displayName="Completed">

                </mx:LineSeries>
                <mx:LineSeries id="cs4"
                               yField="Approved"
                               xField="Department"
                               displayName="Approved">

                </mx:LineSeries>


            </mx:series>

如何根据数组集合值动态创建
mx:LineSeries
。现在只有4行序列,但有时我必须根据数组集合值的变化显示更多,例如:如果在数组集合中添加一个状态
HoldProject

var series:Array=[];
for (var prop:String in Projects[0])
    if (prop != "Department") {
        var ls:LineSeries=new LineSeries();
        ls.yField=prop;
        ls.xField="Department";
        s.displayName=prop;
        series.push(ls);
    }
myChart.series=series;

在这种情况下,数据提供程序中的每个项都应具有相同的属性集。

OK。如果每次我都收到具有不同属性的数组集合对象,如何循环数组集合项并创建行序列?请提供更多详细信息?因为,我们怎么知道每个项目中应该使用哪个字段作为yField?给定的数组集合中的@Timofei Davydik
部门
很常见,但剩余字段有时仅改变3种状态:
完成
保留
批准
,有时更多的是
完成
保留
已批准
已删除
初始
延迟
等。@Timofei-Davydik不错,但在
道具
中,取回的不是属性(部门),而是值(软件)。如何从项目[0]获取属性?@M.S.Nayak是否确实复制了代码?在my code
for…var
循环中,它检索属性。和
对于每个…var
循环检索值。请确保您正在为…var使用