@@ -45,7 +45,7 @@ function initGraph() {
45
45
let data = structuredClone ( treeData ) ; // A clone is made to avoid any modifications in the original data
46
46
for ( let i = 0 ; i < data . length ; i ++ )
47
47
{
48
- /// Expand the nodes with no parents and initialize shownNodesMap with the shown nodes in the tree
48
+ // Expand the nodes with no parents and initialize shownNodesMap with the shown nodes in the tree
49
49
// and nodeChildrenStateMap with the state of the node children(expanded or collapsed)
50
50
if ( data [ i ] [ "parentIds" ] . length === 0 )
51
51
{
@@ -61,18 +61,17 @@ function initGraph() {
61
61
shownNodesMap [ data [ i ] [ "id" ] ] = 0 ;
62
62
}
63
63
}
64
- /// Get nodes with no children to draw them without children expand/collapse button
64
+ // Get nodes with no children to draw them without children expand/collapse button
65
65
if ( getNodeChildren ( data [ i ] [ "id" ] , data ) . length === 0 )
66
66
{
67
67
leavesNodesIds . push ( data [ i ] [ "id" ] )
68
68
}
69
69
}
70
- /// Remove hidden parents of the nodes in the currentTree
70
+ // Remove hidden parents of the nodes in the currentTree
71
71
for ( let i = 0 ; i < currentTree . length ; i ++ )
72
72
{
73
73
if ( shownNodesMap [ currentTree [ i ] [ "id" ] ] === 1 )
74
74
{
75
- // currentTree[i]["parentIds"] = removeHiddenParents(currentTree[i]["id"]);
76
75
removeHiddenParents ( currentTree [ i ] [ "parentIds" ] ) ;
77
76
}
78
77
}
@@ -124,7 +123,6 @@ function initGraph() {
124
123
let node = getNodeByTitle ( d . currentTarget . __data__ . data . title ) ;
125
124
$ ( "#info_box" ) . empty ( ) ;
126
125
addNodeInfos ( node , "preview" ) ;
127
- // document.getElementById("preview").scrollIntoView({ behavior: 'smooth' });
128
126
updateGraphPlot ( currentNodeId ) ;
129
127
}
130
128
@@ -137,7 +135,6 @@ function initGraph() {
137
135
let node = getNodeByTitle ( d . currentTarget . __data__ . data . title ) ;
138
136
$ ( "#info_box" ) . empty ( ) ;
139
137
addNodeInfos ( node , "preview" ) ;
140
- // document.getElementById("preview").scrollIntoView({ behavior: 'smooth' });
141
138
updateGraphPlot ( currentNodeId ) ;
142
139
}
143
140
@@ -178,7 +175,6 @@ function initGraph() {
178
175
. text ( word ) ;
179
176
}
180
177
}
181
- // set new box height
182
178
} ) ;
183
179
}
184
180
/**
@@ -239,7 +235,7 @@ function onNodeParentsToggle(d)
239
235
* @param {String } state node to be expanded or collapsed
240
236
*/
241
237
function updateTree ( currentNodeId , state ) {
242
- let data = structuredClone ( treeData ) ; // A clone is made to avoid any modifications in the original data
238
+ let data = structuredClone ( treeData ) ; // A clone is made to avoid any modifications in the original data
243
239
if ( state === "children expand" )
244
240
{
245
241
nodeChildrenExpand ( currentNodeId , data ) ;
@@ -262,8 +258,6 @@ function updateTree(currentNodeId,state){
262
258
updateShownNodeMap ( treeData )
263
259
highlightSelectedNode ( currentNodeId ) ;
264
260
updateTreeGraph ( currentTree , currentNodeId , state ) ;
265
- // graph
266
- // .attr('transform', zoomTransform);
267
261
}
268
262
269
263
/**
@@ -281,7 +275,6 @@ function drawTree(drawData,state)
281
275
// --------------------------------
282
276
// This code only handles rendering
283
277
// --------------------------------
284
- // keepTopLayersNodesUp();
285
278
svgSelection = d3 . select ( "svg" ) ;
286
279
svgSelection . selectAll ( '*' ) . remove ( ) ;
287
280
if ( state === "expand tree" )
@@ -372,7 +365,7 @@ function drawTree(drawData,state)
372
365
. attr ( "x" , nodeWidth - 20 - ( 5 / 2 ) )
373
366
. html ( "i" ) ;
374
367
375
- /// Filter nodes with no parent to add parents expand/collapse button
368
+ // Filter nodes with no parent to add parents expand/collapse button
376
369
let rootsNodes = nodes . filter ( function ( node ) {
377
370
return ! nodeParentsStateMap [ node . data . id ] ;
378
371
} )
@@ -391,7 +384,7 @@ function drawTree(drawData,state)
391
384
. attr ( "y" , 8.5 )
392
385
. html ( "+" )
393
386
394
- /// Filter nodes with no children to add expand/collapse button
387
+ // Filter nodes with no children to add expand/collapse button
395
388
let leavesNodes = nodes . filter ( function ( node ) {
396
389
return ! leavesNodesIds . includes ( node . data . id ) ;
397
390
} )
@@ -493,7 +486,7 @@ function nodeChildrenExpand(currentNodeId,data)
493
486
{
494
487
if ( data [ i ] [ "parentIds" ] . includes ( currentNodeId ) )
495
488
{
496
- /// If the child is already shown, add the parent to it in currentTree
489
+ // If the child is already shown, add the parent to it in currentTree
497
490
if ( shownNodesMap [ data [ i ] [ "id" ] ] === 1 )
498
491
{
499
492
for ( let j = 0 ; j < currentTree . length ; j ++ )
@@ -515,7 +508,7 @@ function nodeChildrenExpand(currentNodeId,data)
515
508
nodeChildren . push ( data [ i ] [ "id" ] ) ;
516
509
}
517
510
}
518
- /// Link new nodes (clicked node children) to their existing children
511
+ // Link new nodes (clicked node children) to their existing children
519
512
linkNewNodes ( nodeChildren , data )
520
513
}
521
514
/**
@@ -621,7 +614,7 @@ function expandSearchedNodeTree(node)
621
614
currentTree . push ( node ) ;
622
615
}
623
616
let nodeParentsQueue = node . parentIds . slice ( 0 ) ;
624
- //show node parents till the top layer
617
+ // show node parents till the top layer
625
618
while ( nodeParentsQueue . length > 0 )
626
619
{
627
620
let parentId = nodeParentsQueue . shift ( ) ;
@@ -635,7 +628,7 @@ function expandSearchedNodeTree(node)
635
628
nodeParentsQueue . push ( elem ) ;
636
629
} )
637
630
}
638
- //show node children
631
+ // show node children
639
632
let children = getNodeChildren ( node . id , data ) ;
640
633
children . forEach ( function ( child ) {
641
634
if ( shownNodesMap [ child . id ] !== 1 )
@@ -727,7 +720,6 @@ function updateTreeGraph(drawData,currentNodeId,state)
727
720
graph . select ( ".paths-list" ) . selectAll ( "*" ) . remove ( ) ;
728
721
generateTreeLayout ( drawData ) ;
729
722
layout ( dag ) ;
730
- // keepTopLayersNodesUp();
731
723
732
724
// Remove collapsed nodes before starting the animation
733
725
let collapsedNodes = nodes . filter ( function ( node ) {
@@ -822,7 +814,7 @@ function keepTopLayersNodesUp()
822
814
{
823
815
let rootsNodesY = 100000 ;
824
816
let rootsNodesX = [ ] ;
825
- //get roots nodes y-coordinate(the minimum to make it constant for all of them) and x-coordinates
817
+ // get roots nodes y-coordinate(the minimum to make it constant for all of them) and x-coordinates
826
818
dag . descendants ( ) . forEach ( function ( node ) {
827
819
if ( node . y < rootsNodesY )
828
820
{
@@ -836,7 +828,7 @@ function keepTopLayersNodesUp()
836
828
rootsNodesX . sort ( function ( a , b ) { return a - b } ) ;
837
829
let xStep = ( rootsNodesX [ rootsNodesIds . length - 1 ] - rootsNodesX [ 0 ] ) / rootsNodesIds . length ; //horizontal space between roots nodes
838
830
let i = 0 ;
839
- //Set the new coordinates to the roots nodes
831
+ // Set the new coordinates to the roots nodes
840
832
dag . descendants ( ) . forEach ( function ( node ) {
841
833
if ( rootsNodesIds . includes ( node . data . id ) )
842
834
{
@@ -846,7 +838,7 @@ function keepTopLayersNodesUp()
846
838
i += 1 ;
847
839
}
848
840
} )
849
- //Set the new coordinates to the roots nodes links
841
+ // Set the new coordinates to the roots nodes links
850
842
dag . links ( ) . forEach ( function ( node ) {
851
843
if ( rootsNodesIds . includes ( node . source . data . id ) )
852
844
{
0 commit comments