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.

494 lines
14 KiB

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 any = 'any';
  15. let allOptions = {
  16. configure: {
  17. enabled: { boolean },
  18. filter: { boolean, string, array, 'function': 'function' },
  19. container: { dom },
  20. showButton: { boolean },
  21. __type__: { object, boolean, string, array, 'function': 'function' }
  22. },
  23. edges: {
  24. arrows: {
  25. to: { enabled: { boolean }, scaleFactor: { number }, __type__: { object, boolean } },
  26. middle: { enabled: { boolean }, scaleFactor: { number }, __type__: { object, boolean } },
  27. from: { enabled: { boolean }, scaleFactor: { number }, __type__: { object, boolean } },
  28. __type__: { string: ['from', 'to', 'middle'], object }
  29. },
  30. color: {
  31. color: { string },
  32. highlight: { string },
  33. hover: { string },
  34. inherit: { string: ['from', 'to', 'both'], boolean },
  35. opacity: { number },
  36. __type__: { object, string }
  37. },
  38. dashes: { boolean, array },
  39. font: {
  40. color: { string },
  41. size: { number }, // px
  42. face: { string },
  43. background: { string },
  44. strokeWidth: { number }, // px
  45. strokeColor: { string },
  46. align: { string: ['horizontal', 'top', 'middle', 'bottom'] },
  47. __type__: { object, string }
  48. },
  49. hidden: { boolean },
  50. hoverWidth: { 'function': 'function', number },
  51. label: { string, 'undefined': 'undefined' },
  52. labelHighlightBold: { boolean },
  53. length: { number, 'undefined': 'undefined' },
  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: { 'function': 'function' },
  67. __type__: { object }
  68. },
  69. selectionWidth: { 'function': 'function', 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', 'cubicBezier'] },
  81. roundness: { number },
  82. forceDirection: { string: ['horizontal', 'vertical', 'none'], boolean },
  83. __type__: { object, boolean }
  84. },
  85. title: { string, 'undefined': 'undefined' },
  86. width: { number },
  87. value: { number, 'undefined': 'undefined' },
  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. hover: { 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. hoverConnectedEdges: { boolean },
  112. tooltipDelay: { number },
  113. zoomView: { boolean },
  114. __type__: { object }
  115. },
  116. layout: {
  117. randomSeed: { 'undefined': 'undefined', number },
  118. improvedLayout: { boolean },
  119. hierarchical: {
  120. enabled: { boolean },
  121. levelSeparation: { number },
  122. direction: { string: ['UD', 'DU', 'LR', 'RL'] }, // UD, DU, LR, RL
  123. sortMethod: { string: ['hubsize', 'directed'] }, // hubsize, directed
  124. __type__: { object, boolean }
  125. },
  126. __type__: { object }
  127. },
  128. manipulation: {
  129. enabled: { boolean },
  130. initiallyActive: { boolean },
  131. addNode: { boolean, 'function': 'function' },
  132. addEdge: { boolean, 'function': 'function' },
  133. editNode: { 'function': 'function' },
  134. editEdge: { boolean, 'function': 'function' },
  135. deleteNode: { boolean, 'function': 'function' },
  136. deleteEdge: { boolean, 'function': 'function' },
  137. controlNodeStyle: 'get from nodes, will be overwritten below',
  138. __type__: { object, boolean }
  139. },
  140. nodes: {
  141. borderWidth: { number },
  142. borderWidthSelected: { number, 'undefined': 'undefined' },
  143. brokenImage: { string, 'undefined': 'undefined' },
  144. color: {
  145. border: { string },
  146. background: { string },
  147. highlight: {
  148. border: { string },
  149. background: { string },
  150. __type__: { object, string }
  151. },
  152. hover: {
  153. border: { string },
  154. background: { string },
  155. __type__: { object, string }
  156. },
  157. __type__: { object, string }
  158. },
  159. fixed: {
  160. x: { boolean },
  161. y: { boolean },
  162. __type__: { object, boolean }
  163. },
  164. font: {
  165. color: { string },
  166. size: { number }, // px
  167. face: { string },
  168. background: { string },
  169. strokeWidth: { number }, // px
  170. strokeColor: { string },
  171. __type__: { object, string }
  172. },
  173. group: { string, number, 'undefined': 'undefined' },
  174. hidden: { boolean },
  175. icon: {
  176. face: { string },
  177. code: { string }, //'\uf007',
  178. size: { number }, //50,
  179. color: { string },
  180. __type__: { object }
  181. },
  182. id: { string, number },
  183. image: { string, 'undefined': 'undefined' }, // --> URL
  184. label: { string, 'undefined': 'undefined' },
  185. labelHighlightBold: { boolean },
  186. level: { number, 'undefined': 'undefined' },
  187. mass: { number },
  188. physics: { boolean },
  189. scaling: {
  190. min: { number },
  191. max: { number },
  192. label: {
  193. enabled: { boolean },
  194. min: { number },
  195. max: { number },
  196. maxVisible: { number },
  197. drawThreshold: { number },
  198. __type__: { object, boolean }
  199. },
  200. customScalingFunction: { 'function': 'function' },
  201. __type__: { object }
  202. },
  203. shadow: {
  204. enabled: { boolean },
  205. size: { number },
  206. x: { number },
  207. y: { number },
  208. __type__: { object, boolean }
  209. },
  210. shape: { string: ['ellipse', 'circle', 'database', 'box', 'text', 'image', 'circularImage', 'diamond', 'dot', 'star', 'triangle', 'triangleDown', 'square', 'icon'] },
  211. shapeProperties: {
  212. borderDashes: { boolean, array },
  213. borderRadius: { number },
  214. useImageSize: { boolean },
  215. useBorderWithImage: { boolean },
  216. __type__: { object }
  217. },
  218. size: { number },
  219. title: { string, 'undefined': 'undefined' },
  220. value: { number, 'undefined': 'undefined' },
  221. x: { number },
  222. y: { number },
  223. __type__: { object }
  224. },
  225. physics: {
  226. enabled: { boolean },
  227. barnesHut: {
  228. gravitationalConstant: { number },
  229. centralGravity: { number },
  230. springLength: { number },
  231. springConstant: { number },
  232. damping: { number },
  233. avoidOverlap: { number },
  234. __type__: { object }
  235. },
  236. forceAtlas2Based: {
  237. gravitationalConstant: { number },
  238. centralGravity: { number },
  239. springLength: { number },
  240. springConstant: { number },
  241. damping: { number },
  242. avoidOverlap: { number },
  243. __type__: { object }
  244. },
  245. repulsion: {
  246. centralGravity: { number },
  247. springLength: { number },
  248. springConstant: { number },
  249. nodeDistance: { number },
  250. damping: { number },
  251. __type__: { object }
  252. },
  253. hierarchicalRepulsion: {
  254. centralGravity: { number },
  255. springLength: { number },
  256. springConstant: { number },
  257. nodeDistance: { number },
  258. damping: { number },
  259. __type__: { object }
  260. },
  261. maxVelocity: { number },
  262. minVelocity: { number }, // px/s
  263. solver: { string: ['barnesHut', 'repulsion', 'hierarchicalRepulsion', 'forceAtlas2Based'] },
  264. stabilization: {
  265. enabled: { boolean },
  266. iterations: { number }, // maximum number of iteration to stabilize
  267. updateInterval: { number },
  268. onlyDynamicEdges: { boolean },
  269. fit: { boolean },
  270. __type__: { object, boolean }
  271. },
  272. timestep: { number },
  273. adaptiveTimestep: { boolean },
  274. __type__: { object, boolean }
  275. },
  276. //globals :
  277. autoResize: { boolean },
  278. clickToUse: { boolean },
  279. locale: { string },
  280. locales: {
  281. __any__: { any },
  282. __type__: { object }
  283. },
  284. height: { string },
  285. width: { string },
  286. __type__: { object }
  287. };
  288. allOptions.groups.__any__ = allOptions.nodes;
  289. allOptions.manipulation.controlNodeStyle = allOptions.nodes;
  290. let configureOptions = {
  291. nodes: {
  292. borderWidth: [1, 0, 10, 1],
  293. borderWidthSelected: [2, 0, 10, 1],
  294. color: {
  295. border: ['color', '#2B7CE9'],
  296. background: ['color', '#97C2FC'],
  297. highlight: {
  298. border: ['color', '#2B7CE9'],
  299. background: ['color', '#D2E5FF']
  300. },
  301. hover: {
  302. border: ['color', '#2B7CE9'],
  303. background: ['color', '#D2E5FF']
  304. }
  305. },
  306. fixed: {
  307. x: false,
  308. y: false
  309. },
  310. font: {
  311. color: ['color', '#343434'],
  312. size: [14, 0, 100, 1], // px
  313. face: ['arial', 'verdana', 'tahoma'],
  314. background: ['color', 'none'],
  315. strokeWidth: [0, 0, 50, 1], // px
  316. strokeColor: ['color', '#ffffff']
  317. },
  318. //group: 'string',
  319. hidden: false,
  320. labelHighlightBold: true,
  321. //icon: {
  322. // face: 'string', //'FontAwesome',
  323. // code: 'string', //'\uf007',
  324. // size: [50, 0, 200, 1], //50,
  325. // color: ['color','#2B7CE9'] //'#aa00ff'
  326. //},
  327. //image: 'string', // --> URL
  328. physics: true,
  329. scaling: {
  330. min: [10, 0, 200, 1],
  331. max: [30, 0, 200, 1],
  332. label: {
  333. enabled: false,
  334. min: [14, 0, 200, 1],
  335. max: [30, 0, 200, 1],
  336. maxVisible: [30, 0, 200, 1],
  337. drawThreshold: [5, 0, 20, 1]
  338. }
  339. },
  340. shadow: {
  341. enabled: false,
  342. size: [10, 0, 20, 1],
  343. x: [5, -30, 30, 1],
  344. y: [5, -30, 30, 1]
  345. },
  346. shape: ['ellipse', 'box', 'circle', 'database', 'diamond', 'dot', 'square', 'star', 'text', 'triangle', 'triangleDown'],
  347. shapeProperties: {
  348. borderDashes: false,
  349. borderRadius: [6, 0, 20, 1],
  350. useImageSize: false
  351. },
  352. size: [25, 0, 200, 1]
  353. },
  354. edges: {
  355. arrows: {
  356. to: { enabled: false, scaleFactor: [1, 0, 3, 0.05] }, // boolean / {arrowScaleFactor:1} / {enabled: false, arrowScaleFactor:1}
  357. middle: { enabled: false, scaleFactor: [1, 0, 3, 0.05] },
  358. from: { enabled: false, scaleFactor: [1, 0, 3, 0.05] }
  359. },
  360. color: {
  361. color: ['color', '#848484'],
  362. highlight: ['color', '#848484'],
  363. hover: ['color', '#848484'],
  364. inherit: ['from', 'to', 'both', true, false],
  365. opacity: [1, 0, 1, 0.05]
  366. },
  367. dashes: false,
  368. font: {
  369. color: ['color', '#343434'],
  370. size: [14, 0, 100, 1], // px
  371. face: ['arial', 'verdana', 'tahoma'],
  372. background: ['color', 'none'],
  373. strokeWidth: [2, 0, 50, 1], // px
  374. strokeColor: ['color', '#ffffff'],
  375. align: ['horizontal', 'top', 'middle', 'bottom']
  376. },
  377. hidden: false,
  378. hoverWidth: [1.5, 0, 5, 0.1],
  379. labelHighlightBold: true,
  380. physics: true,
  381. scaling: {
  382. min: [1, 0, 100, 1],
  383. max: [15, 0, 100, 1],
  384. label: {
  385. enabled: true,
  386. min: [14, 0, 200, 1],
  387. max: [30, 0, 200, 1],
  388. maxVisible: [30, 0, 200, 1],
  389. drawThreshold: [5, 0, 20, 1]
  390. }
  391. },
  392. selectionWidth: [1.5, 0, 5, 0.1],
  393. selfReferenceSize: [20, 0, 200, 1],
  394. shadow: {
  395. enabled: false,
  396. size: [10, 0, 20, 1],
  397. x: [5, -30, 30, 1],
  398. y: [5, -30, 30, 1]
  399. },
  400. smooth: {
  401. enabled: true,
  402. type: ['dynamic', 'continuous', 'discrete', 'diagonalCross', 'straightCross', 'horizontal', 'vertical', 'curvedCW', 'curvedCCW', 'cubicBezier'],
  403. forceDirection: ['horizontal', 'vertical', 'none'],
  404. roundness: [0.5, 0, 1, 0.05]
  405. },
  406. width: [1, 0, 30, 1]
  407. },
  408. layout: {
  409. //randomSeed: [0, 0, 500, 1],
  410. //improvedLayout: true,
  411. hierarchical: {
  412. enabled: false,
  413. levelSeparation: [150, 20, 500, 5],
  414. direction: ['UD', 'DU', 'LR', 'RL'], // UD, DU, LR, RL
  415. sortMethod: ['hubsize', 'directed'] // hubsize, directed
  416. }
  417. },
  418. interaction: {
  419. dragNodes: true,
  420. dragView: true,
  421. hideEdgesOnDrag: false,
  422. hideNodesOnDrag: false,
  423. hover: false,
  424. keyboard: {
  425. enabled: false,
  426. speed: { x: [10, 0, 40, 1], y: [10, 0, 40, 1], zoom: [0.02, 0, 0.1, 0.005] },
  427. bindToWindow: true
  428. },
  429. multiselect: false,
  430. navigationButtons: false,
  431. selectable: true,
  432. selectConnectedEdges: true,
  433. hoverConnectedEdges: true,
  434. tooltipDelay: [300, 0, 1000, 25],
  435. zoomView: true
  436. },
  437. manipulation: {
  438. enabled: false,
  439. initiallyActive: false
  440. },
  441. physics: {
  442. enabled: true,
  443. barnesHut: {
  444. //theta: [0.5, 0.1, 1, 0.05],
  445. gravitationalConstant: [-2000, -30000, 0, 50],
  446. centralGravity: [0.3, 0, 10, 0.05],
  447. springLength: [95, 0, 500, 5],
  448. springConstant: [0.04, 0, 1.2, 0.005],
  449. damping: [0.09, 0, 1, 0.01],
  450. avoidOverlap: [0, 0, 1, 0.01]
  451. },
  452. forceAtlas2Based: {
  453. //theta: [0.5, 0.1, 1, 0.05],
  454. gravitationalConstant: [-50, -500, 0, 1],
  455. centralGravity: [0.01, 0, 1, 0.005],
  456. springLength: [95, 0, 500, 5],
  457. springConstant: [0.08, 0, 1.2, 0.005],
  458. damping: [0.4, 0, 1, 0.01],
  459. avoidOverlap: [0, 0, 1, 0.01]
  460. },
  461. repulsion: {
  462. centralGravity: [0.2, 0, 10, 0.05],
  463. springLength: [200, 0, 500, 5],
  464. springConstant: [0.05, 0, 1.2, 0.005],
  465. nodeDistance: [100, 0, 500, 5],
  466. damping: [0.09, 0, 1, 0.01]
  467. },
  468. hierarchicalRepulsion: {
  469. centralGravity: [0.2, 0, 10, 0.05],
  470. springLength: [100, 0, 500, 5],
  471. springConstant: [0.01, 0, 1.2, 0.005],
  472. nodeDistance: [120, 0, 500, 5],
  473. damping: [0.09, 0, 1, 0.01]
  474. },
  475. maxVelocity: [50, 0, 150, 1],
  476. minVelocity: [0.1, 0.01, 0.5, 0.01],
  477. solver: ['barnesHut', 'forceAtlas2Based', 'repulsion', 'hierarchicalRepulsion'],
  478. timestep: [0.5, 0.01, 1, 0.01],
  479. //adaptiveTimestep: true
  480. },
  481. global: {
  482. locale: ['en', 'nl']
  483. }
  484. };
  485. export {allOptions, configureOptions};