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.

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