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.

467 lines
12 KiB

9 years ago
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 fn = 'function';
  15. let undef = 'undefined';
  16. let any = 'any'
  17. let allOptions = {
  18. configure: {
  19. enabled: {boolean},
  20. filter: {boolean,string,array,fn},
  21. container: {dom},
  22. __type__: {object,boolean,string,array,fn}
  23. },
  24. edges: {
  25. arrows: {
  26. to: {enabled: {boolean}, scaleFactor: {number}, __type__: {object, boolean}},
  27. middle: {enabled: {boolean}, scaleFactor: {number}, __type__: {object, boolean}},
  28. from: {enabled: {boolean}, scaleFactor: {number}, __type__: {object, boolean}},
  29. __type__: {string:['from','to','middle'],object}
  30. },
  31. color: {
  32. color: {string},
  33. highlight: {string},
  34. hover: {string},
  35. inherit: {string:['from','to','both'],boolean},
  36. opacity: {number},
  37. __type__: {object, string}
  38. },
  39. dashes: {boolean,array},
  40. font: {
  41. color: {string},
  42. size: {number}, // px
  43. face: {string},
  44. background: {string},
  45. strokeWidth: {number}, // px
  46. strokeColor: {string},
  47. align: {string:['horizontal','top','middle','bottom']},
  48. __type__: {object,string}
  49. },
  50. hidden: {boolean},
  51. hoverWidth: {fn,number},
  52. label: {string,undef},
  53. length: {number,undef},
  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: {fn},
  67. __type__: {object}
  68. },
  69. selectionWidth: {fn,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. dynamic: {boolean},
  81. type: {string},
  82. roundness: {number},
  83. __type__: {object,boolean}
  84. },
  85. title: {string, undef},
  86. width: {number},
  87. value: {number, undef},
  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. tooltipDelay: {number},
  112. zoomView: {boolean},
  113. __type__: {object}
  114. },
  115. layout: {
  116. randomSeed: {undef,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,fn},
  130. addEdge: {boolean,fn},
  131. editNode: {fn},
  132. editEdge: {boolean,fn},
  133. deleteNode: {boolean,fn},
  134. deleteEdge: {boolean,fn},
  135. controlNodeStyle: 'get from nodes, will be overwritten below',
  136. __type__: {object,boolean}
  137. },
  138. nodes: {
  139. borderWidth: {number},
  140. borderWidthSelected: {number,undef},
  141. brokenImage: {string,undef},
  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. stroke: {number}, // px
  168. strokeColor: {string},
  169. __type__: {object,string}
  170. },
  171. group: {string,number,undef},
  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,undef}, // --> URL
  182. label: {string,undef},
  183. level: {number,undef},
  184. mass: {number},
  185. physics: {boolean},
  186. scaling: {
  187. min: {number},
  188. max: {number},
  189. label: {
  190. enabled: {boolean},
  191. min: {number},
  192. max: {number},
  193. maxVisible: {number},
  194. drawThreshold: {number},
  195. __type__: {object, boolean}
  196. },
  197. customScalingFunction: {fn},
  198. __type__: {object}
  199. },
  200. shadow: {
  201. enabled: {boolean},
  202. size: {number},
  203. x: {number},
  204. y: {number},
  205. __type__: {object,boolean}
  206. },
  207. shape: {string:['ellipse', 'circle', 'database', 'box', 'text','image', 'circularImage','diamond', 'dot', 'star', 'triangle', 'triangleDown', 'square','icon']},
  208. size: {number},
  209. title: {string,undef},
  210. value: {number,undef},
  211. x: {number},
  212. y: {number},
  213. __type__: {object}
  214. },
  215. physics: {
  216. barnesHut: {
  217. gravitationalConstant: {number},
  218. centralGravity: {number},
  219. springLength: {number},
  220. springConstant: {number},
  221. damping: {number},
  222. __type__: {object}
  223. },
  224. forceAtlas2Based: {
  225. gravitationalConstant: {number},
  226. centralGravity: {number},
  227. springLength: {number},
  228. springConstant: {number},
  229. damping: {number},
  230. __type__: {object}
  231. },
  232. repulsion: {
  233. centralGravity: {number},
  234. springLength: {number},
  235. springConstant: {number},
  236. nodeDistance: {number},
  237. damping: {number},
  238. __type__: {object}
  239. },
  240. hierarchicalRepulsion: {
  241. centralGravity: {number},
  242. springLength: {number},
  243. springConstant: {number},
  244. nodeDistance: {number},
  245. damping: {number},
  246. __type__: {object}
  247. },
  248. maxVelocity: {number},
  249. minVelocity: {number}, // px/s
  250. solver: {string:['barnesHut','repulsion','hierarchicalRepulsion','forceAtlas2Based']},
  251. stabilization: {
  252. enabled: {boolean},
  253. iterations: {number}, // maximum number of iteration to stabilize
  254. updateInterval: {number},
  255. onlyDynamicEdges: {boolean},
  256. fit: {boolean},
  257. __type__: {object,boolean}
  258. },
  259. timestep: {number},
  260. __type__: {object,boolean}
  261. },
  262. //globals :
  263. autoResize: {boolean},
  264. clickToUse: {boolean},
  265. locale:{string},
  266. locales:{
  267. __any__: {object},
  268. __type__: {object}
  269. },
  270. height: {string},
  271. width: {string},
  272. __type__: {object}
  273. };
  274. allOptions.groups.__any__ = allOptions.nodes;
  275. allOptions.manipulation.controlNodeStyle = allOptions.nodes;
  276. let configureOptions = {
  277. nodes: {
  278. borderWidth: [1, 0, 10, 1],
  279. borderWidthSelected: [2, 0, 10, 1],
  280. color: {
  281. border: ['color','#2B7CE9'],
  282. background: ['color','#97C2FC'],
  283. highlight: {
  284. border: ['color','#2B7CE9'],
  285. background: ['color','#D2E5FF']
  286. },
  287. hover: {
  288. border: ['color','#2B7CE9'],
  289. background: ['color','#D2E5FF']
  290. }
  291. },
  292. fixed: {
  293. x: false,
  294. y: false
  295. },
  296. font: {
  297. color: ['color','#343434'],
  298. size: [14, 0, 100, 1], // px
  299. face: ['arial', 'verdana', 'tahoma'],
  300. background: ['color','none'],
  301. strokeWidth: [0, 0, 50, 1], // px
  302. strokeColor: ['color','#ffffff']
  303. },
  304. //group: 'string',
  305. hidden: false,
  306. //icon: {
  307. // face: 'string', //'FontAwesome',
  308. // code: 'string', //'\uf007',
  309. // size: [50, 0, 200, 1], //50,
  310. // color: ['color','#2B7CE9'] //'#aa00ff'
  311. //},
  312. //image: 'string', // --> URL
  313. physics: true,
  314. scaling: {
  315. min: [10, 0, 200, 1],
  316. max: [30, 0, 200, 1],
  317. label: {
  318. enabled: true,
  319. min: [14, 0, 200, 1],
  320. max: [30, 0, 200, 1],
  321. maxVisible: [30, 0, 200, 1],
  322. drawThreshold: [3, 0, 20, 1]
  323. }
  324. },
  325. shadow:{
  326. enabled: false,
  327. size:[10, 0, 20, 1],
  328. x:[5, -30, 30, 1],
  329. y:[5, -30, 30, 1]
  330. },
  331. shape: ['ellipse', 'box', 'circle', 'database', 'diamond', 'dot', 'square', 'star', 'text', 'triangle', 'triangleDown'],
  332. size: [25, 0, 200, 1]
  333. },
  334. edges: {
  335. arrows: {
  336. to: {enabled: false, scaleFactor: [1, 0, 3, 0.05]}, // boolean / {arrowScaleFactor:1} / {enabled: false, arrowScaleFactor:1}
  337. middle: {enabled: false, scaleFactor: [1, 0, 3, 0.05]},
  338. from: {enabled: false, scaleFactor: [1, 0, 3, 0.05]}
  339. },
  340. color: {
  341. color: ['color','#848484'],
  342. highlight: ['color','#848484'],
  343. hover: ['color','#848484'],
  344. inherit: ['from','to','both',true, false],
  345. opacity: [1, 0, 1, 0.05]
  346. },
  347. dashes: false,
  348. font: {
  349. color: ['color','#343434'],
  350. size: [14, 0, 100, 1], // px
  351. face: ['arial', 'verdana', 'tahoma'],
  352. background: ['color','none'],
  353. strokeWidth: [1, 0, 50, 1], // px
  354. strokeColor: ['color','#ffffff'],
  355. align: ['horizontal', 'top', 'middle', 'bottom']
  356. },
  357. hidden: false,
  358. hoverWidth: [2, 0, 5, 0.1],
  359. physics: true,
  360. scaling: {
  361. min: [1, 0, 100, 1],
  362. max: [15, 0, 100, 1],
  363. label: {
  364. enabled: true,
  365. min: [14, 0, 200, 1],
  366. max: [30, 0, 200, 1],
  367. maxVisible: [30, 0, 200, 1],
  368. drawThreshold: [3, 0, 20, 1]
  369. }
  370. },
  371. selectionWidth: [1.5, 0, 5, 0.1],
  372. selfReferenceSize: [20, 0, 200, 1],
  373. shadow:{
  374. enabled: false,
  375. size:[10, 0, 20, 1],
  376. x:[5, -30, 30, 1],
  377. y:[5, -30, 30, 1]
  378. },
  379. smooth: {
  380. enabled: true,
  381. dynamic: true,
  382. type: ['continuous', 'discrete', 'diagonalCross', 'straightCross', 'horizontal', 'vertical', 'curvedCW', 'curvedCCW'],
  383. roundness: [0.5, 0, 1, 0.05]
  384. },
  385. width: [1, 0, 30, 1]
  386. },
  387. layout: {
  388. randomSeed: [0, 0, 500, 1],
  389. hierarchical: {
  390. enabled: false,
  391. levelSeparation: [150, 20, 500, 5],
  392. direction: ['UD', 'DU', 'LR', 'RL'], // UD, DU, LR, RL
  393. sortMethod: ['hubsize', 'directed'] // hubsize, directed
  394. }
  395. },
  396. interaction: {
  397. dragNodes: true,
  398. dragView: true,
  399. hideEdgesOnDrag: false,
  400. hideNodesOnDrag: false,
  401. hover: false,
  402. keyboard: {
  403. enabled: false,
  404. speed: {x: [10, 0, 40, 1], y: [10, 0, 40, 1], zoom: [0.02, 0, 0.1, 0.005]},
  405. bindToWindow: true
  406. },
  407. multiselect: false,
  408. navigationButtons: false,
  409. selectable: true,
  410. selectConnectedEdges: true,
  411. tooltipDelay: [300, 0, 1000, 25],
  412. zoomView: true
  413. },
  414. manipulation: {
  415. enabled: false,
  416. initiallyActive: false
  417. },
  418. physics: {
  419. barnesHut: {
  420. //theta: [0.5, 0.1, 1, 0.05],
  421. gravitationalConstant: [-2000, -30000, 0, 50],
  422. centralGravity: [0.3, 0, 10, 0.05],
  423. springLength: [95, 0, 500, 5],
  424. springConstant: [0.04, 0, 5, 0.005],
  425. damping: [0.09, 0, 1, 0.01]
  426. },
  427. forceAtlas2Based: {
  428. //theta: [0.5, 0.1, 1, 0.05],
  429. gravitationalConstant: [-800, -3000, 0, 1],
  430. centralGravity: [0.01, 0, 1, 0.005],
  431. springLength: [95, 0, 500, 5],
  432. springConstant: [0.08, 0, 5, 0.005],
  433. damping: [0.4, 0, 1, 0.01]
  434. },
  435. repulsion: {
  436. centralGravity: [0.2, 0, 10, 0.05],
  437. springLength: [200, 0, 500, 5],
  438. springConstant: [0.05, 0, 5, 0.005],
  439. nodeDistance: [100, 0, 500, 5],
  440. damping: [0.09, 0, 1, 0.01]
  441. },
  442. hierarchicalRepulsion: {
  443. centralGravity: [0.2, 0, 10, 0.05],
  444. springLength: [100, 0, 500, 5],
  445. springConstant: [0.01, 0, 5, 0.005],
  446. nodeDistance: [120, 0, 500, 5],
  447. damping: [0.09, 0, 1, 0.01]
  448. },
  449. maxVelocity: [50, 0, 150, 1],
  450. minVelocity: [0.1, 0.01, 0.5, 0.01],
  451. solver: ['barnesHut', 'forceAtlas2Based', 'repulsion', 'hierarchicalRepulsion'],
  452. timestep: [0.5, 0, 1, 0.05]
  453. },
  454. global: {
  455. locale: ['en', 'nl']
  456. }
  457. };
  458. export {allOptions, configureOptions};