flex 饼图PieChart
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" >
<mx: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,bronze:10},
{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 + "%";
}
]]>
</mx:Script>
<mx:PieChart id="pie" dataProvider="{db}" width="100%" height="100%" showDataTips="true">
<mx:series>
<mx:PieSeries field="gold" labelPosition="callout" nameField="country" 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>