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.

459 lines
12 KiB

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: {
  51. enabled: {boolean},
  52. pattern: {array},
  53. __type__: {boolean,object}
  54. },
  55. font: {
  56. color: {string},
  57. size: {number}, // px
  58. face: {string},
  59. background: {string},
  60. stroke: {number}, // px
  61. strokeColor: {string},
  62. align: {string:['horizontal','top','middle','bottom']},
  63. __type__: {object,string}
  64. },
  65. hidden: {boolean},
  66. hoverWidth: {fn,number},
  67. label: {string,undef},
  68. length: {number,undef},
  69. physics: {boolean},
  70. scaling: {
  71. min: {number},
  72. max: {number},
  73. label: {
  74. enabled: {boolean},
  75. min: {number},
  76. max: {number},
  77. maxVisible: {number},
  78. drawThreshold: {number},
  79. __type__: {object,boolean}
  80. },
  81. customScalingFunction: {fn},
  82. __type__: {object}
  83. },
  84. selectionWidth: {fn,number},
  85. selfReferenceSize: {number},
  86. shadow: {
  87. enabled: {boolean},
  88. size: {number},
  89. x: {number},
  90. y: {number},
  91. __type__: {object,boolean}
  92. },
  93. smooth: {
  94. enabled: {boolean},
  95. dynamic: {boolean},
  96. type: {string},
  97. roundness: {number},
  98. __type__: {object,boolean}
  99. },
  100. title: {string, undef},
  101. width: {number},
  102. value: {number, undef},
  103. __type__: {object}
  104. },
  105. groups: {
  106. useDefaultGroups: {boolean},
  107. __any__: ['__ref__','nodes'],
  108. __type__: {object}
  109. },
  110. interaction: {
  111. dragNodes: {boolean},
  112. dragView: {boolean},
  113. zoomView: {boolean},
  114. hoverEnabled: {boolean},
  115. navigationButtons: {boolean},
  116. tooltipDelay: {number},
  117. keyboard: {
  118. enabled: {boolean},
  119. speed: {x: {number}, y: {number}, zoom: {number}, __type__: {object}},
  120. bindToWindow: {boolean},
  121. __type__: {object,boolean}
  122. },
  123. __type__: {object}
  124. },
  125. layout: {
  126. randomSeed: {undef,number},
  127. hierarchical: {
  128. enabled: {boolean},
  129. levelSeparation: {number},
  130. direction: {string:['UD','DU','LR','RL']}, // UD, DU, LR, RL
  131. sortMethod: {string:['hubsize','directed']}, // hubsize, directed
  132. __type__: {object,boolean}
  133. },
  134. __type__: {object}
  135. },
  136. manipulation: {
  137. enabled: {boolean},
  138. initiallyActive: {boolean},
  139. locale: {string},
  140. locales: {object},
  141. addNode: {boolean,fn},
  142. addEdge: {boolean,fn},
  143. editNode: {fn},
  144. editEdge: {boolean,fn},
  145. deleteNode: {boolean,fn},
  146. deleteEdge: {boolean,fn},
  147. controlNodeStyle: ['__ref__','nodes'],
  148. __type__: {object,boolean}
  149. },
  150. nodes: {
  151. borderWidth: {number},
  152. borderWidthSelected: {number,undef},
  153. brokenImage: {string,undef},
  154. color: {
  155. border: {string},
  156. background: {string},
  157. highlight: {
  158. border: {string},
  159. background: {string},
  160. __type__: {object,string}
  161. },
  162. hover: {
  163. border: {string},
  164. background: {string},
  165. __type__: {object,string}
  166. },
  167. __type__: {object,string}
  168. },
  169. fixed: {
  170. x: {boolean},
  171. y: {boolean},
  172. __type__: {object,boolean}
  173. },
  174. font: {
  175. color: {string},
  176. size: {number}, // px
  177. face: {string},
  178. background: {string},
  179. stroke: {number}, // px
  180. strokeColor: {string},
  181. __type__: {object,string}
  182. },
  183. group: {string,number,undef},
  184. hidden: {boolean},
  185. icon: {
  186. face: {string},
  187. code: {string}, //'\uf007',
  188. size: {number}, //50,
  189. color: {string},
  190. __type__: {object}
  191. },
  192. id: {string, number},
  193. image: {string,undef}, // --> URL
  194. label: {string,undef},
  195. level: {number,undef},
  196. mass: {number},
  197. physics: {boolean},
  198. scaling: {
  199. min: {number},
  200. max: {number},
  201. label: {
  202. enabled: {boolean},
  203. min: {number},
  204. max: {number},
  205. maxVisible: {number},
  206. drawThreshold: {number},
  207. __type__: {object, boolean}
  208. },
  209. customScalingFunction: {fn},
  210. __type__: {object}
  211. },
  212. shadow: {
  213. enabled: {boolean},
  214. size: {number},
  215. x: {number},
  216. y: {number},
  217. __type__: {object,boolean}
  218. },
  219. shape: {string:['ellipse', 'circle', 'database', 'box', 'text','image', 'circularImage','diamond', 'dot', 'star', 'triangle','triangleDown', 'square','icon']},
  220. size: {number},
  221. title: {string,undef},
  222. value: {number,undef},
  223. x: {number},
  224. y: {number},
  225. __type__: {object}
  226. },
  227. physics: {
  228. barnesHut: {
  229. gravitationalConstant: {number},
  230. centralGravity: {number},
  231. springLength: {number},
  232. springConstant: {number},
  233. damping: {number},
  234. __type__: {object}
  235. },
  236. repulsion: {
  237. centralGravity: {number},
  238. springLength: {number},
  239. springConstant: {number},
  240. nodeDistance: {number},
  241. damping: {number},
  242. __type__: {object}
  243. },
  244. hierarchicalRepulsion: {
  245. centralGravity: {number},
  246. springLength: {number},
  247. springConstant: {number},
  248. nodeDistance: {number},
  249. damping: {number},
  250. __type__: {object}
  251. },
  252. maxVelocity: {number},
  253. minVelocity: {number}, // px/s
  254. solver: {string:['barnesHut','repulsion','hierarchicalRepulsion']},
  255. stabilization: {
  256. enabled: {boolean},
  257. iterations: {number}, // maximum number of iteration to stabilize
  258. updateInterval: {number},
  259. onlyDynamicEdges: {boolean},
  260. fit: {boolean},
  261. __type__: {object,boolean}
  262. },
  263. timestep: {number},
  264. __type__: {object,boolean}
  265. },
  266. selection: {
  267. selectable: {boolean},
  268. selectConnectedEdges: {boolean},
  269. __type__: {object}
  270. },
  271. view: {},
  272. __type__: {object}
  273. };
  274. allOptions.groups.__any__ = allOptions.nodes;
  275. allOptions.manipulation.controlNodeStyle = allOptions.nodes;
  276. let configureOptions = {
  277. nodes: {
  278. borderWidth: [1, 0, 10, 1],
  279. borderWidthSelected: [2, 0, 10, 1],
  280. color: {
  281. border: ['color','#2B7CE9'],
  282. background: ['color','#97C2FC'],
  283. highlight: {
  284. border: ['color','#2B7CE9'],
  285. background: ['color','#D2E5FF']
  286. },
  287. hover: {
  288. border: ['color','#2B7CE9'],
  289. background: ['color','#D2E5FF']
  290. }
  291. },
  292. fixed: {
  293. x: false,
  294. y: false
  295. },
  296. font: {
  297. color: ['color','#343434'],
  298. size: [14, 0, 100, 1], // px
  299. face: ['arial', 'verdana', 'tahoma'],
  300. background: ['color','none'],
  301. stroke: [0, 0, 50, 1], // px
  302. strokeColor: ['color','#ffffff']
  303. },
  304. //group: 'string',
  305. hidden: false,
  306. //icon: {
  307. // face: 'string', //'FontAwesome',
  308. // code: 'string', //'\uf007',
  309. // size: [50, 0, 200, 1], //50,
  310. // color: ['color','#2B7CE9'] //'#aa00ff'
  311. //},
  312. //image: 'string', // --> URL
  313. physics: true,
  314. scaling: {
  315. min: [10, 0, 200, 1],
  316. max: [30, 0, 200, 1],
  317. label: {
  318. enabled: true,
  319. min: [14, 0, 200, 1],
  320. max: [30, 0, 200, 1],
  321. maxVisible: [30, 0, 200, 1],
  322. drawThreshold: [3, 0, 20, 1]
  323. }
  324. },
  325. shadow:{
  326. enabled: false,
  327. size:[10, 0, 20, 1],
  328. x:[5, -30, 30, 1],
  329. y:[5, -30, 30, 1]
  330. },
  331. shape: ['ellipse', 'box', 'circle', 'database', 'diamond', 'dot', 'square', 'star', 'text', 'triangle', 'triangleDown'],
  332. size: [25, 0, 200, 1]
  333. },
  334. edges: {
  335. arrows: {
  336. to: {enabled: false, scaleFactor: [1, 0, 3, 0.05]}, // boolean / {arrowScaleFactor:1} / {enabled: false, arrowScaleFactor:1}
  337. middle: {enabled: false, scaleFactor: [1, 0, 3, 0.05]},
  338. from: {enabled: false, scaleFactor: [1, 0, 3, 0.05]}
  339. },
  340. color: {
  341. color: ['color','#848484'],
  342. highlight: ['color','#848484'],
  343. hover: ['color','#848484'],
  344. inherit: ['from','to','both',true, false],
  345. opacity: [1, 0, 1, 0.05]
  346. },
  347. dashes: false,
  348. font: {
  349. color: ['color','#343434'],
  350. size: [14, 0, 100, 1], // px
  351. face: ['arial', 'verdana', 'tahoma'],
  352. background: ['color','none'],
  353. stroke: [1, 0, 50, 1], // px
  354. strokeColor: ['color','#ffffff'],
  355. align: ['horizontal', 'top', 'middle', 'bottom']
  356. },
  357. hidden: false,
  358. hoverWidth: [2, 0, 5, 0.1],
  359. physics: true,
  360. scaling: {
  361. min: [1, 0, 100, 1],
  362. max: [15, 0, 100, 1],
  363. label: {
  364. enabled: true,
  365. min: [14, 0, 200, 1],
  366. max: [30, 0, 200, 1],
  367. maxVisible: [30, 0, 200, 1],
  368. drawThreshold: [3, 0, 20, 1]
  369. }
  370. },
  371. selectionWidth: [1.5, 0, 5, 0.1],
  372. selfReferenceSize: [20, 0, 200, 1],
  373. shadow:{
  374. enabled: false,
  375. size:[10, 0, 20, 1],
  376. x:[5, -30, 30, 1],
  377. y:[5, -30, 30, 1]
  378. },
  379. smooth: {
  380. enabled: true,
  381. dynamic: true,
  382. type: ['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. zoomView: true,
  400. hoverEnabled: false,
  401. navigationButtons: false,
  402. tooltipDelay: [300, 0, 1000, 25],
  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. },
  409. manipulation: {
  410. enabled: false,
  411. initiallyActive: false,
  412. locale: ['en', 'nl']
  413. },
  414. physics: {
  415. barnesHut: {
  416. //theta: [0.5, 0.1, 1, 0.05],
  417. gravitationalConstant: [-2000, -30000, 0, 50],
  418. centralGravity: [0.3, 0, 10, 0.05],
  419. springLength: [95, 0, 500, 5],
  420. springConstant: [0.04, 0, 5, 0.005],
  421. damping: [0.09, 0, 1, 0.01]
  422. },
  423. repulsion: {
  424. centralGravity: [0.2, 0, 10, 0.05],
  425. springLength: [200, 0, 500, 5],
  426. springConstant: [0.05, 0, 5, 0.005],
  427. nodeDistance: [100, 0, 500, 5],
  428. damping: [0.09, 0, 1, 0.01]
  429. },
  430. hierarchicalRepulsion: {
  431. centralGravity: [0.2, 0, 10, 0.05],
  432. springLength: [100, 0, 500, 5],
  433. springConstant: [0.01, 0, 5, 0.005],
  434. nodeDistance: [120, 0, 500, 5],
  435. damping: [0.09, 0, 1, 0.01]
  436. },
  437. maxVelocity: [50, 0, 150, 1],
  438. minVelocity: [0.1, 0.01, 0.5, 0.01],
  439. solver: ['barnesHut', 'repulsion', 'hierarchicalRepulsion'],
  440. timestep: [0.5, 0, 1, 0.05]
  441. },
  442. selection: {
  443. selectable: true,
  444. selectConnectedEdges: true
  445. },
  446. rendering: {
  447. hideEdgesOnDrag: false,
  448. hideNodesOnDrag: false
  449. }
  450. };
  451. export {allOptions, configureOptions};