Skip to content

Commit 19f5e80

Browse files
author
Miltos Allamanis
committed
Fix tooltip location.
1 parent 7165d1c commit 19f5e80

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

tsne-viz.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,16 @@ <h2>2D Map of Papers</h2>
6666
for (i=0; i<d.tags.length; i++) {
6767
tags += "<tag>" + d.tags[i] + "</tag>&nbsp;"
6868
}
69+
70+
var boundingRect = document.getElementById("paperviz").getBoundingClientRect();
71+
var mousePos = d3.mouse(this);
72+
var x = mousePos[0] + boundingRect.x + 20;
73+
var y = mousePos[1] + boundingRect.y + 30;
74+
6975
tooltip
7076
.html("<p>" + d.title + " " + tags + "</p>")
71-
.style("left", (d3.mouse(this)[0]+30) + "px")
72-
.style("top", (d3.mouse(this)[1]) + "px");
77+
.style("left", x + "px")
78+
.style("top", y + "px");
7379
}
7480

7581
var click_link = function(d) {

0 commit comments

Comments
 (0)