33
33
} ;
34
34
var container = document . getElementById ( 'network' ) ;
35
35
var network = new vis . Network ( container , data , options ) ;
36
-
36
+ var seed = network . getSeed ( ) ;
37
+
37
38
const vscode = acquireVsCodeApi ( ) ;
38
39
const helpTextDiv = document . getElementById ( 'helpText' ) ;
39
40
let lastMouseX = lastMouseY = 0 ;
40
41
let mouseX = mouseY = 0 ;
41
42
let selection ;
42
43
// get the vis.js canvas
43
- const graphDiv = document . getElementById ( 'network' ) ;
44
- const visDiv = graphDiv . firstElementChild ;
45
- const graphCanvas = visDiv . firstElementChild ;
44
+ var graphDiv = document . getElementById ( 'network' ) ;
45
+ var visDiv = graphDiv . firstElementChild ;
46
+ var graphCanvas = visDiv . firstElementChild ;
46
47
const selectionLayer = document . getElementById ( 'selectionLayer' ) ;
47
48
const selectionCanvas = selectionLayer . firstElementChild ;
48
49
let selectionCanvasContext ;
55
56
const copyToClipboardButton = document . getElementById ( 'copyToClipboardButton' ) ;
56
57
copyToClipboardButton . addEventListener ( 'click' , copyToClipboard ) ;
57
58
copyToClipboardButton . style [ 'display' ] = 'none' ; // TODO: Remove when copyToClipboard is implemented
59
+ const showHierarchicalOptionsButton = document . getElementById ( 'showHierarchicalOptions' ) ;
60
+ showHierarchicalOptionsButton . addEventListener ( 'click' , setNetworkLayout ) ;
61
+ const hierarchicalDirectionSelect = document . getElementById ( 'direction' ) ;
62
+ hierarchicalDirectionSelect . addEventListener ( 'change' , setNetworkLayout ) ;
63
+ const hierarchicalSortMethodSelect = document . getElementById ( 'sortMethod' ) ;
64
+ hierarchicalSortMethodSelect . addEventListener ( 'change' , setNetworkLayout ) ;
58
65
59
66
function mouseUpEventListener ( event ) {
60
67
// Convert the canvas to image data that can be saved
155
162
}
156
163
157
164
function saveAsPng ( ) {
165
+ graphDiv = document . getElementById ( 'network' ) ;
166
+ visDiv = graphDiv . firstElementChild ;
167
+ graphCanvas = visDiv . firstElementChild ;
158
168
// Calculate the bounding box of all the elements on the canvas
159
169
const boundingBox = getBoundingBox ( ) ;
160
170
230
240
console . log ( 'Not implemented yet...' ) ;
231
241
}
232
242
243
+ function setNetworkLayout ( ) {
244
+ const hierarchicalOptionsDirection = document . getElementById ( 'hierarchicalOptions_direction' ) ;
245
+ const hierarchicalOptionsSortMethod = document . getElementById ( 'hierarchicalOptions_sortmethod' ) ;
246
+ const showHierarchicalOptionsCheckbox = document . getElementById ( 'showHierarchicalOptions' ) ;
247
+ hierarchicalOptionsDirection . style [ 'display' ] = showHierarchicalOptionsCheckbox . checked ? 'block' : 'none' ;
248
+ hierarchicalOptionsSortMethod . style [ 'display' ] = showHierarchicalOptionsCheckbox . checked ? 'block' : 'none' ;
249
+ const hierarchicalOptionsDirectionSelect = document . getElementById ( 'direction' ) ;
250
+ const hierarchicalOptionsSortMethodSelect = document . getElementById ( 'sortMethod' ) ;
251
+ if ( showHierarchicalOptionsCheckbox . checked ) {
252
+ options . layout = {
253
+ hierarchical : {
254
+ enabled : true ,
255
+ direction : hierarchicalOptionsDirectionSelect . value ? hierarchicalOptionsDirectionSelect . value : 'UD' ,
256
+ sortMethod : hierarchicalOptionsSortMethodSelect . value ? hierarchicalOptionsSortMethodSelect . value : 'hubsize'
257
+ }
258
+ } ;
259
+ } else {
260
+ options . layout = { } ;
261
+ }
262
+ options . layout . randomSeed = seed ;
263
+ network = new vis . Network ( container , data , options ) ;
264
+ }
265
+
233
266
} ( ) ) ;
0 commit comments