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.

614 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: {
  282. selected: { string, 'undefined': 'undefined' }, // --> URL
  283. unselected: { string, 'undefined': 'undefined' }, // --> URL
  284. __type__: { object, string }
  285. },
  286. label: { string, 'undefined': 'undefined' },
  287. labelHighlightBold: { boolean: bool },
  288. level: { number, 'undefined': 'undefined' },
  289. margin: {
  290. top: { number },
  291. right: { number },
  292. bottom: { number },
  293. left: { number },
  294. __type__: { object, number }
  295. },
  296. mass: { number },
  297. physics: { boolean: bool },
  298. scaling: {
  299. min: { number },
  300. max: { number },
  301. label: {
  302. enabled: { boolean: bool },
  303. min: { number },
  304. max: { number },
  305. maxVisible: { number },
  306. drawThreshold: { number },
  307. __type__: { object, boolean: bool }
  308. },
  309. customScalingFunction: { 'function': 'function' },
  310. __type__: { object }
  311. },
  312. shadow: {
  313. enabled: { boolean: bool },
  314. color: { string },
  315. size: { number },
  316. x: { number },
  317. y: { number },
  318. __type__: { object, boolean: bool }
  319. },
  320. shape: { string: ['ellipse', 'circle', 'database', 'box', 'text', 'image', 'circularImage', 'diamond', 'dot', 'star', 'triangle', 'triangleDown', 'square', 'icon'] },
  321. shapeProperties: {
  322. borderDashes: { boolean: bool, array },
  323. borderRadius: { number },
  324. interpolation: { boolean: bool },
  325. useImageSize: { boolean: bool },
  326. useBorderWithImage: { boolean: bool },
  327. __type__: { object }
  328. },
  329. size: { number },
  330. title: { string, dom, 'undefined': 'undefined' },
  331. value: { number, 'undefined': 'undefined' },
  332. widthConstraint: {
  333. minimum: { number },
  334. maximum: { number },
  335. __type__: { object, boolean: bool, number }
  336. },
  337. x: { number },
  338. y: { number },
  339. __type__: { object }
  340. },
  341. physics: {
  342. enabled: { boolean: bool },
  343. barnesHut: {
  344. gravitationalConstant: { number },
  345. centralGravity: { number },
  346. springLength: { number },
  347. springConstant: { number },
  348. damping: { number },
  349. avoidOverlap: { number },
  350. __type__: { object }
  351. },
  352. forceAtlas2Based: {
  353. gravitationalConstant: { number },
  354. centralGravity: { number },
  355. springLength: { number },
  356. springConstant: { number },
  357. damping: { number },
  358. avoidOverlap: { number },
  359. __type__: { object }
  360. },
  361. repulsion: {
  362. centralGravity: { number },
  363. springLength: { number },
  364. springConstant: { number },
  365. nodeDistance: { number },
  366. damping: { number },
  367. __type__: { object }
  368. },
  369. hierarchicalRepulsion: {
  370. centralGravity: { number },
  371. springLength: { number },
  372. springConstant: { number },
  373. nodeDistance: { number },
  374. damping: { number },
  375. __type__: { object }
  376. },
  377. maxVelocity: { number },
  378. minVelocity: { number }, // px/s
  379. solver: { string: ['barnesHut', 'repulsion', 'hierarchicalRepulsion', 'forceAtlas2Based'] },
  380. stabilization: {
  381. enabled: { boolean: bool },
  382. iterations: { number }, // maximum number of iteration to stabilize
  383. updateInterval: { number },
  384. onlyDynamicEdges: { boolean: bool },
  385. fit: { boolean: bool },
  386. __type__: { object, boolean: bool }
  387. },
  388. timestep: { number },
  389. adaptiveTimestep: { boolean: bool },
  390. __type__: { object, boolean: bool }
  391. },
  392. //globals :
  393. autoResize: { boolean: bool },
  394. clickToUse: { boolean: bool },
  395. locale: { string },
  396. locales: {
  397. __any__: { any },
  398. __type__: { object }
  399. },
  400. height: { string },
  401. width: { string },
  402. __type__: { object }
  403. };
  404. allOptions.groups.__any__ = allOptions.nodes;
  405. allOptions.manipulation.controlNodeStyle = allOptions.nodes;
  406. let configureOptions = {
  407. nodes: {
  408. borderWidth: [1, 0, 10, 1],
  409. borderWidthSelected: [2, 0, 10, 1],
  410. color: {
  411. border: ['color', '#2B7CE9'],
  412. background: ['color', '#97C2FC'],
  413. highlight: {
  414. border: ['color', '#2B7CE9'],
  415. background: ['color', '#D2E5FF']
  416. },
  417. hover: {
  418. border: ['color', '#2B7CE9'],
  419. background: ['color', '#D2E5FF']
  420. }
  421. },
  422. fixed: {
  423. x: false,
  424. y: false
  425. },
  426. font: {
  427. color: ['color', '#343434'],
  428. size: [14, 0, 100, 1], // px
  429. face: ['arial', 'verdana', 'tahoma'],
  430. background: ['color', 'none'],
  431. strokeWidth: [0, 0, 50, 1], // px
  432. strokeColor: ['color', '#ffffff']
  433. },
  434. //group: 'string',
  435. hidden: false,
  436. labelHighlightBold: true,
  437. //icon: {
  438. // face: 'string', //'FontAwesome',
  439. // code: 'string', //'\uf007',
  440. // size: [50, 0, 200, 1], //50,
  441. // color: ['color','#2B7CE9'] //'#aa00ff'
  442. //},
  443. //image: 'string', // --> URL
  444. physics: true,
  445. scaling: {
  446. min: [10, 0, 200, 1],
  447. max: [30, 0, 200, 1],
  448. label: {
  449. enabled: false,
  450. min: [14, 0, 200, 1],
  451. max: [30, 0, 200, 1],
  452. maxVisible: [30, 0, 200, 1],
  453. drawThreshold: [5, 0, 20, 1]
  454. }
  455. },
  456. shadow: {
  457. enabled: false,
  458. color: 'rgba(0,0,0,0.5)',
  459. size: [10, 0, 20, 1],
  460. x: [5, -30, 30, 1],
  461. y: [5, -30, 30, 1]
  462. },
  463. shape: ['ellipse', 'box', 'circle', 'database', 'diamond', 'dot', 'square', 'star', 'text', 'triangle', 'triangleDown'],
  464. shapeProperties: {
  465. borderDashes: false,
  466. borderRadius: [6, 0, 20, 1],
  467. interpolation: true,
  468. useImageSize: false
  469. },
  470. size: [25, 0, 200, 1]
  471. },
  472. edges: {
  473. arrows: {
  474. to: { enabled: false, scaleFactor: [1, 0, 3, 0.05], type: 'arrow' },
  475. middle: { enabled: false, scaleFactor: [1, 0, 3, 0.05], type: 'arrow' },
  476. from: { enabled: false, scaleFactor: [1, 0, 3, 0.05], type: 'arrow' }
  477. },
  478. arrowStrikethrough: true,
  479. color: {
  480. color: ['color', '#848484'],
  481. highlight: ['color', '#848484'],
  482. hover: ['color', '#848484'],
  483. inherit: ['from', 'to', 'both', true, false],
  484. opacity: [1, 0, 1, 0.05]
  485. },
  486. dashes: false,
  487. font: {
  488. color: ['color', '#343434'],
  489. size: [14, 0, 100, 1], // px
  490. face: ['arial', 'verdana', 'tahoma'],
  491. background: ['color', 'none'],
  492. strokeWidth: [2, 0, 50, 1], // px
  493. strokeColor: ['color', '#ffffff'],
  494. align: ['horizontal', 'top', 'middle', 'bottom']
  495. },
  496. hidden: false,
  497. hoverWidth: [1.5, 0, 5, 0.1],
  498. labelHighlightBold: true,
  499. physics: true,
  500. scaling: {
  501. min: [1, 0, 100, 1],
  502. max: [15, 0, 100, 1],
  503. label: {
  504. enabled: true,
  505. min: [14, 0, 200, 1],
  506. max: [30, 0, 200, 1],
  507. maxVisible: [30, 0, 200, 1],
  508. drawThreshold: [5, 0, 20, 1]
  509. }
  510. },
  511. selectionWidth: [1.5, 0, 5, 0.1],
  512. selfReferenceSize: [20, 0, 200, 1],
  513. shadow: {
  514. enabled: false,
  515. color: 'rgba(0,0,0,0.5)',
  516. size: [10, 0, 20, 1],
  517. x: [5, -30, 30, 1],
  518. y: [5, -30, 30, 1]
  519. },
  520. smooth: {
  521. enabled: true,
  522. type: ['dynamic', 'continuous', 'discrete', 'diagonalCross', 'straightCross', 'horizontal', 'vertical', 'curvedCW', 'curvedCCW', 'cubicBezier'],
  523. forceDirection: ['horizontal', 'vertical', 'none'],
  524. roundness: [0.5, 0, 1, 0.05]
  525. },
  526. width: [1, 0, 30, 1]
  527. },
  528. layout: {
  529. //randomSeed: [0, 0, 500, 1],
  530. //improvedLayout: true,
  531. hierarchical: {
  532. enabled: false,
  533. levelSeparation: [150, 20, 500, 5],
  534. nodeSpacing: [100, 20, 500, 5],
  535. treeSpacing: [200, 20, 500, 5],
  536. blockShifting: true,
  537. edgeMinimization: true,
  538. parentCentralization: true,
  539. direction: ['UD', 'DU', 'LR', 'RL'], // UD, DU, LR, RL
  540. sortMethod: ['hubsize', 'directed'] // hubsize, directed
  541. }
  542. },
  543. interaction: {
  544. dragNodes: true,
  545. dragView: true,
  546. hideEdgesOnDrag: false,
  547. hideNodesOnDrag: false,
  548. hover: false,
  549. keyboard: {
  550. enabled: false,
  551. speed: { x: [10, 0, 40, 1], y: [10, 0, 40, 1], zoom: [0.02, 0, 0.1, 0.005] },
  552. bindToWindow: true
  553. },
  554. multiselect: false,
  555. navigationButtons: false,
  556. selectable: true,
  557. selectConnectedEdges: true,
  558. hoverConnectedEdges: true,
  559. tooltipDelay: [300, 0, 1000, 25],
  560. zoomView: true
  561. },
  562. manipulation: {
  563. enabled: false,
  564. initiallyActive: false
  565. },
  566. physics: {
  567. enabled: true,
  568. barnesHut: {
  569. //theta: [0.5, 0.1, 1, 0.05],
  570. gravitationalConstant: [-2000, -30000, 0, 50],
  571. centralGravity: [0.3, 0, 10, 0.05],
  572. springLength: [95, 0, 500, 5],
  573. springConstant: [0.04, 0, 1.2, 0.005],
  574. damping: [0.09, 0, 1, 0.01],
  575. avoidOverlap: [0, 0, 1, 0.01]
  576. },
  577. forceAtlas2Based: {
  578. //theta: [0.5, 0.1, 1, 0.05],
  579. gravitationalConstant: [-50, -500, 0, 1],
  580. centralGravity: [0.01, 0, 1, 0.005],
  581. springLength: [95, 0, 500, 5],
  582. springConstant: [0.08, 0, 1.2, 0.005],
  583. damping: [0.4, 0, 1, 0.01],
  584. avoidOverlap: [0, 0, 1, 0.01]
  585. },
  586. repulsion: {
  587. centralGravity: [0.2, 0, 10, 0.05],
  588. springLength: [200, 0, 500, 5],
  589. springConstant: [0.05, 0, 1.2, 0.005],
  590. nodeDistance: [100, 0, 500, 5],
  591. damping: [0.09, 0, 1, 0.01]
  592. },
  593. hierarchicalRepulsion: {
  594. centralGravity: [0.2, 0, 10, 0.05],
  595. springLength: [100, 0, 500, 5],
  596. springConstant: [0.01, 0, 1.2, 0.005],
  597. nodeDistance: [120, 0, 500, 5],
  598. damping: [0.09, 0, 1, 0.01]
  599. },
  600. maxVelocity: [50, 0, 150, 1],
  601. minVelocity: [0.1, 0.01, 0.5, 0.01],
  602. solver: ['barnesHut', 'forceAtlas2Based', 'repulsion', 'hierarchicalRepulsion'],
  603. timestep: [0.5, 0.01, 1, 0.01],
  604. //adaptiveTimestep: true
  605. }
  606. };
  607. export {allOptions, configureOptions};