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.

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