Flex +WebService
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Script> <![CDATA[ import mx.controls.DataGrid; import flash.external.ExternalInterface; import flash.geom.Point; import flash.net.navigateToURL; import mx.messaging.AbstractConsumer; import mx.controls.Alert; import mx.events.CalendarLayoutChangeEvent; import mx.collections.ArrayCollection; import mx.controls.ComboBox; import mx.charts.series.AreaSeries; import mx.charts.series.items.AreaSeriesItem; import mx.charts.HitData; import mx.charts.CategoryAxis; import mx.charts.chartClasses.Series; import mx.charts.AreaChart; import mx.charts.series.AreaSeries; import mx.styles.StyleManager; import mx.charts.HitData; import mx.charts.series.items.LineSeriesItem; import mx.containers.ViewStack; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; import mx.utils.StringUtil; import mx.collections.ArrayCollection; [Bindable] private var nums:ArrayCollection=new ArrayCollection(); private var numArr:ArrayCollection = new ArrayCollection(); private var db:ArrayCollection = new ArrayCollection ([ {INFORTYPENAME:"异常信息",NUM:21,T:4}, {INFORTYPENAME:"普通信息",NUM:26,T:3}, {INFORTYPENAME:"重大异常信息",NUM:6,T:5} ]); //页面初始化 private function init():void{ dataService.GetStatisticsInfo(); } //鼠标放在每一个部分时候的展示信息 private function showMoreInfo(data:Object, field:String, index:Number, percentValue:Number):String{ var percent:String = percentValue.toString().substr(0,6); return data.INFORTYPENAME + "\n 总数:" + data.NUM + "\n 百分比:" + percent + "%"; } //处错误的时候提示信息 public function onFault(event:FaultEvent):void{ Alert.show("调用超时!"); } //生成数据数组 public function onGetStatisticsInfo(event:ResultEvent):void{ //dgMQ.dataProvider=evt.result.Tables.ds.Rows; numArr //numArr=event.result.Tables.ds.Rows; nums=event.result.Tables.ds.Rows; //Alert.show(nums[0]["INFORTYPENAME"].toString()); //var m:int=0; //Alert.show(nums.length.toString()); //for(m;m<nums.length;m++) //{ // Alert.show(m.toString()+"dfd"); // Alert.show(nums[m][2].toString()); // numArr.addItem({NUM:nums[m][0],INFORTYPENAME:nums[m][2]}); // } //var dt:DataGrid=dataProvider=event.result.Tables.ds.Rows; // nums = event.result. } ]]> </mx:Script> <mx:Model id="model" source="crossdomain.xml"/> <mx:WebService id="dataService" wsdl="{model.webservice}" showBusyCursor="true" useProxy="false"> <mx:operation name="GetStatisticsInfo" result="onGetStatisticsInfo(event)" fault="onFault(event)" /> </mx:WebService> <mx:PieChart id="pie" dataProvider="{nums}" width="50%" height="50%" showDataTips="true" creationComplete="init()"> <mx:series> <mx:PieSeries field="NUM" labelPosition="callout" nameField="INFORTYPENAME" labelFunction="showMoreInfo"> <!-- 清除掉投影--> <mx:filters><mx:Array/></mx:filters> <!-- 内部分割线条 --> <mx:radialStroke> <mx:Stroke weight="1" color="#ffffff" alpha="0.3" /> </mx:radialStroke> <!-- 圆周边 边线 --> <mx:stroke> <mx:Stroke weight="2" color="#000000" alpha="0.5" /> </mx:stroke> <!-- 提示信息的线 --> <mx:calloutStroke> <mx:Stroke weight="1" color="#000000" alpha="0.5" /> </mx:calloutStroke> </mx:PieSeries> </mx:series> </mx:PieChart> <!-- 图例说明 --> <mx:Legend dataProvider="{pie}" /> </mx:Application>
、、、、、、、、、、、、、、、、、、、、、、、、、
配置文件
<config>
<webservice>http://130.120.110.3:1122/WSForFlex.asmx?wsdl</webservice>
<main>http://www.baidu.com</main>
</config>