开发者

Centering DataTip (target) on a ColumnChart in Flex 3

How can I align a DataTip to the vertical center of the corresp开发者_JS百科onding column? I've tried creating a custom dataTipRenderer, but it seems to me that there I can only move the datatip relative to the target (the circle graphic). But that position's just fine, I'd like to move the target itself.

My last idea is to set the showDataTipTargets style of the chart to false and draw the targets within the custom dataTipRenderer. I consider this a dirty hack, so if there's anything more friendly I'd go with that. Plus, in this case, how can I tell the column center coordinates in the datatip renderer's updateDisplayList function?


Hope this snippet of code would help ... package As { import flash.display.*; import flash.geom.Point;

import mx.charts.*;
import mx.charts.chartClasses.DataTip;
import mx.charts.series.ColumnSeries;
import mx.charts.series.items.ColumnSeriesItem;
public class MyDataTip extends DataTip 
{
    private var _xBaseLine:int=0;
    private var _yBaseLine:int=0;
    private var myX = 0
    private var myY = 0
    public function MyDataTip()
    {
    super();
    }
    override public function set data(arg1:Object):void {
        var sMessage:String;
        var pt:Point;
        var hitData:HitData = mx.charts.HitData(arg1);
        var chartItem = ColumnSeriesItem(hitData.chartItem);
        var renderer = chartItem.itemRenderer;
        var series = ColumnSeries(hitData.element); 

        var colName = chartItem.element.name
        var pft = chartItem.xValue       


        if(renderer != null) {
            myX = ( renderer.width / 2 )
            myY = ( renderer.height/ 2 ) + ( this.height)
        }
        super.data=arg1;
    }
    override public function move (x:Number, y:Number):void { 
        // Adjusted
        var pointAdjusted:Point = new Point(x + _xBaseLine, y + _yBaseLine); 
        // Call the parent
        super.move(pointAdjusted.x, pointAdjusted.y); 
    } 
    override protected function updateDisplayList(w:Number, h:Number):void 
    {
        super.updateDisplayList(w, h); 

        this.x = this.x + myX - 15
        this.y = this.y + myY - 7
        }
}

} Cheers !! :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜