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.

455 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';
  13. let dom = 'dom';
  14. let fn = 'function';
  15. let undef = 'undefined';
  16. let allOptions = {
  17. canvas: {
  18. width: {string},
  19. height: {string},
  20. autoResize: {boolean},
  21. __type__: {object}
  22. },
  23. rendering: {
  24. hideEdgesOnDrag: {boolean},
  25. hideNodesOnDrag: {boolean},
  26. __type__: {object}
  27. },
  28. clustering: {},
  29. configure: {
  30. enabled: {boolean},
  31. filter: {boolean,string:['nodes','edges','layout','physics','manipulation','interaction','selection','rendering'],array},
  32. container: {dom},
  33. __type__: {object,boolean,string:['nodes','edges','layout','physics','manipulation','interaction','selection','rendering'],array}
  34. },
  35. edges: {
  36. arrows: {
  37. to: {enabled: {boolean}, scaleFactor: {number}, __type__: {object}},
  38. middle: {enabled: {boolean}, scaleFactor: {number}, __type__: {object}},
  39. from: {enabled: {boolean}, scaleFactor: {number}, __type__: {object}},
  40. __type__: {string:['from','to','middle'],object}
  41. },
  42. color: {
  43. color: {string},
  44. highlight: {string},
  45. hover: {string},
  46. inherit: {string:['from','to','both'],boolean},
  47. opacity: {number},
  48. __type__: {object, string}
  49. },
  50. dashes: {boolean,array},
  51. font: {
  52. color: {string},
  53. size: {number}, // px
  54. face: {string},
  55. background: {string},
  56. stroke: {number}, // px
  57. strokeColor: {string},
  58. align: {string:['horizontal','top','middle','bottom']},
  59. __type__: {object,string}
  60. },
  61. hidden: {boolean},
  62. hoverWidth: {fn,number},
  63. label: {string,undef},
  64. length: {number,undef},
  65. physics: {boolean},
  66. scaling: {
  67. min: {number},
  68. max: {number},
  69. label: {
  70. enabled: {boolean},
  71. min: {number},
  72. max: {number},
  73. maxVisible: {number},
  74. drawThreshold: {number},
  75. __type__: {object,boolean}
  76. },
  77. customScalingFunction: {fn},
  78. __type__: {object}
  79. },
  80. selectionWidth: {fn,number},
  81. selfReferenceSize: {number},
  82. shadow: {
  83. enabled: {boolean},
  84. size: {number},
  85. x: {number},
  86. y: {number},
  87. __type__: {object,boolean}
  88. },
  89. smooth: {
  90. enabled: {boolean},
  91. dynamic: {boolean},
  92. type: {string},
  93. roundness: {number},
  94. __type__: {object,boolean}
  95. },
  96. title: {string, undef},
  97. width: {number},
  98. value: {number, undef},
  99. __type__: {object}
  100. },
  101. groups: {
  102. useDefaultGroups: {boolean},
  103. __any__: ['__ref__','nodes'],
  104. __type__: {object}
  105. },
  106. interaction: {
  107. dragNodes: {boolean},
  108. dragView: {boolean},
  109. zoomView: {boolean},
  110. hoverEnabled: {boolean},
  111. navigationButtons: {boolean},
  112. tooltipDelay: {number},
  113. keyboard: {
  114. enabled: {boolean},
  115. speed: {x: {number}, y: {number}, zoom: {number}, __type__: {object}},
  116. bindToWindow: {boolean},
  117. __type__: {object,boolean}
  118. },
  119. __type__: {object}
  120. },
  121. layout: {
  122. randomSeed: {undef,number},
  123. hierarchical: {
  124. enabled: {boolean},
  125. levelSeparation: {number},
  126. direction: {string:['UD','DU','LR','RL']}, // UD, DU, LR, RL
  127. sortMethod: {string:['hubsize','directed']}, // hubsize, directed
  128. __type__: {object,boolean}
  129. },
  130. __type__: {object}
  131. },
  132. manipulation: {
  133. enabled: {boolean},
  134. initiallyActive: {boolean},
  135. locale: {string},
  136. locales: {object},
  137. addNode: {boolean,fn},
  138. addEdge: {boolean,fn},
  139. editNode: {fn},
  140. editEdge: {boolean,fn},
  141. deleteNode: {boolean,fn},
  142. deleteEdge: {boolean,fn},
  143. controlNodeStyle: ['__ref__','nodes'],
  144. __type__: {object,boolean}
  145. },
  146. nodes: {
  147. borderWidth: {number},
  148. borderWidthSelected: {number,undef},
  149. brokenImage: {string,undef},
  150. color: {
  151. border: {string},
  152. background: {string},
  153. highlight: {
  154. border: {string},
  155. background: {string},
  156. __type__: {object,string}
  157. },
  158. hover: {
  159. border: {string},
  160. background: {string},
  161. __type__: {object,string}
  162. },
  163. __type__: {object,string}
  164. },
  165. fixed: {
  166. x: {boolean},
  167. y: {boolean},
  168. __type__: {object,boolean}
  169. },
  170. font: {
  171. color: {string},
  172. size: {number}, // px
  173. face: {string},
  174. background: {string},
  175. stroke: {number}, // px
  176. strokeColor: {string},
  177. __type__: {object,string}
  178. },
  179. group: {string,number,undef},
  180. hidden: {boolean},
  181. icon: {
  182. face: {string},
  183. code: {string}, //'\uf007',
  184. size: {number}, //50,
  185. color: {string},
  186. __type__: {object}
  187. },
  188. id: {string, number},
  189. image: {string,undef}, // --> URL
  190. label: {string,undef},
  191. level: {number,undef},
  192. mass: {number},
  193. physics: {boolean},
  194. scaling: {
  195. min: {number},
  196. max: {number},
  197. label: {
  198. enabled: {boolean},
  199. min: {number},
  200. max: {number},
  201. maxVisible: {number},
  202. drawThreshold: {number},
  203. __type__: {object, boolean}
  204. },
  205. customScalingFunction: {fn},
  206. __type__: {object}
  207. },
  208. shadow: {
  209. enabled: {boolean},
  210. size: {number},
  211. x: {number},
  212. y: {number},
  213. __type__: {object,boolean}
  214. },
  215. shape: {string:['ellipse', 'circle', 'database', 'box', 'text','image', 'circularImage','diamond', 'dot', 'star', 'triangle','triangleDown', 'square','icon']},
  216. size: {number},
  217. title: {string,undef},
  218. value: {number,undef},
  219. x: {number},
  220. y: {number},
  221. __type__: {object}
  222. },
  223. physics: {
  224. barnesHut: {
  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']},
  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. selection: {
  263. selectable: {boolean},
  264. selectConnectedEdges: {boolean},
  265. __type__: {object}
  266. },
  267. view: {},
  268. __type__: {object}
  269. };
  270. allOptions.groups.__any__ = allOptions.nodes;
  271. allOptions.manipulation.controlNodeStyle = allOptions.nodes;
  272. let configureOptions = {
  273. nodes: {
  274. borderWidth: [1, 0, 10, 1],
  275. borderWidthSelected: [2, 0, 10, 1],
  276. color: {
  277. border: ['color','#2B7CE9'],
  278. background: ['color','#97C2FC'],
  279. highlight: {
  280. border: ['color','#2B7CE9'],
  281. background: ['color','#D2E5FF']
  282. },
  283. hover: {
  284. border: ['color','#2B7CE9'],
  285. background: ['color','#D2E5FF']
  286. }
  287. },
  288. fixed: {
  289. x: false,
  290. y: false
  291. },
  292. font: {
  293. color: ['color','#343434'],
  294. size: [14, 0, 100, 1], // px
  295. face: ['arial', 'verdana', 'tahoma'],
  296. background: ['color','none'],
  297. stroke: [0, 0, 50, 1], // px
  298. strokeColor: ['color','#ffffff']
  299. },
  300. //group: 'string',
  301. hidden: false,
  302. //icon: {
  303. // face: 'string', //'FontAwesome',
  304. // code: 'string', //'\uf007',
  305. // size: [50, 0, 200, 1], //50,
  306. // color: ['color','#2B7CE9'] //'#aa00ff'
  307. //},
  308. //image: 'string', // --> URL
  309. physics: true,
  310. scaling: {
  311. min: [10, 0, 200, 1],
  312. max: [30, 0, 200, 1],
  313. label: {
  314. enabled: true,
  315. min: [14, 0, 200, 1],
  316. max: [30, 0, 200, 1],
  317. maxVisible: [30, 0, 200, 1],
  318. drawThreshold: [3, 0, 20, 1]
  319. }
  320. },
  321. shadow:{
  322. enabled: false,
  323. size:[10, 0, 20, 1],
  324. x:[5, -30, 30, 1],
  325. y:[5, -30, 30, 1]
  326. },
  327. shape: ['ellipse', 'box', 'circle', 'database', 'diamond', 'dot', 'square', 'star', 'text', 'triangle', 'triangleDown'],
  328. size: [25, 0, 200, 1]
  329. },
  330. edges: {
  331. arrows: {
  332. to: {enabled: false, scaleFactor: [1, 0, 3, 0.05]}, // boolean / {arrowScaleFactor:1} / {enabled: false, arrowScaleFactor:1}
  333. middle: {enabled: false, scaleFactor: [1, 0, 3, 0.05]},
  334. from: {enabled: false, scaleFactor: [1, 0, 3, 0.05]}
  335. },
  336. color: {
  337. color: ['color','#848484'],
  338. highlight: ['color','#848484'],
  339. hover: ['color','#848484'],
  340. inherit: ['from','to','both',true, false],
  341. opacity: [1, 0, 1, 0.05]
  342. },
  343. dashes: false,
  344. font: {
  345. color: ['color','#343434'],
  346. size: [14, 0, 100, 1], // px
  347. face: ['arial', 'verdana', 'tahoma'],
  348. background: ['color','none'],
  349. stroke: [1, 0, 50, 1], // px
  350. strokeColor: ['color','#ffffff'],
  351. align: ['horizontal', 'top', 'middle', 'bottom']
  352. },
  353. hidden: false,
  354. hoverWidth: [2, 0, 5, 0.1],
  355. physics: true,
  356. scaling: {
  357. min: [1, 0, 100, 1],
  358. max: [15, 0, 100, 1],
  359. label: {
  360. enabled: true,
  361. min: [14, 0, 200, 1],
  362. max: [30, 0, 200, 1],
  363. maxVisible: [30, 0, 200, 1],
  364. drawThreshold: [3, 0, 20, 1]
  365. }
  366. },
  367. selectionWidth: [1.5, 0, 5, 0.1],
  368. selfReferenceSize: [20, 0, 200, 1],
  369. shadow:{
  370. enabled: false,
  371. size:[10, 0, 20, 1],
  372. x:[5, -30, 30, 1],
  373. y:[5, -30, 30, 1]
  374. },
  375. smooth: {
  376. enabled: true,
  377. dynamic: true,
  378. type: ['continuous', 'discrete', 'diagonalCross', 'straightCross', 'horizontal', 'vertical', 'curvedCW', 'curvedCCW'],
  379. roundness: [0.5, 0, 1, 0.05]
  380. },
  381. width: [1, 0, 30, 1]
  382. },
  383. layout: {
  384. randomSeed: [0, 0, 500, 1],
  385. hierarchical: {
  386. enabled: false,
  387. levelSeparation: [150, 20, 500, 5],
  388. direction: ['UD', 'DU', 'LR', 'RL'], // UD, DU, LR, RL
  389. sortMethod: ['hubsize', 'directed'] // hubsize, directed
  390. }
  391. },
  392. interaction: {
  393. dragNodes: true,
  394. dragView: true,
  395. zoomView: true,
  396. hoverEnabled: false,
  397. navigationButtons: false,
  398. tooltipDelay: [300, 0, 1000, 25],
  399. keyboard: {
  400. enabled: false,
  401. speed: {x: [10, 0, 40, 1], y: [10, 0, 40, 1], zoom: [0.02, 0, 0.1, 0.005]},
  402. bindToWindow: true
  403. }
  404. },
  405. manipulation: {
  406. enabled: false,
  407. initiallyActive: false,
  408. locale: ['en', 'nl']
  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. selection: {
  439. selectable: true,
  440. selectConnectedEdges: true
  441. },
  442. rendering: {
  443. hideEdgesOnDrag: false,
  444. hideNodesOnDrag: false
  445. }
  446. };
  447. export {allOptions, configureOptions};