加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

flex4.7 利用PieChart制作饼图

发布时间:2020-12-15 03:36:38 所属栏目:百科 来源:网络整理
导读:?xml version="1.0" encoding="utf-8"? s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"? ? xmlns:s="library://ns.adobe.com/flex/spark"? ? xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" fx:Script ![CDATA[ impor
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"? ? xmlns:s="library://ns.adobe.com/flex/spark"? ? xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"> <fx:Script> <![CDATA[ import mx.collections.ArrayCollection; [Bindable] private var db:ArrayCollection = new ArrayCollection ([ {country:"美国",gold:35,sliver:20,bronze:10},{country:"中国",gold:60,sliver:25,{country:"日本",gold:2,sliver:10,bronze:8} ]); private function showMoreInfo(data:Object,field:String,index:Number,percentValue:Number):String{ //data表示传进来的整个对象,你可以访问他的各种属性了.field表示目前你用了哪个属性(这里是gold). //index是顺序(也就是美国0,中国1,日本2),percentValue是百分比(他的返回值很长,比如36.0815241424); var percent:String = percentValue.toString().substr(0,6); return data.country + "n 金牌总数:" + data.gold + "n 银牌总数:" + data.sliver + "n 百分比:" + percent + "%"; } ]]> </fx:Script> <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> </fx:Declarations> <mx:PieChart id="pie" dataProvider="{db}" width="50%" height="50%" showDataTips="true"> <mx:series> <mx:PieSeries field="gold" labelPosition="callout" nameField="country" labelFunction="showMoreInfo"> <!-- 清除掉投影--> <mx:filters> <fx:Array/></mx:filters> <!-- 内部分割线条 --> <mx:radialStroke> <mx:SolidColorStroke weight="1" color="#ffffff" alpha="0.3" /> </mx:radialStroke> <!-- 圆周边 边线 --> <mx:stroke> <mx:SolidColorStroke weight="2" color="#000000" alpha="0.5" /> </mx:stroke> <!-- 提示信息的线 --> <mx:calloutStroke> <mx:SolidColorStroke weight="1" color="#000000" alpha="0.5" /> </mx:calloutStroke> </mx:PieSeries> </mx:series> </mx:PieChart> <!-- 图例说明 --> <mx:Legend dataProvider="{pie}" /> </s:Application>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读