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.

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