Skip to content

Commit b50c19c

Browse files
committed
Circular tooltip's position adjusted according to circular plot body
1 parent a729299 commit b50c19c

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

src/circularMap.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export default function (cloneData) {
8585
})
8686
.on("mouseover", function (d) {
8787

88-
// create a higlight arc to indicate graphic being hovered upon
88+
// create a higlight arc to indicate graphic being hovered upon
8989
let arcIndex = parseInt(d3.select(this).attr('class').split('-')[1]);
9090
d3.select(this)
9191
.append('path')
@@ -107,10 +107,10 @@ export default function (cloneData) {
107107
})
108108
.on("click", function (d) {
109109

110-
// remove previously highlighted arc
110+
// remove previously highlighted arc
111111
d3.select('.selected-index-arc').remove();
112112

113-
// create a higlight arc to indicate graphic being hovered upon
113+
// create a higlight arc to indicate graphic being hovered upon
114114
let clickedArcIndex = parseInt(d3.select(this).attr('class').split('-')[1]);
115115
d3.select(this)
116116
.append('path')
@@ -129,16 +129,23 @@ export default function (cloneData) {
129129

130130
cloneMap({ 'genealogyList': [d], versionCount, uniqueVersionList });
131131
})
132-
.on("mousemove", function () { return tooltip.style("top", (event.pageY - 10) + "px").style("left", (event.pageX + 10) + "px"); })
132+
.on("mousemove", function () {
133+
let c_info = circularRootSVG._groups[0][0].getBoundingClientRect();
134+
let c_tooltip_info = tooltip._groups[0][0].getBoundingClientRect();
135+
let t_y1 = event.pageY;
136+
let t_x1 = event.pageX;
137+
138+
//adjust circular tooltip
139+
if (t_x1 >= c_info.width/2 + c_info.left) {
140+
t_x1 -= c_tooltip_info.width;
141+
}
142+
if(t_y1 >= c_info.height) {
143+
t_y1 -= c_tooltip_info.height;
144+
}
145+
return tooltip.style("top", (t_y1) + "px").style("left", (t_x1) + "px");
146+
})
133147
.on("mouseout", function () {
134148
d3.selectAll('path.changeArc-pointer').remove();
135149
return tooltip.style("visibility", "hidden");
136150
})
137151
}
138-
139-
140-
141-
142-
143-
144-

0 commit comments

Comments
 (0)