Flex 3 中柱形图上的数据提示(目标)居中

发布于 2024-09-29 06:02:50 字数 263 浏览 2 评论 0原文

如何将数据提示与相应列的垂直中心对齐?我尝试创建一个自定义 dataTipRenderer,但在我看来,我只能相对于目标(圆形图形)移动数据提示。不过这个位置还好,我想移动目标本身。

我的最后一个想法是将图表的 showDataTipTargets 样式设置为 false 并在自定义 dataTipRenderer 中绘制目标。我认为这是一个肮脏的黑客行为,所以如果有更友好的东西我会同意。另外,在这种情况下,我如何知道数据提示渲染器的 updateDisplayList 函数中的列中心坐标?

How can I align a DataTip to the vertical center of the corresponding 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

森林迷了鹿 2024-10-06 06:02:50

希望这段代码能有所帮助......
封装为
{
导入 flash.display.*;
导入 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
        }
}

}
干杯! :)

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 !! :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文