带有 Web 服务的 Flex 融合图表
我有一个 Flex 项目,我想在其中调用 Web 服务并将值从它传递到 xml 文件以更新融合图表 xml 我的代码是
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
public var PUENumber:String;
protected var xmlLoader:URLLoader;
[Bindable]
public var avgPUEXml:XML = new XML;
protected function init():void
{
xmlLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE,setDataXML)
xmlLoader.load(new URLRequest("data/AvgPUE.xml")); //Loading xml file for the chart from the folder
};
protected function setDataXML(event:Event):void
{
avgPUEXml = XML(event.target.data);
avgPUEXml.value = PUENumber; //updating chart xml value
fw.FCDataXML = avgPUEXml.toString();
fw.FCRender();
};
protected function getDC_POWERdataResult_resultHandler(event:ResultEvent):void
{
PUENumber = getDC_POWERdataResult.lastResult; //getting value to update in xml file
init();
}
protected function bordercontainer1_creationCompleteHandler(event:FlexEvent):void
{
getDC_POWERdataResult.token = mGEMWS.getDCPUE("4","715"); //user details to get data from the method
}
]]>
</fx:Script>
<fx:Declarations>
<s:CallResponder id="getDC_POWERdataResult" result="getDC_POWERdataResult_resultHandler(event)"/>
<mgemws:MGEMWS id="mGEMWS" showBusyCursor="true"
fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"/>
</fx:Declarations>
<ns1:FusionWidgets id="fw" FCChartType="Bulb" FCDataXML="avgPUEXml" />
在声明中我正在调用网络服务。并在创建完成时发送用户 ID 详细信息以从 Web 服务获取数据。现在我到底需要在哪里调用 init 函数,以便它使用来自 Web 服务的值更新 xml 文件并显示融合小部件
I have flex project where i want to call webservice and pass values from it to the xml file to update fusion chart xml
My code is
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
public var PUENumber:String;
protected var xmlLoader:URLLoader;
[Bindable]
public var avgPUEXml:XML = new XML;
protected function init():void
{
xmlLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE,setDataXML)
xmlLoader.load(new URLRequest("data/AvgPUE.xml")); //Loading xml file for the chart from the folder
};
protected function setDataXML(event:Event):void
{
avgPUEXml = XML(event.target.data);
avgPUEXml.value = PUENumber; //updating chart xml value
fw.FCDataXML = avgPUEXml.toString();
fw.FCRender();
};
protected function getDC_POWERdataResult_resultHandler(event:ResultEvent):void
{
PUENumber = getDC_POWERdataResult.lastResult; //getting value to update in xml file
init();
}
protected function bordercontainer1_creationCompleteHandler(event:FlexEvent):void
{
getDC_POWERdataResult.token = mGEMWS.getDCPUE("4","715"); //user details to get data from the method
}
]]>
</fx:Script>
<fx:Declarations>
<s:CallResponder id="getDC_POWERdataResult" result="getDC_POWERdataResult_resultHandler(event)"/>
<mgemws:MGEMWS id="mGEMWS" showBusyCursor="true"
fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"/>
</fx:Declarations>
<ns1:FusionWidgets id="fw" FCChartType="Bulb" FCDataXML="avgPUEXml" />
in the declaration am calling web service. and on creationCompelete am sending userid details to get data from webservice. now where exactly i need to call init function so that it updates xml file with values coming from web service and display the fusion widget
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不需要“setDataXML”处理程序方法。此外,您在“init”方法中不需要任何“URLLoader”或“URLRequest”。 FusionCharts支持XML数据以及XML路径。因此,删除“setDataXML”并删除“init”方法中的所有代码,然后仅添加
fw.addEventListener(FCEvent.FCRenderEvent, wgdtRendHandler);
并添加下面的处理程序方法 -
我认为这应该适合你。如果您仍然没有获得图表中更新的数据,请检查“init”方法中的 XML 文件在该时间点是否已正确更新。
You don't need the 'setDataXML' handler method. Also you don't need any 'URLLoader' or 'URLRequest' in the 'init' method. FusionCharts supports XML data as well as XML path. So remove the 'setDataXML' and remove all the codes from the 'init' method and add just
fw.addEventListener(FCEvent.FCRenderEvent, wgdtRendHandler);
and add below handler method -
I think this should work for you. In case you still don't get the updated data in the chart, check the XML file in the 'init' method whether it's updated properly at that point of time.
当图表完成加载并准备好数据时,您可以调用 init 函数。
您可以通过监听仪表的 FCLoadEvent 或 FCRenderEvent 来执行此操作。
请尝试使用:
或
You can call the init function when the chart finishes loading and is ready for data.
You can do this listening to FCLoadEvent or FCRenderEvent of the gauge.
Please try using :
or