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.

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