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.

451 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},
  21. container: {dom},
  22. __type__: {object,boolean,string,array}
  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. hoverEnabled: {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. repulsion: {
  225. centralGravity: {number},
  226. springLength: {number},
  227. springConstant: {number},
  228. nodeDistance: {number},
  229. damping: {number},
  230. __type__: {object}
  231. },
  232. hierarchicalRepulsion: {
  233. centralGravity: {number},
  234. springLength: {number},
  235. springConstant: {number},
  236. nodeDistance: {number},
  237. damping: {number},
  238. __type__: {object}
  239. },
  240. maxVelocity: {number},
  241. minVelocity: {number}, // px/s
  242. solver: {string:['barnesHut','repulsion','hierarchicalRepulsion']},
  243. stabilization: {
  244. enabled: {boolean},
  245. iterations: {number}, // maximum number of iteration to stabilize
  246. updateInterval: {number},
  247. onlyDynamicEdges: {boolean},
  248. fit: {boolean},
  249. __type__: {object,boolean}
  250. },
  251. timestep: {number},
  252. __type__: {object,boolean}
  253. },
  254. //globals :
  255. autoResize: {boolean},
  256. clickToUse: {boolean},
  257. locale:{string},
  258. locales:{
  259. __any__: {object},
  260. __type__: {object}
  261. },
  262. height: {string},
  263. width: {string},
  264. __type__: {object}
  265. };
  266. allOptions.groups.__any__ = allOptions.nodes;
  267. allOptions.manipulation.controlNodeStyle = allOptions.nodes;
  268. let configureOptions = {
  269. nodes: {
  270. borderWidth: [1, 0, 10, 1],
  271. borderWidthSelected: [2, 0, 10, 1],
  272. color: {
  273. border: ['color','#2B7CE9'],
  274. background: ['color','#97C2FC'],
  275. highlight: {
  276. border: ['color','#2B7CE9'],
  277. background: ['color','#D2E5FF']
  278. },
  279. hover: {
  280. border: ['color','#2B7CE9'],
  281. background: ['color','#D2E5FF']
  282. }
  283. },
  284. fixed: {
  285. x: false,
  286. y: false
  287. },
  288. font: {
  289. color: ['color','#343434'],
  290. size: [14, 0, 100, 1], // px
  291. face: ['arial', 'verdana', 'tahoma'],
  292. background: ['color','none'],
  293. strokeWidth: [0, 0, 50, 1], // px
  294. strokeColor: ['color','#ffffff']
  295. },
  296. //group: 'string',
  297. hidden: false,
  298. //icon: {
  299. // face: 'string', //'FontAwesome',
  300. // code: 'string', //'\uf007',
  301. // size: [50, 0, 200, 1], //50,
  302. // color: ['color','#2B7CE9'] //'#aa00ff'
  303. //},
  304. //image: 'string', // --> URL
  305. physics: true,
  306. scaling: {
  307. min: [10, 0, 200, 1],
  308. max: [30, 0, 200, 1],
  309. label: {
  310. enabled: true,
  311. min: [14, 0, 200, 1],
  312. max: [30, 0, 200, 1],
  313. maxVisible: [30, 0, 200, 1],
  314. drawThreshold: [3, 0, 20, 1]
  315. }
  316. },
  317. shadow:{
  318. enabled: false,
  319. size:[10, 0, 20, 1],
  320. x:[5, -30, 30, 1],
  321. y:[5, -30, 30, 1]
  322. },
  323. shape: ['ellipse', 'box', 'circle', 'database', 'diamond', 'dot', 'square', 'star', 'text', 'triangle', 'triangleDown'],
  324. size: [25, 0, 200, 1]
  325. },
  326. edges: {
  327. arrows: {
  328. to: {enabled: false, scaleFactor: [1, 0, 3, 0.05]}, // boolean / {arrowScaleFactor:1} / {enabled: false, arrowScaleFactor:1}
  329. middle: {enabled: false, scaleFactor: [1, 0, 3, 0.05]},
  330. from: {enabled: false, scaleFactor: [1, 0, 3, 0.05]}
  331. },
  332. color: {
  333. color: ['color','#848484'],
  334. highlight: ['color','#848484'],
  335. hover: ['color','#848484'],
  336. inherit: ['from','to','both',true, false],
  337. opacity: [1, 0, 1, 0.05]
  338. },
  339. dashes: false,
  340. font: {
  341. color: ['color','#343434'],
  342. size: [14, 0, 100, 1], // px
  343. face: ['arial', 'verdana', 'tahoma'],
  344. background: ['color','none'],
  345. strokeWidth: [1, 0, 50, 1], // px
  346. strokeColor: ['color','#ffffff'],
  347. align: ['horizontal', 'top', 'middle', 'bottom']
  348. },
  349. hidden: false,
  350. hoverWidth: [2, 0, 5, 0.1],
  351. physics: true,
  352. scaling: {
  353. min: [1, 0, 100, 1],
  354. max: [15, 0, 100, 1],
  355. label: {
  356. enabled: true,
  357. min: [14, 0, 200, 1],
  358. max: [30, 0, 200, 1],
  359. maxVisible: [30, 0, 200, 1],
  360. drawThreshold: [3, 0, 20, 1]
  361. }
  362. },
  363. selectionWidth: [1.5, 0, 5, 0.1],
  364. selfReferenceSize: [20, 0, 200, 1],
  365. shadow:{
  366. enabled: false,
  367. size:[10, 0, 20, 1],
  368. x:[5, -30, 30, 1],
  369. y:[5, -30, 30, 1]
  370. },
  371. smooth: {
  372. enabled: true,
  373. dynamic: true,
  374. type: ['continuous', 'discrete', 'diagonalCross', 'straightCross', 'horizontal', 'vertical', 'curvedCW', 'curvedCCW'],
  375. roundness: [0.5, 0, 1, 0.05]
  376. },
  377. width: [1, 0, 30, 1]
  378. },
  379. layout: {
  380. randomSeed: [0, 0, 500, 1],
  381. hierarchical: {
  382. enabled: false,
  383. levelSeparation: [150, 20, 500, 5],
  384. direction: ['UD', 'DU', 'LR', 'RL'], // UD, DU, LR, RL
  385. sortMethod: ['hubsize', 'directed'] // hubsize, directed
  386. }
  387. },
  388. interaction: {
  389. dragNodes: true,
  390. dragView: true,
  391. hideEdgesOnDrag: false,
  392. hideNodesOnDrag: false,
  393. hoverEnabled: false,
  394. keyboard: {
  395. enabled: false,
  396. speed: {x: [10, 0, 40, 1], y: [10, 0, 40, 1], zoom: [0.02, 0, 0.1, 0.005]},
  397. bindToWindow: true
  398. },
  399. multiselect: false,
  400. navigationButtons: false,
  401. selectable: true,
  402. selectConnectedEdges: true,
  403. tooltipDelay: [300, 0, 1000, 25],
  404. zoomView: true
  405. },
  406. manipulation: {
  407. enabled: false,
  408. initiallyActive: false
  409. },
  410. physics: {
  411. barnesHut: {
  412. //theta: [0.5, 0.1, 1, 0.05],
  413. gravitationalConstant: [-2000, -30000, 0, 50],
  414. centralGravity: [0.3, 0, 10, 0.05],
  415. springLength: [95, 0, 500, 5],
  416. springConstant: [0.04, 0, 5, 0.005],
  417. damping: [0.09, 0, 1, 0.01]
  418. },
  419. repulsion: {
  420. centralGravity: [0.2, 0, 10, 0.05],
  421. springLength: [200, 0, 500, 5],
  422. springConstant: [0.05, 0, 5, 0.005],
  423. nodeDistance: [100, 0, 500, 5],
  424. damping: [0.09, 0, 1, 0.01]
  425. },
  426. hierarchicalRepulsion: {
  427. centralGravity: [0.2, 0, 10, 0.05],
  428. springLength: [100, 0, 500, 5],
  429. springConstant: [0.01, 0, 5, 0.005],
  430. nodeDistance: [120, 0, 500, 5],
  431. damping: [0.09, 0, 1, 0.01]
  432. },
  433. maxVelocity: [50, 0, 150, 1],
  434. minVelocity: [0.1, 0.01, 0.5, 0.01],
  435. solver: ['barnesHut', 'repulsion', 'hierarchicalRepulsion'],
  436. timestep: [0.5, 0, 1, 0.05]
  437. },
  438. global: {
  439. locale: ['en', 'nl']
  440. }
  441. };
  442. export {allOptions, configureOptions};