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.

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