vis.js is a dynamic, browser-based visualization library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

616 lines
18 KiB

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