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.

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