From e30bfe98c492e10a8d656db9620600bb4296fbed Mon Sep 17 00:00:00 2001 From: archmoj Date: Tue, 20 Jul 2021 16:36:06 -0400 Subject: [PATCH 1/2] pick winning and median positions for unified hover depending on axis --- src/components/fx/hover.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/fx/hover.js b/src/components/fx/hover.js index 4cc6d19e802..550f514246f 100644 --- a/src/components/fx/hover.js +++ b/src/components/fx/hover.js @@ -1072,8 +1072,11 @@ function createHoverText(hoverData, opts, gd) { // Position the hover var winningPoint = hoverData[0]; - var ly = (winningPoint.y0 + winningPoint.y1) / 2; - var lx = (winningPoint.x0 + winningPoint.x1) / 2; + var ly = axLetter === 'y' ? + (winningPoint.y0 + winningPoint.y1) / 2 : Lib.mean(hoverData.map(function(c) {return (c.y0 + c.y1) / 2;})); + var lx = axLetter === 'x' ? + (winningPoint.x0 + winningPoint.x1) / 2 : Lib.mean(hoverData.map(function(c) {return (c.x0 + c.x1) / 2;})); + var legendContainer = container.select('g.legend'); var tbb = legendContainer.node().getBoundingClientRect(); lx += xa._offset; From c9d06e52a26caccc916723b4c84c59e6519af11d Mon Sep 17 00:00:00 2001 From: archmoj Date: Tue, 20 Jul 2021 16:50:20 -0400 Subject: [PATCH 2/2] draft log for PR 5845 --- draftlogs/5845_fix.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 draftlogs/5845_fix.md diff --git a/draftlogs/5845_fix.md b/draftlogs/5845_fix.md new file mode 100644 index 00000000000..5b483f123d8 --- /dev/null +++ b/draftlogs/5845_fix.md @@ -0,0 +1 @@ + - Position hover in respect to the average of values in (x|y) unified modes (regression introduced in 2.0.0) [[#5845](https://github.com/plotly/plotly.js/pull/5845)]