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.

470 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. 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. 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. strokeWidth: {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. 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__: {object},
  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. tooltipDelay: [300, 0, 1000, 25],
  413. zoomView: true
  414. },
  415. manipulation: {
  416. enabled: false,
  417. initiallyActive: false
  418. },
  419. physics: {
  420. barnesHut: {
  421. //theta: [0.5, 0.1, 1, 0.05],
  422. gravitationalConstant: [-2000, -30000, 0, 50],
  423. centralGravity: [0.3, 0, 10, 0.05],
  424. springLength: [95, 0, 500, 5],
  425. springConstant: [0.04, 0, 1.2, 0.005],
  426. damping: [0.09, 0, 1, 0.01],
  427. avoidOverlap: [0, 0, 1, 0.01]
  428. },
  429. forceAtlas2Based: {
  430. //theta: [0.5, 0.1, 1, 0.05],
  431. gravitationalConstant: [-50, -500, 0, 1],
  432. centralGravity: [0.01, 0, 1, 0.005],
  433. springLength: [95, 0, 500, 5],
  434. springConstant: [0.08, 0, 1.2, 0.005],
  435. damping: [0.4, 0, 1, 0.01],
  436. avoidOverlap: [0, 0, 1, 0.01]
  437. },
  438. repulsion: {
  439. centralGravity: [0.2, 0, 10, 0.05],
  440. springLength: [200, 0, 500, 5],
  441. springConstant: [0.05, 0, 1.2, 0.005],
  442. nodeDistance: [100, 0, 500, 5],
  443. damping: [0.09, 0, 1, 0.01]
  444. },
  445. hierarchicalRepulsion: {
  446. centralGravity: [0.2, 0, 10, 0.05],
  447. springLength: [100, 0, 500, 5],
  448. springConstant: [0.01, 0, 1.2, 0.005],
  449. nodeDistance: [120, 0, 500, 5],
  450. damping: [0.09, 0, 1, 0.01]
  451. },
  452. maxVelocity: [50, 0, 150, 1],
  453. minVelocity: [0.1, 0.01, 0.5, 0.01],
  454. solver: ['barnesHut', 'forceAtlas2Based', 'repulsion', 'hierarchicalRepulsion'],
  455. timestep: [0.5, 0.01, 1, 0.01]
  456. },
  457. global: {
  458. locale: ['en', 'nl']
  459. }
  460. };
  461. export {allOptions, configureOptions};