Skip to content

Commit 9c07a91

Browse files
committed
make a similar function in helpers to test x or y hover modes
1 parent 3c883ff commit 9c07a91

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/components/fx/helpers.js

+10
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ function getPointData(val, pointNumber) {
239239
}
240240
}
241241

242+
var xyHoverMode = {
243+
x: true,
244+
y: true
245+
};
246+
242247
var unifiedHoverMode = {
243248
'x unified': true,
244249
'y unified': true
@@ -248,3 +253,8 @@ exports.isUnifiedHover = function(hovermode) {
248253
if(typeof hovermode !== 'string') return false;
249254
return !!unifiedHoverMode[hovermode];
250255
};
256+
257+
exports.isXYhover = function(hovermode) {
258+
if(typeof hovermode !== 'string') return false;
259+
return !!xyHoverMode[hovermode];
260+
};

src/components/fx/hover.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ var YSHIFTY = Math.sin(YA_RADIANS);
4545
var HOVERARROWSIZE = constants.HOVERARROWSIZE;
4646
var HOVERTEXTPAD = constants.HOVERTEXTPAD;
4747

48-
var XY = {x: 1, y: 1};
49-
5048
// fx.hover: highlight data on hover
5149
// evt can be a mousemove event, or an object with data about what points
5250
// to hover on
@@ -631,9 +629,10 @@ function _hover(gd, evt, subplot, noHoverEvent) {
631629
hoverData.sort(function(d1, d2) { return d1.distance - d2.distance; });
632630

633631
// If in compare mode, select every point at position
634-
if(hoverData[0].length !== 0 &&
635-
XY[mode] &&
636-
hoverData[0].trace.type !== 'splom' // TODO: add support for splom
632+
if(
633+
helpers.isXYhover(mode) &&
634+
hoverData[0].length !== 0 &&
635+
hoverData[0].trace.type !== 'splom' // TODO: add support for splom
637636
) {
638637
var hd = hoverData[0];
639638
var cd0 = hd.cd[hd.index];

0 commit comments

Comments
 (0)