Skip to content

Commit 266caf0

Browse files
committed
generalize toggleHover mode bar button handler,
so that cartesian plots keep retrieve their 'x' and 'y' hovermode when toggling.
1 parent 0c5cf56 commit 266caf0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/components/modebar/buttons.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,15 @@ modeBarButtons.hoverClosestPie = {
493493
};
494494

495495
function toggleHover(gd) {
496-
var newHover = gd._fullLayout.hovermode ? false : 'closest';
496+
var fullLayout = gd._fullLayout;
497+
498+
var onHoverVal;
499+
if(fullLayout._hasCartesian) {
500+
onHoverVal = fullLayout._isHoriz ? 'y' : 'x';
501+
}
502+
else onHoverVal = 'closest';
503+
504+
var newHover = gd._fullLayout.hovermode ? false : onHoverVal;
497505

498506
Plotly.relayout(gd, 'hovermode', newHover);
499507
}

0 commit comments

Comments
 (0)