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.

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