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.

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