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

发布于 2024-12-08 22:24:01 字数 1815 浏览 0 评论 0原文

这是我的

 [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 添加到数组集合中?

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"
                               displayName="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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黎夕旧梦 2024-12-15 22:24:02
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 中的每个项目都应具有相同的属性集。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文