Skip to content

Commit 8aa4397

Browse files
committed
fix bug in heatmap + non-heatmap hover
if you make this plot, you could never hover on the scatter points: Plotly.newPlot(gd, [ {x:[1,2,3], y: [1,4,7], z:[[1,2,3],[4,5,6],[7,8,9]], type:'heatmap'}, {x:[1,2,3], y:[1,4,7]} ],{hovermode:'closest'}) Fx.MAXDIST had moved so sorting point distance was broken with heatmaps.
1 parent 43e8d30 commit 8aa4397

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/traces/heatmap/hover.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
'use strict';
1111

1212
var Fx = require('../../plots/cartesian/graph_interact');
13+
var constants = require('../../plots/cartesian/constants');
1314
var Lib = require('../../lib');
1415

1516

1617
module.exports = function hoverPoints(pointData, xval, yval, hovermode, contour) {
1718
// never let a heatmap override another type as closest point
18-
if(pointData.distance < Fx.MAXDIST) return;
19+
if(pointData.distance < constants.MAXDIST) return;
1920

2021
var cd0 = pointData.cd[0],
2122
trace = cd0.trace,
@@ -46,8 +47,8 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, contour)
4647
return;
4748
}
4849
}
49-
else if(Fx.inbox(xval - x[0], xval - x[x.length - 1]) > Fx.MAXDIST ||
50-
Fx.inbox(yval - y[0], yval - y[y.length - 1]) > Fx.MAXDIST) {
50+
else if(Fx.inbox(xval - x[0], xval - x[x.length - 1]) > constants.MAXDIST ||
51+
Fx.inbox(yval - y[0], yval - y[y.length - 1]) > constants.MAXDIST) {
5152
return;
5253
}
5354
else {
@@ -99,7 +100,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, contour)
99100
return [Lib.extendFlat(pointData, {
100101
index: [ny, nx],
101102
// never let a 2D override 1D type as closest point
102-
distance: Fx.MAXDIST + 10,
103+
distance: constants.MAXDIST + 10,
103104
x0: x0,
104105
x1: x1,
105106
y0: y0,

src/traces/scatter/hover.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
var Lib = require('../../lib');
1313
var Fx = require('../../plots/cartesian/graph_interact');
14+
var constants = require('../../plots/cartesian/constants');
1415
var ErrorBars = require('../../components/errorbars');
1516
var getTraceColor = require('./get_trace_color');
1617
var Color = require('../../components/color');
@@ -59,7 +60,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
5960

6061
Lib.extendFlat(pointData, {
6162
// never let a 2D override 1D type as closest point
62-
distance: Fx.MAXDIST + 10,
63+
distance: constants.MAXDIST + 10,
6364
x0: x0,
6465
x1: x1,
6566
y0: y0,

0 commit comments

Comments
 (0)