1

我在工具提示中有一个 url 链接,但是,如果工具提示超出图表区域并且您尝试单击该 url,则工具提示会消失。

有什么解决方法吗?

谢谢!

4

1 回答 1

2

我发现在这样的情况下,最好手动定位工具提示:

http://api.highcharts.com/highcharts#tooltip.positioner

这样,不需要的隐藏是可控的。

编辑:

如果你扩展工具提示原型,你可以操纵 X 和 Y

Tooltip.prototype.move = function (x, y, anchorX, anchorY) {
    var tooltip = this,
        now = tooltip.now,
        animate = tooltip.options.animation !== false && !tooltip.isHidden;

            if(x > ?????)
            {
               x = x - 50; // or how ever many pixels you want to move it to
            }

    // get intermediate values for animation
    extend(now, {
        x: animate ? (2 * now.x + x) / 3 : x,
        y: animate ? (now.y + y) / 2 : y,
        anchorX: animate ? (2 * now.anchorX + anchorX) / 3 : anchorX,
        anchorY: animate ? (now.anchorY + anchorY) / 2 : anchorY
    });

    // move to the intermediate value
    tooltip.label.attr(now);


    // run on next tick of the mouse tracker
    if (animate && (mathAbs(x - now.x) > 1 || mathAbs(y - now.y) > 1)) {

        // never allow two timeouts
        clearTimeout(this.tooltipTimeout);

        // set the fixed interval ticking for the smooth tooltip
        this.tooltipTimeout = setTimeout(function () {
            // The interval function may still be running during destroy, so check that the chart is really there before calling.
            if (tooltip) {
                tooltip.move(x, y, anchorX, anchorY);
            }
        }, 32);

    }
}
于 2013-02-05T18:13:19.160 回答