开发者

creating dynamic lineseries in linechart

This is my array collection

 [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}]);

line series for line chart:

<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"
                               displa开发者_开发百科yName="Approved">

                </mx:LineSeries>


            </mx:series>

how can i create mx:LineSeries dynamically depending upon array collection values. Now only 4 line series is there but some times i have to show more as per the array collection values change ex: if one more status HoldProject added to array collection?


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;

In this case, each item in your dataProvider should have the same property set.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜