Use CurrencyFormatter and NumberFormatter to format label for Chart : CurrencyValidator « Data Model « Flex






Use CurrencyFormatter and NumberFormatter to format label for Chart

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

1.Use CurrencyValidator to validate money valuesUse CurrencyValidator to validate money values
2.Using the CurrencyValidator to validate US currencyUsing the CurrencyValidator to validate US currency
3.Using the CurrencyValidator to validate European-formatted priceUsing the CurrencyValidator to validate European-formatted price
4.Using CurrencyValidator class to validate a currency value entered in U.S. dollars and in EurosUsing CurrencyValidator class to validate a currency value entered in U.S. dollars and in Euros
5.Use NumberValidator to validate and CurrencyFormatter to formatUse NumberValidator to validate and CurrencyFormatter to format
6.Currency formatter cell rendererCurrency formatter cell renderer
7.CurrencyFormatter precisionCurrencyFormatter precision
8.CurrencyFormatter decimalSeparatorToCurrencyFormatter decimalSeparatorTo
9.CurrencyFormatter thousandsSeparatorToCurrencyFormatter thousandsSeparatorTo
10.CurrencyFormatter useThousandsSeparatorCurrencyFormatter useThousandsSeparator
11.CurrencyFormatter useNegativeSignCurrencyFormatter useNegativeSign
12.Example of Currency FormatterExample of Currency Formatter
13.Using the CurrencyFormatter classUsing the CurrencyFormatter class