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.

469 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. type: {string:['dynamic','continuous','discrete','diagonalCross','straightCross','horizontal','vertical','curvedCW','curvedCCW']},
  81. roundness: {number},
  82. __type__: {object,boolean}
  83. },
  84. title: {string, undef},
  85. width: {number},
  86. value: {number, undef},
  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. tooltipDelay: {number},
  111. zoomView: {boolean},
  112. __type__: {object}
  113. },
  114. layout: {
  115. randomSeed: {undef,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,fn},
  129. addEdge: {boolean,fn},
  130. editNode: {fn},
  131. editEdge: {boolean,fn},
  132. deleteNode: {boolean,fn},
  133. deleteEdge: {boolean,fn},
  134. controlNodeStyle: 'get from nodes, will be overwritten below',
  135. __type__: {object,boolean}
  136. },
  137. nodes: {
  138. borderWidth: {number},
  139. borderWidthSelected: {number,undef},
  140. brokenImage: {string,undef},
  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. stroke: {number}, // px
  167. strokeColor: {string},
  168. __type__: {object,string}
  169. },
  170. group: {string,number,undef},
  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,undef}, // --> URL
  181. label: {string,undef},
  182. level: {number,undef},
  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: {fn},
  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,undef},
  209. value: {number,undef},
  210. x: {number},
  211. y: {number},
  212. __type__: {object}
  213. },
  214. physics: {
  215. barnesHut: {
  216. gravitationalConstant: {number},
  217. centralGravity: {number},
  218. springLength: {number},
  219. springConstant: {number},
  220. damping: {number},
  221. avoidOverlap: {number},
  222. __type__: {object}
  223. },
  224. forceAtlas2Based: {
  225. gravitationalConstant: {number},
  226. centralGravity: {number},
  227. springLength: {number},
  228. springConstant: {number},
  229. damping: {number},
  230. avoidOverlap: {number},
  231. __type__: {object}
  232. },
  233. repulsion: {
  234. centralGravity: {number},
  235. springLength: {number},
  236. springConstant: {number},
  237. nodeDistance: {number},
  238. damping: {number},
  239. __type__: {object}
  240. },
  241. hierarchicalRepulsion: {
  242. centralGravity: {number},
  243. springLength: {number},
  244. springConstant: {number},
  245. nodeDistance: {number},
  246. damping: {number},
  247. __type__: {object}
  248. },
  249. maxVelocity: {number},
  250. minVelocity: {number}, // px/s
  251. solver: {string:['barnesHut','repulsion','hierarchicalRepulsion','forceAtlas2Based']},
  252. stabilization: {
  253. enabled: {boolean},
  254. iterations: {number}, // maximum number of iteration to stabilize
  255. updateInterval: {number},
  256. onlyDynamicEdges: {boolean},
  257. fit: {boolean},
  258. __type__: {object,boolean}
  259. },
  260. timestep: {number},
  261. __type__: {object,boolean}
  262. },
  263. //globals :
  264. autoResize: {boolean},
  265. clickToUse: {boolean},
  266. locale:{string},
  267. locales:{
  268. __any__: {object},
  269. __type__: {object}
  270. },
  271. height: {string},
  272. width: {string},
  273. __type__: {object}
  274. };
  275. allOptions.groups.__any__ = allOptions.nodes;
  276. allOptions.manipulation.controlNodeStyle = allOptions.nodes;
  277. let configureOptions = {
  278. nodes: {
  279. borderWidth: [1, 0, 10, 1],
  280. borderWidthSelected: [2, 0, 10, 1],
  281. color: {
  282. border: ['color','#2B7CE9'],
  283. background: ['color','#97C2FC'],
  284. highlight: {
  285. border: ['color','#2B7CE9'],
  286. background: ['color','#D2E5FF']
  287. },
  288. hover: {
  289. border: ['color','#2B7CE9'],
  290. background: ['color','#D2E5FF']
  291. }
  292. },
  293. fixed: {
  294. x: false,
  295. y: false
  296. },
  297. font: {
  298. color: ['color','#343434'],
  299. size: [14, 0, 100, 1], // px
  300. face: ['arial', 'verdana', 'tahoma'],
  301. background: ['color','none'],
  302. strokeWidth: [0, 0, 50, 1], // px
  303. strokeColor: ['color','#ffffff']
  304. },
  305. //group: 'string',
  306. hidden: false,
  307. //icon: {
  308. // face: 'string', //'FontAwesome',
  309. // code: 'string', //'\uf007',
  310. // size: [50, 0, 200, 1], //50,
  311. // color: ['color','#2B7CE9'] //'#aa00ff'
  312. //},
  313. //image: 'string', // --> URL
  314. physics: true,
  315. scaling: {
  316. min: [10, 0, 200, 1],
  317. max: [30, 0, 200, 1],
  318. label: {
  319. enabled: true,
  320. min: [14, 0, 200, 1],
  321. max: [30, 0, 200, 1],
  322. maxVisible: [30, 0, 200, 1],
  323. drawThreshold: [3, 0, 20, 1]
  324. }
  325. },
  326. shadow:{
  327. enabled: false,
  328. size:[10, 0, 20, 1],
  329. x:[5, -30, 30, 1],
  330. y:[5, -30, 30, 1]
  331. },
  332. shape: ['ellipse', 'box', 'circle', 'database', 'diamond', 'dot', 'square', 'star', 'text', 'triangle', 'triangleDown'],
  333. size: [25, 0, 200, 1]
  334. },
  335. edges: {
  336. arrows: {
  337. to: {enabled: false, scaleFactor: [1, 0, 3, 0.05]}, // boolean / {arrowScaleFactor:1} / {enabled: false, arrowScaleFactor:1}
  338. middle: {enabled: false, scaleFactor: [1, 0, 3, 0.05]},
  339. from: {enabled: false, scaleFactor: [1, 0, 3, 0.05]}
  340. },
  341. color: {
  342. color: ['color','#848484'],
  343. highlight: ['color','#848484'],
  344. hover: ['color','#848484'],
  345. inherit: ['from','to','both',true, false],
  346. opacity: [1, 0, 1, 0.05]
  347. },
  348. dashes: false,
  349. font: {
  350. color: ['color','#343434'],
  351. size: [14, 0, 100, 1], // px
  352. face: ['arial', 'verdana', 'tahoma'],
  353. background: ['color','none'],
  354. strokeWidth: [1, 0, 50, 1], // px
  355. strokeColor: ['color','#ffffff'],
  356. align: ['horizontal', 'top', 'middle', 'bottom']
  357. },
  358. hidden: false,
  359. hoverWidth: [2, 0, 5, 0.1],
  360. physics: true,
  361. scaling: {
  362. min: [1, 0, 100, 1],
  363. max: [15, 0, 100, 1],
  364. label: {
  365. enabled: true,
  366. min: [14, 0, 200, 1],
  367. max: [30, 0, 200, 1],
  368. maxVisible: [30, 0, 200, 1],
  369. drawThreshold: [3, 0, 20, 1]
  370. }
  371. },
  372. selectionWidth: [1.5, 0, 5, 0.1],
  373. selfReferenceSize: [20, 0, 200, 1],
  374. shadow:{
  375. enabled: false,
  376. size:[10, 0, 20, 1],
  377. x:[5, -30, 30, 1],
  378. y:[5, -30, 30, 1]
  379. },
  380. smooth: {
  381. enabled: true,
  382. type: ['dynamic','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. avoidOverlap: [0, 0, 1, 0.01]
  427. },
  428. forceAtlas2Based: {
  429. //theta: [0.5, 0.1, 1, 0.05],
  430. gravitationalConstant: [-800, -3000, 0, 1],
  431. centralGravity: [0.01, 0, 1, 0.005],
  432. springLength: [95, 0, 500, 5],
  433. springConstant: [0.08, 0, 5, 0.005],
  434. damping: [0.4, 0, 1, 0.01],
  435. avoidOverlap: [0, 0, 1, 0.01]
  436. },
  437. repulsion: {
  438. centralGravity: [0.2, 0, 10, 0.05],
  439. springLength: [200, 0, 500, 5],
  440. springConstant: [0.05, 0, 5, 0.005],
  441. nodeDistance: [100, 0, 500, 5],
  442. damping: [0.09, 0, 1, 0.01]
  443. },
  444. hierarchicalRepulsion: {
  445. centralGravity: [0.2, 0, 10, 0.05],
  446. springLength: [100, 0, 500, 5],
  447. springConstant: [0.01, 0, 5, 0.005],
  448. nodeDistance: [120, 0, 500, 5],
  449. damping: [0.09, 0, 1, 0.01]
  450. },
  451. maxVelocity: [50, 0, 150, 1],
  452. minVelocity: [0.1, 0.01, 0.5, 0.01],
  453. solver: ['barnesHut', 'forceAtlas2Based', 'repulsion', 'hierarchicalRepulsion'],
  454. timestep: [0.5, 0, 1, 0.05]
  455. },
  456. global: {
  457. locale: ['en', 'nl']
  458. }
  459. };
  460. export {allOptions, configureOptions};