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.

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