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.

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