2
2
< meta charset ="utf-8 ">
3
3
< style >
4
4
5
- body {
5
+ . node {
6
6
font : 11px "Helvetica Neue" , Helvetica, Arial, sans-serif;
7
7
}
8
+ .node : hover circle {
9
+ stroke : red;
10
+ stroke-width : 4px ;
11
+ }
8
12
9
- .node {
10
- font : 11px "Helvetica Neue" , Helvetica, Arial, sans-serif;
13
+ .node .link {
14
+ stroke-width : 0 ;
15
+ }
16
+ .node : hover .link {
17
+ stroke-width : 4px ;
11
18
}
12
19
13
20
.link {
@@ -67,20 +74,14 @@ <h1>IPFS TestNet</h1>
67
74
. data ( graph . nodes )
68
75
. enter ( ) . append ( "g" )
69
76
. attr ( "class" , "node" )
70
- . attr ( "transform" , function ( d ) { return "rotate(" + ( d . x - 90 + rotate ) + ")translate(" + d . y + ")" ; } )
77
+
78
+ var p = projection
71
79
72
80
node . append ( "svg:circle" )
73
- . attr ( "r" , function ( d ) { return d . conns + 3 ; } )
81
+ . attr ( "r" , function ( d ) { return d . conns + 2 ; } )
74
82
. style ( "fill" , function ( d , i ) { return color ( i % 20 ) ; } )
83
+ . attr ( "transform" , function ( d ) { return "rotate(" + ( d . x - 90 + rotate ) + ")translate(" + d . y + ")" ; } )
75
84
76
- node . append ( "text" )
77
- . attr ( "dx" , function ( d ) { return 8 ; } )
78
- . attr ( "dy" , ".31em" )
79
- // .attr("text-anchor", function(d) { return d.x < 180 ? "start" : "end"; })
80
- // .attr("transform", function(d) { return d.x < 180 ? null : "rotate(180)"; })
81
- . text ( function ( d ) { return d . conns + " - " + d . name ; } ) ;
82
-
83
- var p = projection
84
85
var link = svg . selectAll ( ".link" )
85
86
. data ( graph . paths )
86
87
. enter ( ) . append ( "path" )
@@ -90,9 +91,26 @@ <h1>IPFS TestNet</h1>
90
91
+ "S" + p ( d [ 1 ] ) [ 0 ] + "," + p ( d [ 1 ] ) [ 1 ]
91
92
+ " " + p ( d [ 2 ] ) [ 0 ] + "," + p ( d [ 2 ] ) [ 1 ] ;
92
93
} )
93
- . style ( "stroke" , function ( d ) { return color ( d [ 0 ] . index % 20 ) ; } )
94
- . style ( "stroke-opacity" , function ( d ) { return 0.3 ; } )
95
94
95
+ node . selectAll ( '.link' )
96
+ . data ( function ( d ) { return d . links } )
97
+ . enter ( ) . append ( 'path' )
98
+ . attr ( 'class' , 'link' )
99
+ . style ( "stroke" , function ( d ) { return color ( d . source . index % 20 ) ; } )
100
+ . attr ( "d" , function ( d ) {
101
+ return "M" + p ( d . path [ 0 ] ) [ 0 ] + "," + p ( d . path [ 0 ] ) [ 1 ]
102
+ + "S" + p ( d . path [ 1 ] ) [ 0 ] + "," + p ( d . path [ 1 ] ) [ 1 ]
103
+ + " " + p ( d . path [ 2 ] ) [ 0 ] + "," + p ( d . path [ 2 ] ) [ 1 ] ;
104
+ } )
105
+
106
+ node . append ( "text" )
107
+ . attr ( "class" , "label" )
108
+ . attr ( "dx" , - 4 )
109
+ . attr ( "dy" , 3 )
110
+ // .attr("text-anchor", function(d) { return d.x < 180 ? "start" : "end"; })
111
+ // .attr("transform", function(d) { return d.x < 180 ? null : "rotate(180)"; })
112
+ . text ( function ( d ) { return d . conns + " - " + d . name ; } )
113
+ . attr ( "transform" , function ( d ) { return "rotate(" + ( d . x - 90 + rotate ) + ")translate(" + d . y + ")" ; } )
96
114
97
115
// var mid = svg.selectAll(".node-mid")
98
116
// .data(graph.mids)
@@ -126,9 +144,10 @@ <h1>IPFS TestNet</h1>
126
144
data . y = innerRadius
127
145
data . x = ( ( 360 / graph2 . nodes . length ) * i )
128
146
data . conns = 0
129
- data . index = i
130
147
graph . nodes . push ( data )
131
148
graph . byName [ data . name ] = data
149
+ data . index = i
150
+ data . links = [ ]
132
151
} )
133
152
134
153
graph2 . links . forEach ( function ( link ) {
@@ -147,6 +166,9 @@ <h1>IPFS TestNet</h1>
147
166
148
167
var path = [ source , mid , target ]
149
168
graph . paths . push ( path )
169
+
170
+ source . links . push ( { path : path , source : source } )
171
+ target . links . push ( { path : path , source : target } )
150
172
} )
151
173
152
174
document . getElementById ( "node-count" ) . innerText = graph . nodes . length
0 commit comments