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.

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