Skip to content

Commit 2864e68

Browse files
committed
Incorporated p2d and clientX event
1 parent 43ccc25 commit 2864e68

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/components/fx/click.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,14 @@ module.exports = function click(gd, evt, subplot) {
3333
} else if(clickmode.indexOf('anywhere') > -1) {
3434
var xaxis = gd._fullLayout.xaxis;
3535
var yaxis = gd._fullLayout.yaxis;
36-
var l = gd._fullLayout.margin.l;
37-
var t = gd._fullLayout.margin.t;
38-
var x = xaxis.p2c(evt.pointerX - l);
39-
var y = yaxis.p2c(evt.pointerY - t);
36+
var bb = evt.target.getBoundingClientRect();
37+
var x = xaxis.p2d(evt.clientX - bb.left);
38+
var y = yaxis.p2d(evt.clientY - bb.top);
4039
data = [{x: x, y: y}];
4140
}
4241
if(data) {
4342
if(annotationsDone && annotationsDone.then) {
44-
// TODO(j) add gd._hoverdata to emitClick here
45-
annotationsDone.then(emitClick);
43+
annotationsDone.then(function() { emitClick(data); });
4644
} else emitClick(data);
4745
}
4846

0 commit comments

Comments
 (0)