@@ -22,14 +22,11 @@ class RouteTrace {
2222 console . log ( 'data: ' , data )
2323 console . log ( 'nodes: ' , data [ 0 ] )
2424 console . log ( 'links: ' , data [ 1 ] )
25-
26- console . log ( '1st data point: ' , data [ 0 ] [ 0 ] )
27- console . log ( '4th data point: ' , data [ 0 ] [ 3 ] )
2825
29- var simulation = d3 . forceSimulation ( data [ 0 ] )
30- . force ( ' link' , d3 . forceLink ( ) )
31- . force ( 'charge' , d3 . forceManyBody ( ) )
32- . force ( 'center' , d3 . forceCenter ( width / 2 , height / 2 ) )
26+ const simulation = d3 . forceSimulation ( data [ 0 ] )
27+ . force ( " link" , d3 . forceLink ( data [ 1 ] ) . id ( data => data . id ) )
28+ . force ( 'charge' , d3 . forceManyBody ( ) . strength ( - 1000 ) )
29+ . force ( 'center' , d3 . forceCenter ( width / 2 , height / 2 ) )
3330
3431 const link = svg . append ( "g" )
3532 . attr ( "class" , "links" )
@@ -65,14 +62,14 @@ class RouteTrace {
6562 . on ( 'tick' , ticked ) ;
6663
6764 simulation . force ( 'link' )
68- // .links(data[1]); // error: cannot create property vx on books
65+ . links ( data [ 1 ] ) ; // error: cannot create property vx on books
6966
7067 function ticked ( ) {
7168 link
72- . attr ( 'x1' , function ( d ) { return d . source . x ; } )
73- . attr ( 'y1' , function ( d ) { return d . source . y ; } )
74- . attr ( 'x2' , function ( d ) { return d . target . x ; } )
75- . attr ( 'y2' , function ( d ) { return d . target . y ; } ) ;
69+ . attr ( "x1" , d => d . source . x )
70+ . attr ( "y1" , d => d . source . y )
71+ . attr ( "x2" , d => d . target . x )
72+ . attr ( "y2" , d => d . target . y ) ;
7673
7774 node
7875 . attr ( "transform" , function ( d ) {
0 commit comments