我根本不知道该怎么做。这是我的代码。
public function doFormatMoneda(valor:Number):String{
var formatoMoneda:CurrencyFormatter = new CurrencyFormatter();
formatoMoneda.precision = "2";
formatoMoneda.rounding = "none";
formatoMoneda.decimalSeparatorTo = ".";
formatoMoneda.thousandsSeparatorTo = ",";
formatoMoneda.useThousandsSeparator = "true";
formatoMoneda.useNegativeSign = "true";
formatoMoneda.currencySymbol = "$";
formatoMoneda.alignSymbol = "left";
return formatoMoneda.format(valor.toString());
}
private function formatCurrency(hitData:HitData):String{
var format:String = doFormatMoneda(Number(hitData));
return format;
}
<mx:BarChart top="30" left="10" width="100%" dataProvider="{orgData}" dataTipFunction="formatCurrency" showDataTips="true" height="430" fontWeight="bold" id="bcCfds">
<mx:verticalAxis>
<mx:CategoryAxis categoryField="mes"/>
</mx:verticalAxis>
<mx:series>
<mx:BarSeries
yField="mes"
xField="totalCancelada"
labelField="totalCanceladaFormato"
displayName="Canceladas"
barWidthRatio="1.0"/>
<mx:BarSeries
yField="mes"
xField="totalPagada"
labelField="totalPagadaFormato"
displayName="Pagadas"
barWidthRatio="1.0"/>
<mx:BarSeries
yField="mes"
xField="totalTerminada"
labelField="totalTerminadaFormato"
displayName="Terminadas"
barWidthRatio="1.0"/>
</mx:series>
</mx:BarChart>
<mx:Legend dataProvider="{bcCfds}" direction="horizontal" />
显示空的数据提示。这让我疯了。
答案 0 :(得分:1)
我认为您需要从hitdata获取货币价值并将其转换为数字。 你应该试试 Number(hitData.item)或具有CurrencyValue的项目的某些属性。
答案 1 :(得分:0)
<mx:Script>
<![CDATA[
import mx.formatters.CurrencyFormatter;
import mx.charts.HitData;
public function doFormatMoneda(valor:Number):String{
var formatoMoneda:CurrencyFormatter = new CurrencyFormatter();
formatoMoneda.precision = "2";
formatoMoneda.rounding = "none";
formatoMoneda.decimalSeparatorTo = ".";
formatoMoneda.thousandsSeparatorTo = ",";
formatoMoneda.useThousandsSeparator = "true";
formatoMoneda.useNegativeSign = "true";
formatoMoneda.currencySymbol = "$";
formatoMoneda.alignSymbol = "left";
return formatoMoneda.format(valor.toString());
}
private function formatCurrency(hitData:HitData):String{
var format:String = doFormatMoneda(Number(hitData.item.totalCancelada));
return format;
}
]]>
</mx:Script>
正如arpit所说,hitData.item是你对象的句柄。你必须指定你要格式化这个对象的哪个属性。例如,我使用了totalCancelada并且它工作正常。