试试这个自定义数据提示操作脚本。
// charts/MyDataTip.as
package {
import mx.charts.chartClasses.DataTip;
import mx.charts.*;
import flash.display.*;
import flash.geom.Matrix;
import flash.text.TextField;
public class MyDataTip extends DataTip {
// The title is renderered in a TextField.
private var myText:TextField;
public function MyDataTip() {
super();
}
override protected function createChildren():void{
super.createChildren();
myText = new TextField();
}
override protected function updateDisplayList(w:Number, h:Number):void {
super.updateDisplayList(w, h);
// The data property provides access to the data tip's text.
if(data.hasOwnProperty('text')) {
myText.text = data.text;
} else {
myText.text = data.toString();
}
this.setStyle("textAlign","center");
this.setStyle("color","#FFFFFF");
var g:Graphics = graphics;
g.clear();
var m:Matrix = new Matrix();
m.createGradientBox(w+100,h,0,0,0);
g.beginFill(0x339966,1);
g.drawRect(-50,0,w+100,h);
g.endFill();
}
}
}
并在您的 creationComplete="applyCustomDataTips()" 函数中使用此操作脚本。
例如:
public function applyCustomDataTips():void {
myColumnChart.setStyle("dataTipRenderer",MyDataTip);
}
请参阅自定义数据提示渲染器