Javascript hightcharts:更改工具提示和阴影的标准位置(悬停)

Javascript hightcharts:更改工具提示和阴影的标准位置(悬停),javascript,jquery,highcharts,tooltip,shadow,Javascript,Jquery,Highcharts,Tooltip,Shadow,请看一下这个: 气泡被半径拉得更高。 因此,方法“drawPoints”更改如下(因为该“更改特性”未在框架中实现): 如果将鼠标悬停在所看到的气泡上,阴影和工具提示仍然位于“旧”中心。 有人知道绘制阴影和工具提示的方法是如何命名的吗 我也想覆盖这两种方法。 我希望它们被称为“drawShadow”和“drawTooltip”,但不幸的是,它们不是 谢谢 您应该在点选项中包装光晕路径方法。然后覆盖点内的“此”对象 H.wrap(H.Point.prototype, 'haloPath', fun

请看一下这个:

气泡被半径拉得更高。 因此,方法“drawPoints”更改如下(因为该“更改特性”未在框架中实现):

如果将鼠标悬停在所看到的气泡上,阴影和工具提示仍然位于“旧”中心。 有人知道绘制阴影和工具提示的方法是如何命名的吗

我也想覆盖这两种方法。 我希望它们被称为“drawShadow”和“drawTooltip”,但不幸的是,它们不是


谢谢

您应该在点选项中包装光晕路径方法。然后覆盖点内的“此”对象

H.wrap(H.Point.prototype, 'haloPath', function (proceed) {

                if(this.oldY === UNDEFINED) {
                    this.oldY = this.plotY;
                    this.plotY -= (this.shapeArgs.r);
                }

                return proceed.apply(this, 

Array.prototype.slice.call(arguments, 1));
});

H.wrap(H.Tooltip.prototype, 'getAnchor', function (proceed, points, mouseEvent) {
        var ret,
        chart = this.chart,
            inverted = chart.inverted,
            plotTop = chart.plotTop,
            plotLeft = chart.plotLeft,
            plotX = 0,
            plotY = 0,
            yAxis,
            xAxis;

        points = splat(points);

        // Pie uses a special tooltipPos
        ret = points[0].tooltipPos;

        // When tooltip follows mouse, relate the position to the mouse
        if (this.followPointer && mouseEvent) {
            if (mouseEvent.chartX === UNDEFINED) {
                mouseEvent = chart.pointer.normalize(mouseEvent);
            }
            ret = [
            mouseEvent.chartX - chart.plotLeft,
            mouseEvent.chartY - plotTop];
        }
        // When shared, use the average position
        if (!ret) {
            each(points, function (point) {
                yAxis = point.series.yAxis;
                xAxis = point.series.xAxis;
                plotX += point.plotX + (!inverted && xAxis ? xAxis.left - plotLeft : 0);
                plotY += (point.plotLow ? (point.plotLow + point.plotHigh) / 2 : point.plotY) + (!inverted && yAxis ? yAxis.top - plotTop : 0); // #1151
            });

            plotX /= points.length;
            plotY /= points.length;

            ret = [
            inverted ? chart.plotWidth - plotY : plotX,
            this.shared && !inverted && points.length > 1 && mouseEvent ? mouseEvent.chartY - plotTop : // place shared tooltip next to the mouse (#424)
            inverted ? chart.plotHeight - plotX : plotY];
        }

        if(points[0].oldY === UNDEFINED) {
            ret[1] -= points[0].shapeArgs.r;
        }

        return map(ret, mathRound);
    });
编辑:
示例:

此阴影(光晕)是串联对象,动态渲染为路径,因此您还需要包装光晕功能(光晕路径)。完美!我只需复制并粘贴包装器函数,并通过“halo”替换“drawPoints”!工具提示呢?你也知道这个函数名吗?你说的“haloPath”@SebastianBochan是什么意思<代码>…H.wrap(H.seriesTypes.bubble.prototype,'haloPath',函数(p){…没有影响。但这仅在我在气泡上悬停2次时有效。第一次悬停时,工具提示位于其原始居中位置。当我将鼠标移动到另一个气泡并返回到该气泡后,工具提示将按半径向上移动。您看到@SebastianBochan了吗?也许我们必须以某种方式更改if分支?但在哪里你想在“新移动的气泡”的中心有一个工具提示吗?如果你第一次悬停时它太“深”。如果工具提示指向“新移动的气泡”的中心这将是完美的!第二次悬停的位置也很好。重要的是,它不应该在第一次和第二次悬停的不同位置呈现。你需要包装getAnchor函数以获得工具提示,请参阅我更新的演示
H.wrap(H.Point.prototype, 'haloPath', function (proceed) {

                if(this.oldY === UNDEFINED) {
                    this.oldY = this.plotY;
                    this.plotY -= (this.shapeArgs.r);
                }

                return proceed.apply(this, 

Array.prototype.slice.call(arguments, 1));
});

H.wrap(H.Tooltip.prototype, 'getAnchor', function (proceed, points, mouseEvent) {
        var ret,
        chart = this.chart,
            inverted = chart.inverted,
            plotTop = chart.plotTop,
            plotLeft = chart.plotLeft,
            plotX = 0,
            plotY = 0,
            yAxis,
            xAxis;

        points = splat(points);

        // Pie uses a special tooltipPos
        ret = points[0].tooltipPos;

        // When tooltip follows mouse, relate the position to the mouse
        if (this.followPointer && mouseEvent) {
            if (mouseEvent.chartX === UNDEFINED) {
                mouseEvent = chart.pointer.normalize(mouseEvent);
            }
            ret = [
            mouseEvent.chartX - chart.plotLeft,
            mouseEvent.chartY - plotTop];
        }
        // When shared, use the average position
        if (!ret) {
            each(points, function (point) {
                yAxis = point.series.yAxis;
                xAxis = point.series.xAxis;
                plotX += point.plotX + (!inverted && xAxis ? xAxis.left - plotLeft : 0);
                plotY += (point.plotLow ? (point.plotLow + point.plotHigh) / 2 : point.plotY) + (!inverted && yAxis ? yAxis.top - plotTop : 0); // #1151
            });

            plotX /= points.length;
            plotY /= points.length;

            ret = [
            inverted ? chart.plotWidth - plotY : plotX,
            this.shared && !inverted && points.length > 1 && mouseEvent ? mouseEvent.chartY - plotTop : // place shared tooltip next to the mouse (#424)
            inverted ? chart.plotHeight - plotX : plotY];
        }

        if(points[0].oldY === UNDEFINED) {
            ret[1] -= points[0].shapeArgs.r;
        }

        return map(ret, mathRound);
    });