-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtooltip.js
109 lines (101 loc) · 3.46 KB
/
tooltip.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
var tooltip = d3.select(".custom-tooltip")
var accOrRej = function(d){
return (d.id===0) ? "Yes" : "No"
}
d3.select('.force-directed').selectAll("circle")
.on("mousemove", function(d){
tooltip.transition().duration(100)
.style("opacity", .9)
tooltip.html(
'<table border="0" align="center" cellpadding="5" cellspacing="3">'
+ '<tbody>'
+ '<tr>'
+ '<td>Accepted?</td>'
+ '<td style="border-radius: 2px; background-color:' + colorScale(d.id) + ';">'
+ accOrRej(d)
+ '</td>'
+ '</tr>'
+'<tr>'
+ '<td>Department: </td>'
+ '<td>'+ d.department
+ '</tr>'
+'<tr>'
+ '<td>Gender: </td>'
+ '<td>'+ d.sex + '</td>'
+ '</tr>'
+ '</tbody>'
+ '</table>')
.style("left", (d3.event.pageX + 10) + "px")
.style("top", (d3.event.pageY - 110) + "px")
d3.select(this).transition().duration(25)
.attr('r', '6')
})
.on("mouseout", function(d) {
tooltip.transition().duration(200)
.style("opacity", 0);
d3.select(this).transition().duration(50)
// TODO: hardcoding the normal radius like this is sort of hacky
// but it gets the job down for now.
.attr('r', '2.2257336343115126')
})
d3.select('.svg-line').selectAll('circle')
.on("mousemove", function(d){
tooltip.transition().duration(100)
.style('opacity', 0.9)
tooltip.html(
'<table style="margin-bottom: 5px;" border="0" align="center" cellpadding="5" cellspacing="3">'
+ '<tbody>'
+ '<tr style="background-color:' + d.col + ';">'
+ '<td style="border-radius: 2px;">'
+ '( ' + d.x + ' , ' + d.y + ' )'
+ '</td>'
+ '</tr>'
+ '</tbody>'
+ '</table>')
.style("left", (d3.event.pageX + 10) + "px")
.style("top", (d3.event.pageY - 70) + "px")
d3.select(this).transition().duration(25)
.attr('stroke', 'white')
.attr('stroke-width','2px')
})
.on('mouseout', function(d) {
tooltip
.transition()
.duration(200)
.style('opacity', 0)
d3.select(this).transition().duration(25)
.attr("stroke", "#2C3E50")
.attr("stroke-width", "1px")
})
d3.selectAll(".arc")
.on("mousemove", function(d){
tooltip.transition().duration(100)
.style("opacity", .9);
tooltip.html(
'<table style="margin-bottom: 5px;" border="0" align="center" cellpadding="5" cellspacing="3">'
+ '<tbody>'
+ '<tr>'
+ '<td style="border-radius: 2px; font-weight: bold; background-color:' + color(d.data.accepted) + ';">'
+ d.data.accepted
+ '</td>'
+ '<td>'
+ d.data.percent + '%'
+ '</td>'
+ '</tr>'
+ '</tbody>'
+ '</table>')
.style("left", (d3.event.pageX + 10) + "px")
.style("top", (d3.event.pageY - 70) + "px")
d3.select(this).select("path").transition().duration(50)
.attr("stroke", "white")
.attr("stroke-width","10px")
})
.on("mouseout", function(){
tooltip
.transition()
.duration(200)
.style("opacity", 0)
d3.select(this).select("path").transition().duration(50)
.attr("stroke", "white")
.attr("stroke-width","1px")
})