Skip to content

Commit 27eb8c3

Browse files
committed
events: fix plotly events in geo plots
1 parent 9cf50c2 commit 27eb8c3

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

src/plots/cartesian/graph_interact.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -416,10 +416,14 @@ function hover(gd, evt, subplot) {
416416
// on the currently selected plot area
417417
var xpx, ypx;
418418

419-
// mouse event? ie is there a target element with
420-
// clientX and clientY values?
421-
if(evt.target && ('clientX' in evt) && ('clientY' in evt)) {
419+
if('xpx' in evt || 'ypx' in evt) {
420+
if('xpx' in evt) xpx = evt.xpx;
421+
else xpx = xaArray[0]._length / 2;
422422

423+
if('ypx' in evt) ypx = evt.ypx;
424+
else ypx = yaArray[0]._length / 2;
425+
}
426+
else {
423427
// fire the beforehover event and quit if it returns false
424428
// note that we're only calling this on real mouse events, so
425429
// manual calls to fx.hover will always run.
@@ -438,13 +442,6 @@ function hover(gd, evt, subplot) {
438442
return dragElement.unhoverRaw(gd, evt);
439443
}
440444
}
441-
else {
442-
if('xpx' in evt) xpx = evt.xpx;
443-
else xpx = xaArray[0]._length / 2;
444-
445-
if('ypx' in evt) ypx = evt.ypx;
446-
else ypx = yaArray[0]._length / 2;
447-
}
448445

449446
if('xval' in evt) xvalArray = flat(subplots, evt.xval);
450447
else xvalArray = p2c(xaArray, xpx);

src/plots/geo/geo.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,9 @@ proto.plot = function(geoCalcData, fullLayout, promises) {
9191

9292
if(!lonlat || isNaN(lonlat[0]) || isNaN(lonlat[1])) return;
9393

94-
var evt = {
95-
target: true,
96-
xpx: mouse[0],
97-
ypx: mouse[1]
98-
};
94+
var evt = d3.event;
95+
evt.xpx = mouse[0];
96+
evt.ypx = mouse[1];
9997

10098
_this.xaxis.c2p = function() { return mouse[0]; };
10199
_this.xaxis.p2c = function() { return lonlat[0]; };
@@ -110,7 +108,7 @@ proto.plot = function(geoCalcData, fullLayout, promises) {
110108
});
111109

112110
_this.framework.on('click', function() {
113-
Fx.click(_this.graphDiv, { target: true });
111+
Fx.click(_this.graphDiv, d3.event);
114112
});
115113

116114
topojsonNameNew = topojsonUtils.getTopojsonName(geoLayout);

0 commit comments

Comments
 (0)