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.

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