PDA

View Full Version : symbol format


Anitha
02-12-2009, 08:39 AM
Dear Friends ,

For a chart Datatip function I need a currency Format .There is no chance of 10 separator through currency formatter , I wish to use the switch symbol formatter.Hence I create a classfile and access the object through the way.But I cant get any datatip when access the datatip function.What is the problem .
Am in right way?
But it run successfully when I do that in mxml application page <mx:script />
Please refer the following code.

Mxml application page :

<MyComp:CustomSSFormatter id="SSFormat"/>

<mx:ColumnChart id="columnchart1" dataProvider="{ans}" showDataTips="true" dataTipFunction="formatDataTip">


script :
<mx:Script>
<![CDATA[

private function formatDataTip(hitData:HitData):void
{
var Sales:Number = Math.round(hitData.item.Sales);
SSFormat.format(Sales); }

]]>
</mx:Script>



ActionScript Class File:
package myFormatters
{
import mx.formatters.Formatter;
import mx.formatters.SwitchSymbolFormatter;

public class CustomSSFormatter extends Formatter
{
public var formatString : String = new String;
public var formattedData : String = new String;
public var switcher : SwitchSymbolFormatter = new SwitchSymbolFormatter("#");

public function CustomSSFormatter()
{
super();
}

override public function format(Sales:Object):String
{
if ((Sales>=100000)&&(Sales<=999999))
{
formatString = "Rs. #,##,###";
formattedData = switcher.formatValue(formatString,String(Sales));
}
if ((Sales>=1000000)&&(Sales<=9999999))
{
formatString = "Rs. ##,##,###";
formattedData = switcher.formatValue(formatString,String(Sales));
}
return switcher.formatValue( formatString, Sales );
}
}
}