我应该如何在 Flex 中格式化 HTTPService 结果,以便可以通过饼图访问它?

发布于 2024-09-06 02:08:41 字数 1455 浏览 3 评论 0原文

我觉得这应该很简单,但是我在网上看到的每个地方都有人做不同的事情。我正在做一个小型图表应用程序来跟踪下载统计信息,并希望将数据放入饼图中。我是 Flex 新手,所以如果我的代码很糟糕,我深表歉意。

<s:HTTPService id="service"
    url="admin/stats/totalstats.php" 
    fault="service_faultHandler(event)"
    result="service_resultHandler(event)" />

用于此目的的最佳 resultFormat 是什么?如果我将返回值分配给 ActionScript 变量,它应该是 ArrayList 吗?数组集合?

这是从 HTTPService 返回的 XML 示例,

<DownloadStats>
    <year count="24522" year="2008">
        <month count="20" month="5" year="2008" full="May 2008">
            <day count="2" month="5" day="20" year="2008"/>
            <day count="1" month="5" day="21" year="2008"/>
            <day count="9" month="5" day="22" year="2008"/>
            <day count="1" month="5" day="23" year="2008"/>
            <day count="1" month="5" day="29" year="2008"/>
            <day count="1" month="5" day="30" year="2008"/>
            <day count="5" month="5" day="31" year="2008"/>
        </month>
        ...
    </year>
<DownloadStats>

感谢任何帮助,

谢谢,

Eric R。

编辑:我认为了解如何将数据传输到图表以确保我没有做错事会很有帮助那里也有。

<mx:PieChart id="pieChart">
    <mx:PieSeries nameField="year"
            field="count"
            labelPosition="callout"
            displayName="Total"
            dataProvider="{graphData}"/>
</mx:PieChart>

I feel like this should be simple, however everywhere I look online someone does something different. I am doing a small charting application to track download statistics, and want to put the data into a pie chart. I am new to Flex, so if my code is horrible I apologize.

<s:HTTPService id="service"
    url="admin/stats/totalstats.php" 
    fault="service_faultHandler(event)"
    result="service_resultHandler(event)" />

What is the best resultFormat for this purpose, and if I am assigning the returned value to an ActionScript variable, should it be an ArrayList? ArrayCollection?

Heres a sample of the XML being returned from the HTTPService

<DownloadStats>
    <year count="24522" year="2008">
        <month count="20" month="5" year="2008" full="May 2008">
            <day count="2" month="5" day="20" year="2008"/>
            <day count="1" month="5" day="21" year="2008"/>
            <day count="9" month="5" day="22" year="2008"/>
            <day count="1" month="5" day="23" year="2008"/>
            <day count="1" month="5" day="29" year="2008"/>
            <day count="1" month="5" day="30" year="2008"/>
            <day count="5" month="5" day="31" year="2008"/>
        </month>
        ...
    </year>
<DownloadStats>

Any help is appreciated,

Thanks,

Eric R.

EDIT: I decided that it would be helpful to see how I am transferring the data to the chart to make sure I am not doing something wrong there either.

<mx:PieChart id="pieChart">
    <mx:PieSeries nameField="year"
            field="count"
            labelPosition="callout"
            displayName="Total"
            dataProvider="{graphData}"/>
</mx:PieChart>

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

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

发布评论

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

评论(1

庆幸我还是我 2024-09-13 02:08:41

通过更改后端并使用多个允许唯一结果处理程序的 HTTPServices 解决了该问题。无论这是否是我认为无关紧要的最佳方式,我的报告程序是如此之小,以至于几乎不可能看到性能下降。 HTTPService 默认返回一个对象,您可以使用点运算符操作该对象以在 XML 中向下钻取。如果您遇到类似问题,请给我留言,我会更详细地解释。

The issue was resolved by changing the backend and using multiple HTTPServices allowing for unique result handlers. Whether or not this is the best way I find to be irrelevant--my reporting program is so small that it will be near impossible to see a diminish in performance. HTTPService returns an object by default and you manipulate the object using dot operators to drill down in the XML. If you are having a similar issue send me a message and I will explain it in more detail.

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