296
296
const showHierarchicalOptionsCheckbox = document . getElementById ( 'showHierarchicalOptions' ) ;
297
297
hierarchicalOptionsDirection . style [ 'display' ] = showHierarchicalOptionsCheckbox . checked ? 'block' : 'none' ;
298
298
hierarchicalOptionsSortMethod . style [ 'display' ] = showHierarchicalOptionsCheckbox . checked ? 'block' : 'none' ;
299
- const hierarchicalOptionsDirectionSelect = document . getElementById ( 'direction' ) ;
300
- const hierarchicalOptionsSortMethodSelect = document . getElementById ( 'sortMethod' ) ;
299
+
300
+ options . layout . hierarchical = {
301
+ enabled : false
302
+ } ;
303
+ options . physics = {
304
+ enabled : true ,
305
+ solver : 'repulsion'
306
+ } ;
301
307
if ( showHierarchicalOptionsCheckbox . checked ) {
308
+ const hierarchicalOptionsDirectionSelect = document . getElementById ( 'direction' ) ;
302
309
if ( hierarchicalOptionsDirectionSelect . value && hierarchicalOptionsDirectionSelect . value === 'Random' ) {
303
- nodes . getIds ( ) . forEach ( id => storeCoordinates ( nodes . get ( id ) ) ) ;
304
- options . layout = { hierarchical : { enabled : false } } ;
310
+ nodes . getIds ( ) . forEach ( id => storeCoordinates ( nodes . get ( id ) ) ) ;
305
311
seed = Math . random ( ) ;
312
+ options . layout . randomSeed = seed ;
306
313
} else if ( hierarchicalOptionsDirectionSelect . value && hierarchicalOptionsDirectionSelect . value === 'Fixed' ) {
307
- options . layout = { hierarchical : { enabled : false } } ;
308
- nodes . getIds ( ) . forEach ( id => restoreCoordinates ( nodes . get ( id ) ) ) ;
314
+ nodes . getIds ( ) . forEach ( id => restoreCoordinates ( nodes . get ( id ) ) ) ;
309
315
} else {
310
- options . layout = {
311
- hierarchical : {
312
- enabled : true ,
313
- direction : hierarchicalOptionsDirectionSelect . value ? hierarchicalOptionsDirectionSelect . value : defaultGraphDirection ,
314
- sortMethod : hierarchicalOptionsSortMethodSelect . value ? hierarchicalOptionsSortMethodSelect . value : 'hubsize'
315
- }
316
+ const hierarchicalOptionsSortMethodSelect = document . getElementById ( 'sortMethod' ) ;
317
+ options . layout . hierarchical = {
318
+ enabled : true ,
319
+ direction : hierarchicalOptionsDirectionSelect . value ? hierarchicalOptionsDirectionSelect . value : defaultGraphDirection ,
320
+ sortMethod : hierarchicalOptionsSortMethodSelect . value ? hierarchicalOptionsSortMethodSelect . value : 'hubsize'
316
321
} ;
317
322
}
318
323
} else {
319
- if ( defaultGraphDirection === '' ) {
320
- options . layout = { hierarchical : { enabled : false } } ;
321
- nodes . getIds ( ) . forEach ( id => restoreCoordinates ( nodes . get ( id ) ) ) ;
322
- } else {
323
- options . layout = {
324
- hierarchical : {
325
- enabled : true ,
326
- direction : defaultGraphDirection ,
327
- sortMethod : 'hubsize'
328
- }
329
- } ;
330
- nodes . getIds ( ) . forEach ( id => storeCoordinates ( nodes . get ( id ) ) ) ;
331
- }
324
+ nodes . getIds ( ) . forEach ( id => restoreCoordinates ( nodes . get ( id ) ) ) ;
332
325
}
333
- options . layout . randomSeed = seed ;
334
- network . setOptions ( {
335
- physics : {
336
- enabled : true ,
337
- solver : 'repulsion'
338
- }
339
- } ) ;
340
- nodes . getIds ( ) . forEach ( id => {
341
- const node = nodes . get ( id ) ;
342
- } ) ;
343
326
network = new vis . Network ( container , data , options ) ;
344
327
network . on ( "stabilizationIterationsDone" , function ( ) {
345
- network . setOptions ( { physics : false } ) ;
328
+ network . setOptions ( {
329
+ physics : false
330
+ } ) ;
346
331
} ) ;
347
332
}
348
-
349
333
} ( ) ) ;
0 commit comments