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
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. showButton: {boolean},
  23. __type__: {object,boolean,string,array,fn}
  24. },
  25. edges: {
  26. arrows: {
  27. to: {enabled: {boolean}, scaleFactor: {number}, __type__: {object, boolean}},
  28. middle: {enabled: {boolean}, scaleFactor: {number}, __type__: {object, boolean}},
  29. from: {enabled: {boolean}, scaleFactor: {number}, __type__: {object, boolean}},
  30. __type__: {string:['from','to','middle'],object}
  31. },
  32. color: {
  33. color: {string},
  34. highlight: {string},
  35. hover: {string},
  36. inherit: {string:['from','to','both'],boolean},
  37. opacity: {number},
  38. __type__: {object, string}
  39. },
  40. dashes: {boolean,array},
  41. font: {
  42. color: {string},
  43. size: {number}, // px
  44. face: {string},
  45. background: {string},
  46. strokeWidth: {number}, // px
  47. strokeColor: {string},
  48. align: {string:['horizontal','top','middle','bottom']},
  49. __type__: {object,string}
  50. },
  51. hidden: {boolean},
  52. hoverWidth: {fn,number},
  53. label: {string,undef},
  54. length: {number,undef},
  55. physics: {boolean},
  56. scaling: {
  57. min: {number},
  58. max: {number},
  59. label: {
  60. enabled: {boolean},
  61. min: {number},
  62. max: {number},
  63. maxVisible: {number},
  64. drawThreshold: {number},
  65. __type__: {object,boolean}
  66. },
  67. customScalingFunction: {fn},
  68. __type__: {object}
  69. },
  70. selectionWidth: {fn,number},
  71. selfReferenceSize: {number},
  72. shadow: {
  73. enabled: {boolean},
  74. size: {number},
  75. x: {number},
  76. y: {number},
  77. __type__: {object,boolean}
  78. },
  79. smooth: {
  80. enabled: {boolean},
  81. type: {string:['dynamic','continuous','discrete','diagonalCross','straightCross','horizontal','vertical','curvedCW','curvedCCW']},
  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. hoverConnectedEdges: {boolean},
  112. tooltipDelay: {number},
  113. zoomView: {boolean},
  114. __type__: {object}
  115. },
  116. layout: {
  117. randomSeed: {undef,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,fn},
  131. addEdge: {boolean,fn},
  132. editNode: {fn},
  133. editEdge: {boolean,fn},
  134. deleteNode: {boolean,fn},
  135. deleteEdge: {boolean,fn},
  136. controlNodeStyle: 'get from nodes, will be overwritten below',
  137. __type__: {object,boolean}
  138. },
  139. nodes: {
  140. borderWidth: {number},
  141. borderWidthSelected: {number,undef},
  142. brokenImage: {string,undef},
  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,undef},
  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,undef}, // --> URL
  183. label: {string,undef},
  184. level: {number,undef},
  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: {fn},
  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,undef},
  211. value: {number,undef},
  212. x: {number},
  213. y: {number},
  214. __type__: {object}
  215. },
  216. physics: {
  217. barnesHut: {
  218. gravitationalConstant: {number},
  219. centralGravity: {number},
  220. springLength: {number},
  221. springConstant: {number},
  222. damping: {number},
  223. avoidOverlap: {number},
  224. __type__: {object}
  225. },
  226. forceAtlas2Based: {
  227. gravitationalConstant: {number},
  228. centralGravity: {number},
  229. springLength: {number},
  230. springConstant: {number},
  231. damping: {number},
  232. avoidOverlap: {number},
  233. __type__: {object}
  234. },
  235. repulsion: {
  236. centralGravity: {number},
  237. springLength: {number},
  238. springConstant: {number},
  239. nodeDistance: {number},
  240. damping: {number},
  241. __type__: {object}
  242. },
  243. hierarchicalRepulsion: {
  244. centralGravity: {number},
  245. springLength: {number},
  246. springConstant: {number},
  247. nodeDistance: {number},
  248. damping: {number},
  249. __type__: {object}
  250. },
  251. maxVelocity: {number},
  252. minVelocity: {number}, // px/s
  253. solver: {string:['barnesHut','repulsion','hierarchicalRepulsion','forceAtlas2Based']},
  254. stabilization: {
  255. enabled: {boolean},
  256. iterations: {number}, // maximum number of iteration to stabilize
  257. updateInterval: {number},
  258. onlyDynamicEdges: {boolean},
  259. fit: {boolean},
  260. __type__: {object,boolean}
  261. },
  262. timestep: {number},
  263. __type__: {object,boolean}
  264. },
  265. //globals :
  266. autoResize: {boolean},
  267. clickToUse: {boolean},
  268. locale:{string},
  269. locales:{
  270. __any__: {object},
  271. __type__: {object}
  272. },
  273. height: {string},
  274. width: {string},
  275. __type__: {object}
  276. };
  277. allOptions.groups.__any__ = allOptions.nodes;
  278. allOptions.manipulation.controlNodeStyle = allOptions.nodes;
  279. let configureOptions = {
  280. nodes: {
  281. borderWidth: [1, 0, 10, 1],
  282. borderWidthSelected: [2, 0, 10, 1],
  283. color: {
  284. border: ['color','#2B7CE9'],
  285. background: ['color','#97C2FC'],
  286. highlight: {
  287. border: ['color','#2B7CE9'],
  288. background: ['color','#D2E5FF']
  289. },
  290. hover: {
  291. border: ['color','#2B7CE9'],
  292. background: ['color','#D2E5FF']
  293. }
  294. },
  295. fixed: {
  296. x: false,
  297. y: false
  298. },
  299. font: {
  300. color: ['color','#343434'],
  301. size: [14, 0, 100, 1], // px
  302. face: ['arial', 'verdana', 'tahoma'],
  303. background: ['color','none'],
  304. strokeWidth: [0, 0, 50, 1], // px
  305. strokeColor: ['color','#ffffff']
  306. },
  307. //group: 'string',
  308. hidden: false,
  309. //icon: {
  310. // face: 'string', //'FontAwesome',
  311. // code: 'string', //'\uf007',
  312. // size: [50, 0, 200, 1], //50,
  313. // color: ['color','#2B7CE9'] //'#aa00ff'
  314. //},
  315. //image: 'string', // --> URL
  316. physics: true,
  317. scaling: {
  318. min: [10, 0, 200, 1],
  319. max: [30, 0, 200, 1],
  320. label: {
  321. enabled: false,
  322. min: [14, 0, 200, 1],
  323. max: [30, 0, 200, 1],
  324. maxVisible: [30, 0, 200, 1],
  325. drawThreshold: [5, 0, 20, 1]
  326. }
  327. },
  328. shadow:{
  329. enabled: false,
  330. size:[10, 0, 20, 1],
  331. x:[5, -30, 30, 1],
  332. y:[5, -30, 30, 1]
  333. },
  334. shape: ['ellipse', 'box', 'circle', 'database', 'diamond', 'dot', 'square', 'star', 'text', 'triangle', 'triangleDown'],
  335. size: [25, 0, 200, 1]
  336. },
  337. edges: {
  338. arrows: {
  339. to: {enabled: false, scaleFactor: [1, 0, 3, 0.05]}, // boolean / {arrowScaleFactor:1} / {enabled: false, arrowScaleFactor:1}
  340. middle: {enabled: false, scaleFactor: [1, 0, 3, 0.05]},
  341. from: {enabled: false, scaleFactor: [1, 0, 3, 0.05]}
  342. },
  343. color: {
  344. color: ['color','#848484'],
  345. highlight: ['color','#848484'],
  346. hover: ['color','#848484'],
  347. inherit: ['from','to','both',true, false],
  348. opacity: [1, 0, 1, 0.05]
  349. },
  350. dashes: false,
  351. font: {
  352. color: ['color','#343434'],
  353. size: [14, 0, 100, 1], // px
  354. face: ['arial', 'verdana', 'tahoma'],
  355. background: ['color','none'],
  356. strokeWidth: [2, 0, 50, 1], // px
  357. strokeColor: ['color','#ffffff'],
  358. align: ['horizontal', 'top', 'middle', 'bottom']
  359. },
  360. hidden: false,
  361. hoverWidth: [1.5, 0, 5, 0.1],
  362. physics: true,
  363. scaling: {
  364. min: [1, 0, 100, 1],
  365. max: [15, 0, 100, 1],
  366. label: {
  367. enabled: true,
  368. min: [14, 0, 200, 1],
  369. max: [30, 0, 200, 1],
  370. maxVisible: [30, 0, 200, 1],
  371. drawThreshold: [5, 0, 20, 1]
  372. }
  373. },
  374. selectionWidth: [1.5, 0, 5, 0.1],
  375. selfReferenceSize: [20, 0, 200, 1],
  376. shadow:{
  377. enabled: false,
  378. size:[10, 0, 20, 1],
  379. x:[5, -30, 30, 1],
  380. y:[5, -30, 30, 1]
  381. },
  382. smooth: {
  383. enabled: true,
  384. type: ['dynamic','continuous', 'discrete', 'diagonalCross', 'straightCross', 'horizontal', 'vertical', 'curvedCW', 'curvedCCW'],
  385. roundness: [0.5, 0, 1, 0.05]
  386. },
  387. width: [1, 0, 30, 1]
  388. },
  389. layout: {
  390. //randomSeed: [0, 0, 500, 1],
  391. hierarchical: {
  392. enabled: false,
  393. levelSeparation: [150, 20, 500, 5],
  394. direction: ['UD', 'DU', 'LR', 'RL'], // UD, DU, LR, RL
  395. sortMethod: ['hubsize', 'directed'] // hubsize, directed
  396. }
  397. },
  398. interaction: {
  399. dragNodes: true,
  400. dragView: true,
  401. hideEdgesOnDrag: false,
  402. hideNodesOnDrag: false,
  403. hover: false,
  404. keyboard: {
  405. enabled: false,
  406. speed: {x: [10, 0, 40, 1], y: [10, 0, 40, 1], zoom: [0.02, 0, 0.1, 0.005]},
  407. bindToWindow: true
  408. },
  409. multiselect: false,
  410. navigationButtons: false,
  411. selectable: true,
  412. selectConnectedEdges: true,
  413. hoverConnectedEdges: true,
  414. tooltipDelay: [300, 0, 1000, 25],
  415. zoomView: true
  416. },
  417. manipulation: {
  418. enabled: false,
  419. initiallyActive: false
  420. },
  421. physics: {
  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};