这是我的数组集合
[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行系列有,但有时我必须显示更多的按照数组集合值的变化ex:如果一个更多的状态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;
在本例中,dataProvider中的每个项应该具有相同的属性集。