Use CurrencyFormatter and NumberFormatter to format label for Chart
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" >
<mx:TraceTarget/>
<mx:Script>
import mx.events.CollectionEvent;
import mx.messaging.messages.AsyncMessage;
import mx.messaging.events.MessageEvent;
import mx.collections.ArrayCollection;
[Bindable]
private var acSales:ArrayCollection = new ArrayCollection(
[{name:"A", sales:5.00},
{name:"B", sales:8.00},
{name:"C", sales:2.00}]);
private function formatLabel(data:Object, field:String, index:Number, percentValue:Number):String
{
return data.name + "\n" + cf.format(data.sales) + "\n(" + nf.format(percentValue) + "%)";
}
</mx:Script>
<mx:CurrencyFormatter id="cf" precision="2"/>
<mx:NumberFormatter id="nf" precision="1"/>
<mx:PieChart id="chart" dataProvider="{acSales}" width="100%" height="100%">
<mx:series>
<mx:PieSeries field="sales" explodeRadius=".05"
labelPosition="callout" labelFunction="formatLabel"
fontSize="12" fontWeight="bold"/>
</mx:series>
</mx:PieChart>
</mx:Application>
Related examples in the same category