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



请看一下:http://jsfiddle.net/zb443xj9/

气泡被半径拉得更高。因此,方法"drawPoints"更改如下(因为此"更改功能"未在框架中实现):

    (function (H) {
    H.wrap(H.seriesTypes.bubble.prototype, 'drawPoints', function (p) {
        var series = this;
        H.each(series.points, function (point, i) {
            point.shapeArgs.y -= point.shapeArgs.r; //moved up by radius
        });
        p.call(this);
    });
})(Highcharts);

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

我也希望覆盖这两种方法。我希望它们被称为"drawShadow"one_answers"drawTooltip",但不幸的是没有。

谢谢!

您应该将haloPath方法包装在点选项中。然后覆盖点内的"this"对象。

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);
    });

编辑:示例:http://jsfiddle.net/zb443xj9/6/

最新更新