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.

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