Skip to content

Commit 0117b41

Browse files
committed
888: fixup scattermapbox both select and hover
1 parent 76afc6c commit 0117b41

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/plots/mapbox/mapbox.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -382,18 +382,14 @@ proto.createFramework = function(fullLayout) {
382382
div.style.position = 'absolute';
383383
self.container.appendChild(div);
384384

385-
var gd = self.gd;
386-
var scaleX = gd._fullLayout._inverseScaleX;
387-
var scaleY = gd._fullLayout._inverseScaleY;
388-
389385
// create mock x/y axes for hover routine
390386
self.xaxis = {
391387
_id: 'x',
392-
c2p: function(v) { return self.project(v).x * scaleX; }
388+
c2p: function(v) { return self.project(v).x; }
393389
};
394390
self.yaxis = {
395391
_id: 'y',
396-
c2p: function(v) { return self.project(v).y * scaleY; }
392+
c2p: function(v) { return self.project(v).y; }
397393
};
398394

399395
self.updateFramework(fullLayout);

src/traces/scattermapbox/hover.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ module.exports = function hoverPoints(pointData, xval, yval) {
4242
var lon = Lib.modHalf(lonlat[0], 360);
4343
var lat = lonlat[1];
4444
var pt = subplot.project([lon, lat]);
45-
var dx = pt.x - xa.c2p([xval2, lat]);
46-
var dy = pt.y - ya.c2p([lon, yval]);
45+
var dx = pt.x - xa.c2p([xval2, lat]) * scaleX;
46+
var dy = pt.y - ya.c2p([lon, yval]) * scaleY;
4747
var rad = Math.max(3, d.mrc || 0);
4848

4949
return Math.max(Math.sqrt(dx * dx + dy * dy) - rad, 1 - 3 / rad);
@@ -60,8 +60,8 @@ module.exports = function hoverPoints(pointData, xval, yval) {
6060
var lonlatShifted = [Lib.modHalf(lonlat[0], 360) + lonShift, lonlat[1]];
6161

6262
// shift labels back to original winded globe
63-
var xc = xa.c2p(lonlatShifted) / scaleX;
64-
var yc = ya.c2p(lonlatShifted) / scaleY;
63+
var xc = xa.c2p(lonlatShifted);
64+
var yc = ya.c2p(lonlatShifted);
6565
var rad = di.mrc || 1;
6666

6767
pointData.x0 = xc - rad;

0 commit comments

Comments
 (0)