diff --git a/src/traces/sankey/plot.js b/src/traces/sankey/plot.js index 1810603a8ab..7b0ce67e60e 100644 --- a/src/traces/sankey/plot.js +++ b/src/traces/sankey/plot.js @@ -125,13 +125,14 @@ module.exports = function plot(gd, calcData) { var linkHoverFollow = function(element, d) { + var rootBBox = gd.getBoundingClientRect(); var boundingBox = element.getBoundingClientRect(); var hoverCenterX = boundingBox.left + boundingBox.width / 2; var hoverCenterY = boundingBox.top + boundingBox.height / 2; var tooltip = Fx.loneHover({ - x: hoverCenterX + window.scrollX, - y: hoverCenterY + window.scrollY, + x: hoverCenterX - rootBBox.left, + y: hoverCenterY - rootBBox.top, name: d3.format(d.valueFormat)(d.link.value) + d.valueSuffix, text: [ d.link.label, @@ -173,15 +174,16 @@ module.exports = function plot(gd, calcData) { var nodeHoverFollow = function(element, d) { var nodeRect = d3.select(element).select('.nodeRect'); + var rootBBox = gd.getBoundingClientRect(); var boundingBox = nodeRect.node().getBoundingClientRect(); - var hoverCenterX0 = boundingBox.left - 2; - var hoverCenterX1 = boundingBox.right + 2; - var hoverCenterY = boundingBox.top + boundingBox.height / 4; + var hoverCenterX0 = boundingBox.left - 2 - rootBBox.left; + var hoverCenterX1 = boundingBox.right + 2 - rootBBox.left; + var hoverCenterY = boundingBox.top + boundingBox.height / 4 - rootBBox.top; var tooltip = Fx.loneHover({ - x0: hoverCenterX0 + window.scrollX, - x1: hoverCenterX1 + window.scrollX, - y: hoverCenterY + window.scrollY, + x0: hoverCenterX0, + x1: hoverCenterX1, + y: hoverCenterY, name: d3.format(d.valueFormat)(d.node.value) + d.valueSuffix, text: [ d.node.label,