高图:错误的工具提示位置

时间:2020-04-20 08:05:27

标签: javascript jquery highcharts

我正在使用图表来表示折线图。但是,出于某些奇怪的原因,在图表上徘徊时,它显示的是先前点的数据。在尝试调查相同的原因后,其显示位置是不确定的。 有什么办法可以解决此问题或向悬停数据添加一些偏移量?

 Tooltip.prototype.updatePosition = function (point) {
                var chart = this.chart, pointer = chart.pointer, label = this.getLabel(), pos, anchorX = point.plotX + chart.plotLeft, anchorY = point.plotY + chart.plotTop, pad;
                // Needed for outside: true (#11688)
                var chartPosition = pointer.getChartPosition();
                pos = (this.options.positioner || this.getPosition).call(this, label.width, label.height, point);
                // Set the renderer size dynamically to prevent document size to change
                if (this.outside) {
                    pad = (this.options.borderWidth || 0) + 2 * this.distance;
                    this.renderer.setSize(label.width + pad, label.height + pad, false);
                    // Anchor and tooltip container need scaling if chart container has
                    // scale transform/css zoom. #11329.
                    var containerScaling = chart.containerScaling;
                    if (containerScaling) {
                        css(this.container, {
                            transform: "scale(" + containerScaling.scaleX + ", " + containerScaling.scaleY + ")"
                        });
                        anchorX *= containerScaling.scaleX;
                        anchorY *= containerScaling.scaleY;
                    }
                    anchorX += chartPosition.left - pos.x;
                    anchorY += chartPosition.top - pos.y;
                }
                // do the move
                this.move(Math.round(pos.x), Math.round(pos.y || 0), // can be undefined (#3977)
                anchorX, anchorY);
            };
            return Tooltip;
        }());
        H.Tooltip = Tooltip;

        return H.Tooltip;
    });

0 个答案:

没有答案