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.

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