@@ -25,7 +25,8 @@ const Bubblechart = (aData) => {
25
25
. attr ( 'height' , diameter )
26
26
. attr ( 'class' , 'chart-svg' ) ;
27
27
28
-
28
+
29
+
29
30
30
31
let root = d3 . hierarchy ( jsonToDisplay )
31
32
. sum ( function ( d ) { console . log ( d . id ) ; return d . id ; } )
@@ -40,26 +41,28 @@ const Bubblechart = (aData) => {
40
41
. enter ( ) . append ( 'g' )
41
42
. attr ( 'class' , 'node' )
42
43
. attr ( 'transform' , function ( d ) { return 'translate(' + d . x + ' ' + d . y + ')' ; } )
44
+
45
+
43
46
44
- let tooltip = svg
47
+ /* let tooltip = node.append('tooltip')
45
48
.append("div")
46
- . style ( "opacity" , 1 )
47
- . attr ( "id " , "tooltip" )
49
+ .style("opacity", 0 )
50
+ .attr("class ", "tooltip")
48
51
.style("z-index", "10")
49
52
.style("background-color", "black")
50
53
.style("border-radius", "5px")
51
54
.style("padding", "10px")
52
55
.style("color", "white")
53
- . style ( "position" , "absolute" ) ;
56
+
54
57
let showTooltip = function(d) {
55
58
tooltip
56
59
.transition()
57
60
.duration(200)
58
- tooltip
59
61
.style("opacity", 1)
60
- . style ( "visibility" , "visible" )
61
62
.style("stroke", "black")
62
- . text ( "Player: jklkjljljljlklklkljjkljlkj <br> Points with franchise: " )
63
+ .text(function (d) {
64
+ console.log("contribution" + d.data.contributions);
65
+ return "Name : " + d.data.login + "<br/>Contribution: " + d.contributions })
63
66
.style("left", (d.x + (d3.pointer(this)[0] + 90)) + "px")
64
67
.style("top", (d.y + (d3.pointer(this)[1])) + "px");
65
68
}
@@ -74,7 +77,7 @@ const Bubblechart = (aData) => {
74
77
.duration(200)
75
78
.style("opacity", 0)
76
79
.style("visibility", "hidden");
77
- }
80
+ }*/
78
81
79
82
let defs = node . append ( 'defs' ) ;
80
83
@@ -102,9 +105,31 @@ const Bubblechart = (aData) => {
102
105
. style ( "fill" , "#fff" )
103
106
. style ( "fill" , function ( d ) { return "url(#" + d . data . id + ")" } )
104
107
. style ( "stroke" , "black" )
105
- . on ( "mouseover" , showTooltip )
106
- . on ( "mousemove" , moveTooltip )
107
- . on ( "mouseleave" , hideTooltip )
108
+ . on ( "mouseover" , mouseover )
109
+ . on ( "mousemove" , mousemove )
110
+ . on ( "mouseout" , mouseout ) ;
111
+
112
+
113
+ let div = d3 . select ( "#bubble" ) . append ( "div" )
114
+ . attr ( "class" , "tooltip" )
115
+ . style ( "display" , "none" ) ;
116
+
117
+ function mouseover ( ) {
118
+ div . style ( "display" , "inline" ) ;
119
+ }
120
+
121
+ function mousemove ( event , d ) {
122
+ const [ x , y ] = d3 . pointer ( event ) ;
123
+ div
124
+ . text ( x + ", " + y )
125
+ . style ( "left" , ( x ) + "px" )
126
+ . style ( "top" , ( y ) + "px" ) ;
127
+ }
128
+
129
+ function mouseout ( ) {
130
+ div . style ( "display" , "none" ) ;
131
+ }
132
+
108
133
109
134
node . append ( "text" )
110
135
. attr ( "dy" , ".3em" )
@@ -121,7 +146,7 @@ const Bubblechart = (aData) => {
121
146
122
147
123
148
return (
124
- < div >
149
+ < div id = "bubble" className = "bubble" >
125
150
< svg id = "chart" className = "chart" > </ svg >
126
151
</ div >
127
152
) ;
0 commit comments