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.

476 lines
13 KiB

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