我应该如何在 Flex 中格式化 HTTPService 结果,以便可以通过饼图访问它?
我觉得这应该很简单,但是我在网上看到的每个地方都有人做不同的事情。我正在做一个小型图表应用程序来跟踪下载统计信息,并希望将数据放入饼图中。我是 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过更改后端并使用多个允许唯一结果处理程序的 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.