File tree 6 files changed +161
-70
lines changed
6 files changed +161
-70
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,6 @@ function contextOptions(d, i) {
25
25
transition ( n . parent ) ;
26
26
return ;
27
27
}
28
-
29
28
} ) ;
30
29
31
30
searchNodes ( root , d . name ) ;
@@ -35,15 +34,33 @@ function contextOptions(d, i) {
35
34
}
36
35
}
37
36
38
-
39
37
function searchNodes ( d , s ) {
40
- if ( d . data . name == s ) {
38
+ s = s . toLowerCase ( ) ;
39
+ if ( d . data . name == s || d . data . alttitles . includes ( s ) ) {
41
40
transition ( d . parent ) ;
42
- return ;
41
+ return ;
43
42
}
44
43
if ( d . children ) {
45
44
for ( let i in d . children ) {
46
45
searchNodes ( d . children [ i ] , s ) ;
47
- }
46
+ }
47
+ }
48
+ }
49
+
50
+ function search ( s ) {
51
+ searchNodes ( root , s ) ;
52
+ }
53
+
54
+
55
+ function getIncoming ( d , s ) {
56
+
57
+ if ( d . data . connections . includes ( s ) ) {
58
+ //addPath()
59
+ }
60
+
61
+ if ( d . children ) {
62
+ for ( let i in d . children ) {
63
+ getIncoming ( d . children [ i ] , s ) ;
64
+ }
48
65
}
49
66
}
Original file line number Diff line number Diff line change 11
11
< body >
12
12
< div class ="container " align ="center " >
13
13
< div class ="container " >
14
- < div align ="left " style ="display: inline-block; outline: 1px solid grey; padding: 4px; " >
15
- <!-- Search form -->
16
- < div class ="md-form mb-3 ">
17
- < input class ="form-control " type ="text " placeholder ="Search " aria-label ="Search " style ="background: none ">
14
+ < div align ="left " style ="display: inline-block; padding: 5px; border: 1px solid #353b45; margin: 10px " >
15
+ < div class ="md-form mb-3 " style ="margin-right: 50px; margin-left: 50px; margin-top: 15px ">
16
+ < input class ="form-control " id ="Search " type ="text " placeholder ="Search " style ="background: #0e0f12; box-shadow: 0px 0px 5px #0e0f12; border: none; " >
18
17
</ div >
19
- < text style ="color:white ; font-size:13px "> //Grey matter:</ text >
18
+ < text style ="color:#8992a1 ; font-size:13px "> //Grey matter:</ text >
20
19
< div id ="treemapChart "> </ div >
21
- < text style ="color:white ; font-size:13px "> //White matter:</ text >
20
+ < text style ="color:#8992a1 ; font-size:13px "> //White matter:</ text >
22
21
< div id ="sankeyChart ">
23
22
</ div >
24
23
</ div >
33
32
< script src ="treemap.js "> </ script >
34
33
< script src ="contextmenu.js "> </ script >
35
34
< script src ="sankey.js "> </ script >
35
+ < script >
36
+ $ ( "#Search" ) . keydown ( function ( event ) {
37
+ if ( event . keyCode === 13 ) {
38
+ search ( $ ( "#Search" ) . val ( ) ) ;
39
+ }
40
+ } ) ;
41
+ </ script >
36
42
</ body >
37
43
</ html >
Original file line number Diff line number Diff line change @@ -138,16 +138,14 @@ function loadSankey(graph) {
138
138
139
139
// the function for moving the nodes
140
140
function dragmove ( d ) {
141
- d3
142
- . select ( this )
143
- . attr (
144
- "transform" ,
145
- "translate(" +
146
- d . x +
147
- "," +
148
- ( d . y = Math . max ( 0 , Math . min ( height - d . dy , d3 . event . y ) ) ) +
149
- ")"
150
- ) ;
141
+ d3 . select ( this ) . attr (
142
+ "transform" ,
143
+ "translate(" +
144
+ d . x +
145
+ "," +
146
+ ( d . y = Math . max ( 0 , Math . min ( height - d . dy , d3 . event . y ) ) ) +
147
+ ")"
148
+ ) ;
151
149
sankey . relayout ( ) ;
152
150
link . attr ( "d" , path ) ;
153
151
}
Original file line number Diff line number Diff line change
1
+
2
+
1
3
@font-face {
2
4
font-family : LiberationSans;
3
5
src : url ("fonts/LiberationSans-Regular-webfont.woff" );
4
6
}
5
7
8
+ text {
9
+ pointer-events : none;
10
+ font-family : "LiberationSans" ;
11
+ }
12
+
6
13
body {
7
14
background-color : # 24282e ;
8
15
font-family : LiberationSans;
@@ -12,76 +19,84 @@ body {
12
19
width : 750px ;
13
20
overflow : auto;
14
21
}
22
+
15
23
# sankeyChart {
16
24
overflow : hidden;
17
25
}
18
26
19
- text {
20
- pointer-events : none;
21
- font-family : "LiberationSans" ;
22
- }
23
- .grandparent text {
24
- }
27
+
28
+ /*Treemap styles*/
29
+
30
+ .grandparent text {}
31
+
25
32
rect {
26
33
stroke : grey;
27
34
stroke-opacity : 0.2 ;
28
35
stroke-width : 1px ;
29
36
}
37
+
30
38
rect .parent ,
31
- .grandparent rect {
32
- }
39
+ .grandparent rect {}
40
+
33
41
.grandparent : hover rect {
34
42
fill : grey;
35
43
}
44
+
36
45
.children rect .parent ,
37
46
.grandparent rect {
38
47
cursor : pointer;
39
48
}
49
+
40
50
.children rect .child {
41
51
opacity : 0 ;
42
52
}
43
- .children rect .parent {
44
- }
53
+
54
+ .children rect .parent {}
55
+
45
56
.children : hover rect .child {
46
57
opacity : 0.7 ;
47
58
transition : 1s ;
48
59
}
60
+
49
61
.children : hover rect .parent {
50
62
opacity : 0.2 ;
51
63
transition : 0.3s ;
52
64
}
53
- .legend {
54
- /* margin-bottom:8px !important;*/
55
- }
56
- .legend rect {
57
- }
65
+
58
66
.legend text {
59
67
text-anchor : middle;
60
68
pointer-events : auto;
61
69
}
70
+
62
71
.form-group {
63
72
text-align : left;
64
73
}
74
+
65
75
.textdiv {
66
76
font-size : 14px ;
67
77
padding : 7px ;
68
78
cursor : pointer;
69
79
overflow : none;
70
80
}
81
+
71
82
.textdiv .title {
72
83
font-family : "LiberationSans" ;
73
84
font-size : 102% ;
74
85
font-weight : bold;
75
86
margin-top : 8px ;
76
87
font-size : 13px !important ;
77
88
}
89
+
78
90
.textdiv p {
79
91
line-height : 13px ;
80
92
margin : 0 0 4px !important ;
81
93
padding : 0px ;
82
94
font-size : 10px !important ;
83
95
}
84
96
97
+
98
+ /*Sankey Map Styles*/
99
+
85
100
.node rect {
86
101
cursor : move;
87
102
shape-rendering : crispEdges;
@@ -102,6 +117,9 @@ rect.parent,
102
117
stroke-opacity : 0.5 ;
103
118
}
104
119
120
+
121
+ /*Context Menu Styles*/
122
+
105
123
.custom_menu {
106
124
padding : 0 ;
107
125
display : none;
@@ -113,7 +131,6 @@ rect.parent,
113
131
white-space : nowrap;
114
132
font-family : LiberationSans;
115
133
font-size : 14px ;
116
-
117
134
background : black;
118
135
opacity : 0.7 ;
119
136
color : white;
@@ -127,3 +144,4 @@ rect.parent,
127
144
.custom_menu li : hover {
128
145
background-color : # 8f3d3d ;
129
146
}
147
+
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ d3.json("whitematter.json", function(d) {
81
81
} ) ;
82
82
/* Adding a foreign object instead of a text object, allows for text wrapping */
83
83
g . append ( "foreignObject" ) . call ( rect ) . attr ( "class" , "foreignobj" ) . append ( "xhtml:div" ) . attr ( "dy" , ".75em" ) . html ( function ( d ) {
84
- let t = d . data . altTitles ? "/" + d . data . altTitles . join ( "<br>/" ) : "" ;
84
+ let t = d . data . alttitles ? "/" + d . data . alttitles . join ( "<br>/" ) : "" ;
85
85
return '' + '<p class="title"> ' + d . data . name + '</p>' + '<p>' + t + '</p>' ;
86
86
} ) . attr ( "class" , "textdiv" ) ; //textdiv class allows us to style the text easily with CSS
87
87
@@ -176,6 +176,22 @@ d3.json("whitematter.json", function(d) {
176
176
177
177
function name ( d ) {
178
178
return d . data . name ;
179
+ //uncomment when arrow glyphs are set up.
180
+ //return breadcrumbs(d);
181
+ }
182
+
183
+ function breadcrumbs ( d ) {
184
+ var res = "" ;
185
+ var sep = " <" ;
186
+ d . ancestors ( ) . forEach ( function ( i ) {
187
+ res += i . data . name + sep ;
188
+ } ) ;
189
+ return res
190
+ . split ( sep )
191
+ . filter ( function ( i ) {
192
+ return i !== "" ;
193
+ } )
194
+ . join ( sep ) ;
179
195
}
180
196
181
197
function comb ( d , dep , map , ref ) {
You can’t perform that action at this time.
0 commit comments