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.

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