@@ -68,7 +68,7 @@ d3.json("whitematter.json", function(d) {
68
68
69
69
// write text into grandparent
70
70
// and activate click's handler
71
- grandparent . datum ( d . parent ) . on ( "click" , transition ) . select ( "text" ) . text ( name ( d ) ) ;
71
+ grandparent . datum ( d . parent ) . on ( "click" , d => transition ( d ) ) . select ( "text" ) . text ( name ( d ) ) ;
72
72
// grandparent color
73
73
grandparent . datum ( d . parent ) . select ( "rect" ) . attr ( "fill" , function ( ) {
74
74
return 'grey'
@@ -80,7 +80,7 @@ d3.json("whitematter.json", function(d) {
80
80
g . filter ( function ( d ) {
81
81
return d . children ;
82
82
83
- } ) . classed ( "children" , true ) . on ( "click" , transition ) ;
83
+ } ) . classed ( "children" , true ) . on ( "click" , d => transition ( d ) ) ;
84
84
g . selectAll ( ".child" ) . data ( function ( d ) {
85
85
return d . children || [ d ] ;
86
86
} ) . enter ( ) . append ( "rect" ) . attr ( "class" , "child" ) . call ( rect ) ;
@@ -95,9 +95,12 @@ d3.json("whitematter.json", function(d) {
95
95
96
96
generateSankey ( d ) ;
97
97
98
- function transition ( d ) {
99
98
100
- focus = d ;
99
+
100
+
101
+ window . transition = function ( d ) {
102
+
103
+ d != undefined ? focus = d : d = focus ;
101
104
102
105
generateSankey ( d ) ;
103
106
@@ -141,7 +144,7 @@ d3.json("whitematter.json", function(d) {
141
144
} ) ;
142
145
}
143
146
return g ;
144
- }
147
+ } ;
145
148
146
149
function text ( text ) {
147
150
text . attr ( "x" , function ( d ) {
0 commit comments