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.

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