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.

512 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__: { object, boolean } },
  26. middle: { enabled: { boolean }, scaleFactor: { number }, __type__: { object, boolean } },
  27. from: { enabled: { boolean }, scaleFactor: { number }, __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. color: { string },
  173. size: { number }, // px
  174. face: { string },
  175. background: { string },
  176. strokeWidth: { number }, // px
  177. strokeColor: { string },
  178. __type__: { object, string }
  179. },
  180. group: { string, number, 'undefined': 'undefined' },
  181. hidden: { boolean },
  182. icon: {
  183. face: { string },
  184. code: { string }, //'\uf007',
  185. size: { number }, //50,
  186. color: { string },
  187. __type__: { object }
  188. },
  189. id: { string, number },
  190. image: { string, 'undefined': 'undefined' }, // --> URL
  191. label: { string, 'undefined': 'undefined' },
  192. labelHighlightBold: { boolean },
  193. level: { number, 'undefined': 'undefined' },
  194. mass: { number },
  195. physics: { boolean },
  196. scaling: {
  197. min: { number },
  198. max: { number },
  199. label: {
  200. enabled: { boolean },
  201. min: { number },
  202. max: { number },
  203. maxVisible: { number },
  204. drawThreshold: { number },
  205. __type__: { object, boolean }
  206. },
  207. customScalingFunction: { 'function': 'function' },
  208. __type__: { object }
  209. },
  210. shadow: {
  211. enabled: { boolean },
  212. color: { string },
  213. size: { number },
  214. x: { number },
  215. y: { number },
  216. __type__: { object, boolean }
  217. },
  218. shape: { string: ['ellipse', 'circle', 'database', 'box', 'text', 'image', 'circularImage', 'diamond', 'dot', 'star', 'triangle', 'triangleDown', 'square', 'icon'] },
  219. shapeProperties: {
  220. borderDashes: { boolean, array },
  221. borderRadius: { number },
  222. interpolation: { boolean },
  223. useImageSize: { boolean },
  224. useBorderWithImage: { boolean },
  225. __type__: { object }
  226. },
  227. size: { number },
  228. title: { string, 'undefined': 'undefined' },
  229. value: { number, 'undefined': 'undefined' },
  230. x: { number },
  231. y: { number },
  232. __type__: { object }
  233. },
  234. physics: {
  235. enabled: { boolean },
  236. barnesHut: {
  237. gravitationalConstant: { number },
  238. centralGravity: { number },
  239. springLength: { number },
  240. springConstant: { number },
  241. damping: { number },
  242. avoidOverlap: { number },
  243. __type__: { object }
  244. },
  245. forceAtlas2Based: {
  246. gravitationalConstant: { number },
  247. centralGravity: { number },
  248. springLength: { number },
  249. springConstant: { number },
  250. damping: { number },
  251. avoidOverlap: { number },
  252. __type__: { object }
  253. },
  254. repulsion: {
  255. centralGravity: { number },
  256. springLength: { number },
  257. springConstant: { number },
  258. nodeDistance: { number },
  259. damping: { number },
  260. __type__: { object }
  261. },
  262. hierarchicalRepulsion: {
  263. centralGravity: { number },
  264. springLength: { number },
  265. springConstant: { number },
  266. nodeDistance: { number },
  267. damping: { number },
  268. __type__: { object }
  269. },
  270. maxVelocity: { number },
  271. minVelocity: { number }, // px/s
  272. solver: { string: ['barnesHut', 'repulsion', 'hierarchicalRepulsion', 'forceAtlas2Based'] },
  273. stabilization: {
  274. enabled: { boolean },
  275. iterations: { number }, // maximum number of iteration to stabilize
  276. updateInterval: { number },
  277. onlyDynamicEdges: { boolean },
  278. fit: { boolean },
  279. __type__: { object, boolean }
  280. },
  281. timestep: { number },
  282. adaptiveTimestep: { boolean },
  283. __type__: { object, boolean }
  284. },
  285. //globals :
  286. autoResize: { boolean },
  287. clickToUse: { boolean },
  288. locale: { string },
  289. locales: {
  290. __any__: { any },
  291. __type__: { object }
  292. },
  293. height: { string },
  294. width: { string },
  295. __type__: { object }
  296. };
  297. allOptions.groups.__any__ = allOptions.nodes;
  298. allOptions.manipulation.controlNodeStyle = allOptions.nodes;
  299. let configureOptions = {
  300. nodes: {
  301. borderWidth: [1, 0, 10, 1],
  302. borderWidthSelected: [2, 0, 10, 1],
  303. color: {
  304. border: ['color', '#2B7CE9'],
  305. background: ['color', '#97C2FC'],
  306. highlight: {
  307. border: ['color', '#2B7CE9'],
  308. background: ['color', '#D2E5FF']
  309. },
  310. hover: {
  311. border: ['color', '#2B7CE9'],
  312. background: ['color', '#D2E5FF']
  313. }
  314. },
  315. fixed: {
  316. x: false,
  317. y: false
  318. },
  319. font: {
  320. color: ['color', '#343434'],
  321. size: [14, 0, 100, 1], // px
  322. face: ['arial', 'verdana', 'tahoma'],
  323. background: ['color', 'none'],
  324. strokeWidth: [0, 0, 50, 1], // px
  325. strokeColor: ['color', '#ffffff']
  326. },
  327. //group: 'string',
  328. hidden: false,
  329. labelHighlightBold: true,
  330. //icon: {
  331. // face: 'string', //'FontAwesome',
  332. // code: 'string', //'\uf007',
  333. // size: [50, 0, 200, 1], //50,
  334. // color: ['color','#2B7CE9'] //'#aa00ff'
  335. //},
  336. //image: 'string', // --> URL
  337. physics: true,
  338. scaling: {
  339. min: [10, 0, 200, 1],
  340. max: [30, 0, 200, 1],
  341. label: {
  342. enabled: false,
  343. min: [14, 0, 200, 1],
  344. max: [30, 0, 200, 1],
  345. maxVisible: [30, 0, 200, 1],
  346. drawThreshold: [5, 0, 20, 1]
  347. }
  348. },
  349. shadow: {
  350. enabled: false,
  351. color: 'rgba(0,0,0,0.5)',
  352. size: [10, 0, 20, 1],
  353. x: [5, -30, 30, 1],
  354. y: [5, -30, 30, 1]
  355. },
  356. shape: ['ellipse', 'box', 'circle', 'database', 'diamond', 'dot', 'square', 'star', 'text', 'triangle', 'triangleDown'],
  357. shapeProperties: {
  358. borderDashes: false,
  359. borderRadius: [6, 0, 20, 1],
  360. interpolation: true,
  361. useImageSize: false
  362. },
  363. size: [25, 0, 200, 1]
  364. },
  365. edges: {
  366. arrows: {
  367. to: { enabled: false, scaleFactor: [1, 0, 3, 0.05] }, // boolean / {arrowScaleFactor:1} / {enabled: false, arrowScaleFactor:1}
  368. middle: { enabled: false, scaleFactor: [1, 0, 3, 0.05] },
  369. from: { enabled: false, scaleFactor: [1, 0, 3, 0.05] }
  370. },
  371. arrowStrikethrough: true,
  372. color: {
  373. color: ['color', '#848484'],
  374. highlight: ['color', '#848484'],
  375. hover: ['color', '#848484'],
  376. inherit: ['from', 'to', 'both', true, false],
  377. opacity: [1, 0, 1, 0.05]
  378. },
  379. dashes: false,
  380. font: {
  381. color: ['color', '#343434'],
  382. size: [14, 0, 100, 1], // px
  383. face: ['arial', 'verdana', 'tahoma'],
  384. background: ['color', 'none'],
  385. strokeWidth: [2, 0, 50, 1], // px
  386. strokeColor: ['color', '#ffffff'],
  387. align: ['horizontal', 'top', 'middle', 'bottom']
  388. },
  389. hidden: false,
  390. hoverWidth: [1.5, 0, 5, 0.1],
  391. labelHighlightBold: true,
  392. physics: true,
  393. scaling: {
  394. min: [1, 0, 100, 1],
  395. max: [15, 0, 100, 1],
  396. label: {
  397. enabled: true,
  398. min: [14, 0, 200, 1],
  399. max: [30, 0, 200, 1],
  400. maxVisible: [30, 0, 200, 1],
  401. drawThreshold: [5, 0, 20, 1]
  402. }
  403. },
  404. selectionWidth: [1.5, 0, 5, 0.1],
  405. selfReferenceSize: [20, 0, 200, 1],
  406. shadow: {
  407. enabled: false,
  408. color: 'rgba(0,0,0,0.5)',
  409. size: [10, 0, 20, 1],
  410. x: [5, -30, 30, 1],
  411. y: [5, -30, 30, 1]
  412. },
  413. smooth: {
  414. enabled: true,
  415. type: ['dynamic', 'continuous', 'discrete', 'diagonalCross', 'straightCross', 'horizontal', 'vertical', 'curvedCW', 'curvedCCW', 'cubicBezier'],
  416. forceDirection: ['horizontal', 'vertical', 'none'],
  417. roundness: [0.5, 0, 1, 0.05]
  418. },
  419. width: [1, 0, 30, 1]
  420. },
  421. layout: {
  422. //randomSeed: [0, 0, 500, 1],
  423. //improvedLayout: true,
  424. hierarchical: {
  425. enabled: false,
  426. levelSeparation: [150, 20, 500, 5],
  427. nodeSpacing: [100, 20, 500, 5],
  428. treeSpacing: [200, 20, 500, 5],
  429. blockShifting: true,
  430. edgeMinimization: true,
  431. parentCentralization: true,
  432. direction: ['UD', 'DU', 'LR', 'RL'], // UD, DU, LR, RL
  433. sortMethod: ['hubsize', 'directed'] // hubsize, directed
  434. }
  435. },
  436. interaction: {
  437. dragNodes: true,
  438. dragView: true,
  439. hideEdgesOnDrag: false,
  440. hideNodesOnDrag: false,
  441. hover: false,
  442. keyboard: {
  443. enabled: false,
  444. speed: { x: [10, 0, 40, 1], y: [10, 0, 40, 1], zoom: [0.02, 0, 0.1, 0.005] },
  445. bindToWindow: true
  446. },
  447. multiselect: false,
  448. navigationButtons: false,
  449. selectable: true,
  450. selectConnectedEdges: true,
  451. hoverConnectedEdges: true,
  452. tooltipDelay: [300, 0, 1000, 25],
  453. zoomView: true
  454. },
  455. manipulation: {
  456. enabled: false,
  457. initiallyActive: false
  458. },
  459. physics: {
  460. enabled: true,
  461. barnesHut: {
  462. //theta: [0.5, 0.1, 1, 0.05],
  463. gravitationalConstant: [-2000, -30000, 0, 50],
  464. centralGravity: [0.3, 0, 10, 0.05],
  465. springLength: [95, 0, 500, 5],
  466. springConstant: [0.04, 0, 1.2, 0.005],
  467. damping: [0.09, 0, 1, 0.01],
  468. avoidOverlap: [0, 0, 1, 0.01]
  469. },
  470. forceAtlas2Based: {
  471. //theta: [0.5, 0.1, 1, 0.05],
  472. gravitationalConstant: [-50, -500, 0, 1],
  473. centralGravity: [0.01, 0, 1, 0.005],
  474. springLength: [95, 0, 500, 5],
  475. springConstant: [0.08, 0, 1.2, 0.005],
  476. damping: [0.4, 0, 1, 0.01],
  477. avoidOverlap: [0, 0, 1, 0.01]
  478. },
  479. repulsion: {
  480. centralGravity: [0.2, 0, 10, 0.05],
  481. springLength: [200, 0, 500, 5],
  482. springConstant: [0.05, 0, 1.2, 0.005],
  483. nodeDistance: [100, 0, 500, 5],
  484. damping: [0.09, 0, 1, 0.01]
  485. },
  486. hierarchicalRepulsion: {
  487. centralGravity: [0.2, 0, 10, 0.05],
  488. springLength: [100, 0, 500, 5],
  489. springConstant: [0.01, 0, 1.2, 0.005],
  490. nodeDistance: [120, 0, 500, 5],
  491. damping: [0.09, 0, 1, 0.01]
  492. },
  493. maxVelocity: [50, 0, 150, 1],
  494. minVelocity: [0.1, 0.01, 0.5, 0.01],
  495. solver: ['barnesHut', 'forceAtlas2Based', 'repulsion', 'hierarchicalRepulsion'],
  496. timestep: [0.5, 0.01, 1, 0.01],
  497. //adaptiveTimestep: true
  498. },
  499. global: {
  500. locale: ['en', 'nl']
  501. }
  502. };
  503. export {allOptions, configureOptions};