这是我的数组集合
[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
添加到数组集合中吗?
答案 0 :(得分:2)
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中的每个项目都应具有相同的属性集。