[英]flex mx line chart datafunction
我有一个JSON服务链接,它以Integer
返回月份,价格以Number
形式显示在<mx:Linechart />
。
现在,我不想将月份显示为Integer
而不是显示为等效于月份值的字符串。
我试图创建一个像这样的数据功能
public function myDataFunction(series:LineSeries, item:Object, fieldName:String):Object {
var months:Array = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var my_date:Date = new Date();
if (fieldName == 'yValue')
return(item.price);
else if (fieldName == "xValue")
{
return((months[my_date.month]));
}
else
return null;
}
我想发布声誉,但是我没有足够的声誉。 有人请帮忙。
谢谢
要在水平轴上显示月份名称,您需要为其分配labelFunction
。
声明折线图时,您可以这样指定水平轴:
<mx:Linechart>
<mx:horizontalAxis>
<mx:CategoryAxis categoryField="xValue"/>
</mx:horizontalAxis>
</mx:Linechart>
要修改水平轴的值,需要指定labelFunction
:
<mx:CategoryAxis categoryField="xValue" labelFunction="labelFunction"/>
labelFunction
应该如下所示:
function labelFunction(categoryValue:Object, previousCategoryValue:Object, axis:CategoryAxis, categoryItem:Object):String {
return "label";
}
有关更多信息,请参见: http : //help.adobe.com/zh_CN/FlashPlatform/reference/actionscript/3/mx/charts/CategoryAxis.html#labelFunction
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.