UNPKG

19.1 kBJavaScriptView Raw
1/**
2 * This object contains all possible options. It will check if the types are correct, if required if the option is one
3 * of the allowed values.
4 *
5 * __any__ means that the name of the property does not matter.
6 * __type__ is a required field for all objects and contains the allowed types of all objects
7 */
8let string = 'string';
9let bool = 'boolean';
10let number = 'number';
11let array = 'array';
12let object = 'object'; // should only be in a __type__ property
13let dom = 'dom';
14let any = 'any';
15
16// List of endpoints
17let endPoints = ['arrow', 'circle', 'bar'];
18
19let allOptions = {
20 configure: {
21 enabled: { boolean: bool },
22 filter: { boolean: bool, string, array, 'function': 'function' },
23 container: { dom },
24 showButton: { boolean: bool },
25 __type__: { object, boolean: bool, string, array, 'function': 'function' }
26 },
27 edges: {
28 arrows: {
29 to: { enabled: { boolean: bool }, scaleFactor: { number }, type: { string: endPoints }, __type__: { object, boolean: bool } },
30 middle: { enabled: { boolean: bool }, scaleFactor: { number }, type: { string: endPoints }, __type__: { object, boolean: bool } },
31 from: { enabled: { boolean: bool }, scaleFactor: { number }, type: { string: endPoints }, __type__: { object, boolean: bool } },
32 __type__: { string: ['from', 'to', 'middle'], object }
33 },
34 arrowStrikethrough: { boolean: bool },
35 background: {
36 enabled: { boolean: bool },
37 color: { string },
38 size: { number },
39 dashes: { boolean: bool, array },
40 __type__: { object, boolean: bool }
41 },
42 chosen: {
43 label: { boolean: bool, 'function': 'function' },
44 edge: { boolean: bool, 'function': 'function' },
45 __type__: { object, boolean: bool }
46 },
47 color: {
48 color: { string },
49 highlight: { string },
50 hover: { string },
51 inherit: { string: ['from', 'to', 'both'], boolean: bool },
52 opacity: { number },
53 __type__: { object, string }
54 },
55 dashes: { boolean: bool, array },
56 font: {
57 color: { string },
58 size: { number }, // px
59 face: { string },
60 background: { string },
61 strokeWidth: { number }, // px
62 strokeColor: { string },
63 align: { string: ['horizontal', 'top', 'middle', 'bottom'] },
64 vadjust: { number },
65 multi: { boolean: bool, string },
66 bold: {
67 color: { string },
68 size: { number }, // px
69 face: { string },
70 mod: { string },
71 vadjust: { number },
72 __type__: { object, string }
73 },
74 boldital: {
75 color: { string },
76 size: { number }, // px
77 face: { string },
78 mod: { string },
79 vadjust: { number },
80 __type__: { object, string }
81 },
82 ital: {
83 color: { string },
84 size: { number }, // px
85 face: { string },
86 mod: { string },
87 vadjust: { number },
88 __type__: { object, string }
89 },
90 mono: {
91 color: { string },
92 size: { number }, // px
93 face: { string },
94 mod: { string },
95 vadjust: { number },
96 __type__: { object, string }
97 },
98 __type__: { object, string }
99 },
100 hidden: { boolean: bool },
101 hoverWidth: { 'function': 'function', number },
102 label: { string, 'undefined': 'undefined' },
103 labelHighlightBold: { boolean: bool },
104 length: { number, 'undefined': 'undefined' },
105 physics: { boolean: bool },
106 scaling: {
107 min: { number },
108 max: { number },
109 label: {
110 enabled: { boolean: bool },
111 min: { number },
112 max: { number },
113 maxVisible: { number },
114 drawThreshold: { number },
115 __type__: { object, boolean: bool }
116 },
117 customScalingFunction: { 'function': 'function' },
118 __type__: { object }
119 },
120 selectionWidth: { 'function': 'function', number },
121 selfReferenceSize: { number },
122 shadow: {
123 enabled: { boolean: bool },
124 color: { string },
125 size: { number },
126 x: { number },
127 y: { number },
128 __type__: { object, boolean: bool }
129 },
130 smooth: {
131 enabled: { boolean: bool },
132 type: { string: ['dynamic', 'continuous', 'discrete', 'diagonalCross', 'straightCross', 'horizontal', 'vertical', 'curvedCW', 'curvedCCW', 'cubicBezier'] },
133 roundness: { number },
134 forceDirection: { string: ['horizontal', 'vertical', 'none'], boolean: bool },
135 __type__: { object, boolean: bool }
136 },
137 title: { string, 'undefined': 'undefined' },
138 width: { number },
139 widthConstraint: {
140 maximum: { number },
141 __type__: { object, boolean: bool, number }
142 },
143 value: { number, 'undefined': 'undefined' },
144 __type__: { object }
145 },
146 groups: {
147 useDefaultGroups: { boolean: bool },
148 __any__: 'get from nodes, will be overwritten below',
149 __type__: { object }
150 },
151 interaction: {
152 dragNodes: { boolean: bool },
153 dragView: { boolean: bool },
154 hideEdgesOnDrag: { boolean: bool },
155 hideEdgesOnZoom: { boolean: bool },
156 hideNodesOnDrag: { boolean: bool },
157 hover: { boolean: bool },
158 keyboard: {
159 enabled: { boolean: bool },
160 speed: { x: { number }, y: { number }, zoom: { number }, __type__: { object } },
161 bindToWindow: { boolean: bool },
162 __type__: { object, boolean: bool }
163 },
164 multiselect: { boolean: bool },
165 navigationButtons: { boolean: bool },
166 selectable: { boolean: bool },
167 selectConnectedEdges: { boolean: bool },
168 hoverConnectedEdges: { boolean: bool },
169 tooltipDelay: { number },
170 zoomView: { boolean: bool },
171 zoomSpeed: { number },
172 __type__: { object }
173 },
174 layout: {
175 randomSeed: { 'undefined': 'undefined', number },
176 improvedLayout: { boolean: bool },
177 clusterThreshold: { number },
178 hierarchical: {
179 enabled: { boolean: bool },
180 levelSeparation: { number },
181 nodeSpacing: { number },
182 treeSpacing: { number },
183 blockShifting: { boolean: bool },
184 edgeMinimization: { boolean: bool },
185 parentCentralization: { boolean: bool },
186 direction: { string: ['UD', 'DU', 'LR', 'RL'] }, // UD, DU, LR, RL
187 sortMethod: { string: ['hubsize', 'directed'] }, // hubsize, directed
188 __type__: { object, boolean: bool }
189 },
190 __type__: { object }
191 },
192 manipulation: {
193 enabled: { boolean: bool },
194 initiallyActive: { boolean: bool },
195 addNode: { boolean: bool, 'function': 'function' },
196 addEdge: { boolean: bool, 'function': 'function' },
197 editNode: { 'function': 'function' },
198 editEdge: {
199 editWithoutDrag: { 'function' : 'function' },
200 __type__: {object, boolean: bool, 'function': 'function' }
201 },
202 deleteNode: { boolean: bool, 'function': 'function' },
203 deleteEdge: { boolean: bool, 'function': 'function' },
204 controlNodeStyle: 'get from nodes, will be overwritten below',
205 __type__: { object, boolean: bool }
206 },
207 nodes: {
208 borderWidth: { number },
209 borderWidthSelected: { number, 'undefined': 'undefined' },
210 brokenImage: { string, 'undefined': 'undefined' },
211 chosen: {
212 label: { boolean: bool, 'function': 'function' },
213 node: { boolean: bool, 'function': 'function' },
214 __type__: { object, boolean: bool }
215 },
216 color: {
217 border: { string },
218 background: { string },
219 highlight: {
220 border: { string },
221 background: { string },
222 __type__: { object, string }
223 },
224 hover: {
225 border: { string },
226 background: { string },
227 __type__: { object, string }
228 },
229 __type__: { object, string }
230 },
231 fixed: {
232 x: { boolean: bool },
233 y: { boolean: bool },
234 __type__: { object, boolean: bool }
235 },
236 font: {
237 align: { string },
238 color: { string },
239 size: { number }, // px
240 face: { string },
241 background: { string },
242 strokeWidth: { number }, // px
243 strokeColor: { string },
244 vadjust: { number },
245 multi: { boolean: bool, string },
246 bold: {
247 color: { string },
248 size: { number }, // px
249 face: { string },
250 mod: { string },
251 vadjust: { number },
252 __type__: { object, string }
253 },
254 boldital: {
255 color: { string },
256 size: { number }, // px
257 face: { string },
258 mod: { string },
259 vadjust: { number },
260 __type__: { object, string }
261 },
262 ital: {
263 color: { string },
264 size: { number }, // px
265 face: { string },
266 mod: { string },
267 vadjust: { number },
268 __type__: { object, string }
269 },
270 mono: {
271 color: { string },
272 size: { number }, // px
273 face: { string },
274 mod: { string },
275 vadjust: { number },
276 __type__: { object, string }
277 },
278 __type__: { object, string }
279 },
280 group: { string, number, 'undefined': 'undefined' },
281 heightConstraint: {
282 minimum: { number },
283 valign: { string },
284 __type__: { object, boolean: bool, number }
285 },
286 hidden: { boolean: bool },
287 icon: {
288 face: { string },
289 code: { string }, //'\uf007',
290 size: { number }, //50,
291 color: { string },
292 __type__: { object }
293 },
294 id: { string, number },
295 image: {
296 selected: { string, 'undefined': 'undefined' }, // --> URL
297 unselected: { string, 'undefined': 'undefined' }, // --> URL
298 __type__: { object, string }
299 },
300 imagePadding: {
301 top: { number },
302 right: { number },
303 bottom: { number },
304 left: { number },
305 __type__: { object, number }
306 },
307 label: { string, 'undefined': 'undefined' },
308 labelHighlightBold: { boolean: bool },
309 level: { number, 'undefined': 'undefined' },
310 margin: {
311 top: { number },
312 right: { number },
313 bottom: { number },
314 left: { number },
315 __type__: { object, number }
316 },
317 mass: { number },
318 physics: { boolean: bool },
319 scaling: {
320 min: { number },
321 max: { number },
322 label: {
323 enabled: { boolean: bool },
324 min: { number },
325 max: { number },
326 maxVisible: { number },
327 drawThreshold: { number },
328 __type__: { object, boolean: bool }
329 },
330 customScalingFunction: { 'function': 'function' },
331 __type__: { object }
332 },
333 shadow: {
334 enabled: { boolean: bool },
335 color: { string },
336 size: { number },
337 x: { number },
338 y: { number },
339 __type__: { object, boolean: bool }
340 },
341 shape: { string: ['ellipse', 'circle', 'database', 'box', 'text', 'image', 'circularImage', 'diamond', 'dot', 'star', 'triangle', 'triangleDown', 'square', 'icon', 'hexagon'] },
342 shapeProperties: {
343 borderDashes: { boolean: bool, array },
344 borderRadius: { number },
345 interpolation: { boolean: bool },
346 useImageSize: { boolean: bool },
347 useBorderWithImage: { boolean: bool },
348 __type__: { object }
349 },
350 size: { number },
351 title: { string, dom, 'undefined': 'undefined' },
352 value: { number, 'undefined': 'undefined' },
353 widthConstraint: {
354 minimum: { number },
355 maximum: { number },
356 __type__: { object, boolean: bool, number }
357 },
358 x: { number },
359 y: { number },
360 __type__: { object }
361 },
362 physics: {
363 enabled: { boolean: bool },
364 barnesHut: {
365 gravitationalConstant: { number },
366 centralGravity: { number },
367 springLength: { number },
368 springConstant: { number },
369 damping: { number },
370 avoidOverlap: { number },
371 __type__: { object }
372 },
373 forceAtlas2Based: {
374 gravitationalConstant: { number },
375 centralGravity: { number },
376 springLength: { number },
377 springConstant: { number },
378 damping: { number },
379 avoidOverlap: { number },
380 __type__: { object }
381 },
382 repulsion: {
383 centralGravity: { number },
384 springLength: { number },
385 springConstant: { number },
386 nodeDistance: { number },
387 damping: { number },
388 __type__: { object }
389 },
390 hierarchicalRepulsion: {
391 centralGravity: { number },
392 springLength: { number },
393 springConstant: { number },
394 nodeDistance: { number },
395 damping: { number },
396 __type__: { object }
397 },
398 maxVelocity: { number },
399 minVelocity: { number }, // px/s
400 solver: { string: ['barnesHut', 'repulsion', 'hierarchicalRepulsion', 'forceAtlas2Based'] },
401 stabilization: {
402 enabled: { boolean: bool },
403 iterations: { number }, // maximum number of iteration to stabilize
404 updateInterval: { number },
405 onlyDynamicEdges: { boolean: bool },
406 fit: { boolean: bool },
407 __type__: { object, boolean: bool }
408 },
409 timestep: { number },
410 adaptiveTimestep: { boolean: bool },
411 __type__: { object, boolean: bool }
412 },
413
414 //globals :
415 autoResize: { boolean: bool },
416 clickToUse: { boolean: bool },
417 locale: { string },
418 locales: {
419 __any__: { any },
420 __type__: { object }
421 },
422 height: { string },
423 width: { string },
424 __type__: { object }
425};
426
427allOptions.groups.__any__ = allOptions.nodes;
428allOptions.manipulation.controlNodeStyle = allOptions.nodes;
429
430
431let configureOptions = {
432 nodes: {
433 borderWidth: [1, 0, 10, 1],
434 borderWidthSelected: [2, 0, 10, 1],
435 color: {
436 border: ['color', '#2B7CE9'],
437 background: ['color', '#97C2FC'],
438 highlight: {
439 border: ['color', '#2B7CE9'],
440 background: ['color', '#D2E5FF']
441 },
442 hover: {
443 border: ['color', '#2B7CE9'],
444 background: ['color', '#D2E5FF']
445 }
446 },
447 fixed: {
448 x: false,
449 y: false
450 },
451 font: {
452 color: ['color', '#343434'],
453 size: [14, 0, 100, 1], // px
454 face: ['arial', 'verdana', 'tahoma'],
455 background: ['color', 'none'],
456 strokeWidth: [0, 0, 50, 1], // px
457 strokeColor: ['color', '#ffffff']
458 },
459 //group: 'string',
460 hidden: false,
461 labelHighlightBold: true,
462 //icon: {
463 // face: 'string', //'FontAwesome',
464 // code: 'string', //'\uf007',
465 // size: [50, 0, 200, 1], //50,
466 // color: ['color','#2B7CE9'] //'#aa00ff'
467 //},
468 //image: 'string', // --> URL
469 physics: true,
470 scaling: {
471 min: [10, 0, 200, 1],
472 max: [30, 0, 200, 1],
473 label: {
474 enabled: false,
475 min: [14, 0, 200, 1],
476 max: [30, 0, 200, 1],
477 maxVisible: [30, 0, 200, 1],
478 drawThreshold: [5, 0, 20, 1]
479 }
480 },
481 shadow: {
482 enabled: false,
483 color: 'rgba(0,0,0,0.5)',
484 size: [10, 0, 20, 1],
485 x: [5, -30, 30, 1],
486 y: [5, -30, 30, 1]
487 },
488 shape: ['ellipse', 'box', 'circle', 'database', 'diamond', 'dot', 'square', 'star', 'text', 'triangle', 'triangleDown','hexagon'],
489 shapeProperties: {
490 borderDashes: false,
491 borderRadius: [6, 0, 20, 1],
492 interpolation: true,
493 useImageSize: false
494 },
495 size: [25, 0, 200, 1]
496 },
497 edges: {
498 arrows: {
499 to: { enabled: false, scaleFactor: [1, 0, 3, 0.05], type: 'arrow' },
500 middle: { enabled: false, scaleFactor: [1, 0, 3, 0.05], type: 'arrow' },
501 from: { enabled: false, scaleFactor: [1, 0, 3, 0.05], type: 'arrow' }
502 },
503 arrowStrikethrough: true,
504 color: {
505 color: ['color', '#848484'],
506 highlight: ['color', '#848484'],
507 hover: ['color', '#848484'],
508 inherit: ['from', 'to', 'both', true, false],
509 opacity: [1, 0, 1, 0.05]
510 },
511 dashes: false,
512 font: {
513 color: ['color', '#343434'],
514 size: [14, 0, 100, 1], // px
515 face: ['arial', 'verdana', 'tahoma'],
516 background: ['color', 'none'],
517 strokeWidth: [2, 0, 50, 1], // px
518 strokeColor: ['color', '#ffffff'],
519 align: ['horizontal', 'top', 'middle', 'bottom']
520 },
521 hidden: false,
522 hoverWidth: [1.5, 0, 5, 0.1],
523 labelHighlightBold: true,
524 physics: true,
525 scaling: {
526 min: [1, 0, 100, 1],
527 max: [15, 0, 100, 1],
528 label: {
529 enabled: true,
530 min: [14, 0, 200, 1],
531 max: [30, 0, 200, 1],
532 maxVisible: [30, 0, 200, 1],
533 drawThreshold: [5, 0, 20, 1]
534 }
535 },
536 selectionWidth: [1.5, 0, 5, 0.1],
537 selfReferenceSize: [20, 0, 200, 1],
538 shadow: {
539 enabled: false,
540 color: 'rgba(0,0,0,0.5)',
541 size: [10, 0, 20, 1],
542 x: [5, -30, 30, 1],
543 y: [5, -30, 30, 1]
544 },
545 smooth: {
546 enabled: true,
547 type: ['dynamic', 'continuous', 'discrete', 'diagonalCross', 'straightCross', 'horizontal', 'vertical', 'curvedCW', 'curvedCCW', 'cubicBezier'],
548 forceDirection: ['horizontal', 'vertical', 'none'],
549 roundness: [0.5, 0, 1, 0.05]
550 },
551 width: [1, 0, 30, 1]
552 },
553 layout: {
554 //randomSeed: [0, 0, 500, 1],
555 //improvedLayout: true,
556 hierarchical: {
557 enabled: false,
558 levelSeparation: [150, 20, 500, 5],
559 nodeSpacing: [100, 20, 500, 5],
560 treeSpacing: [200, 20, 500, 5],
561 blockShifting: true,
562 edgeMinimization: true,
563 parentCentralization: true,
564 direction: ['UD', 'DU', 'LR', 'RL'], // UD, DU, LR, RL
565 sortMethod: ['hubsize', 'directed'] // hubsize, directed
566 }
567 },
568 interaction: {
569 dragNodes: true,
570 dragView: true,
571 hideEdgesOnDrag: false,
572 hideEdgesOnZoom: false,
573 hideNodesOnDrag: false,
574 hover: false,
575 keyboard: {
576 enabled: false,
577 speed: { x: [10, 0, 40, 1], y: [10, 0, 40, 1], zoom: [0.02, 0, 0.1, 0.005] },
578 bindToWindow: true
579 },
580 multiselect: false,
581 navigationButtons: false,
582 selectable: true,
583 selectConnectedEdges: true,
584 hoverConnectedEdges: true,
585 tooltipDelay: [300, 0, 1000, 25],
586 zoomView: true,
587 zoomSpeed: [1, 1, 1, 1]
588 },
589 manipulation: {
590 enabled: false,
591 initiallyActive: false
592 },
593 physics: {
594 enabled: true,
595 barnesHut: {
596 //theta: [0.5, 0.1, 1, 0.05],
597 gravitationalConstant: [-2000, -30000, 0, 50],
598 centralGravity: [0.3, 0, 10, 0.05],
599 springLength: [95, 0, 500, 5],
600 springConstant: [0.04, 0, 1.2, 0.005],
601 damping: [0.09, 0, 1, 0.01],
602 avoidOverlap: [0, 0, 1, 0.01]
603 },
604 forceAtlas2Based: {
605 //theta: [0.5, 0.1, 1, 0.05],
606 gravitationalConstant: [-50, -500, 0, 1],
607 centralGravity: [0.01, 0, 1, 0.005],
608 springLength: [95, 0, 500, 5],
609 springConstant: [0.08, 0, 1.2, 0.005],
610 damping: [0.4, 0, 1, 0.01],
611 avoidOverlap: [0, 0, 1, 0.01]
612 },
613 repulsion: {
614 centralGravity: [0.2, 0, 10, 0.05],
615 springLength: [200, 0, 500, 5],
616 springConstant: [0.05, 0, 1.2, 0.005],
617 nodeDistance: [100, 0, 500, 5],
618 damping: [0.09, 0, 1, 0.01]
619 },
620 hierarchicalRepulsion: {
621 centralGravity: [0.2, 0, 10, 0.05],
622 springLength: [100, 0, 500, 5],
623 springConstant: [0.01, 0, 1.2, 0.005],
624 nodeDistance: [120, 0, 500, 5],
625 damping: [0.09, 0, 1, 0.01]
626 },
627 maxVelocity: [50, 0, 150, 1],
628 minVelocity: [0.1, 0.01, 0.5, 0.01],
629 solver: ['barnesHut', 'forceAtlas2Based', 'repulsion', 'hierarchicalRepulsion'],
630 timestep: [0.5, 0.01, 1, 0.01],
631 //adaptiveTimestep: true
632 }
633};
634
635export {allOptions, configureOptions};