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.

483 lines
14 KiB

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