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.

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