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.

518 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. margin: {
  199. top: { number },
  200. right: { number },
  201. bottom: { number },
  202. left: { number },
  203. __type__: { object, number }
  204. },
  205. mass: { number },
  206. physics: { boolean },
  207. scaling: {
  208. min: { number },
  209. max: { number },
  210. label: {
  211. enabled: { boolean },
  212. min: { number },
  213. max: { number },
  214. maxVisible: { number },
  215. drawThreshold: { number },
  216. __type__: { object, boolean }
  217. },
  218. customScalingFunction: { 'function': 'function' },
  219. __type__: { object }
  220. },
  221. shadow: {
  222. enabled: { boolean },
  223. color: { string },
  224. size: { number },
  225. x: { number },
  226. y: { number },
  227. __type__: { object, boolean }
  228. },
  229. shape: { string: ['ellipse', 'circle', 'database', 'box', 'text', 'image', 'circularImage', 'diamond', 'dot', 'star', 'triangle', 'triangleDown', 'square', 'icon'] },
  230. shapeProperties: {
  231. borderDashes: { boolean, array },
  232. borderRadius: { number },
  233. interpolation: { boolean },
  234. useImageSize: { boolean },
  235. useBorderWithImage: { boolean },
  236. __type__: { object }
  237. },
  238. size: { number },
  239. title: { string, 'undefined': 'undefined' },
  240. value: { number, 'undefined': 'undefined' },
  241. x: { number },
  242. y: { number },
  243. __type__: { object }
  244. },
  245. physics: {
  246. enabled: { boolean },
  247. barnesHut: {
  248. gravitationalConstant: { number },
  249. centralGravity: { number },
  250. springLength: { number },
  251. springConstant: { number },
  252. damping: { number },
  253. avoidOverlap: { number },
  254. __type__: { object }
  255. },
  256. forceAtlas2Based: {
  257. gravitationalConstant: { number },
  258. centralGravity: { number },
  259. springLength: { number },
  260. springConstant: { number },
  261. damping: { number },
  262. avoidOverlap: { number },
  263. __type__: { object }
  264. },
  265. repulsion: {
  266. centralGravity: { number },
  267. springLength: { number },
  268. springConstant: { number },
  269. nodeDistance: { number },
  270. damping: { number },
  271. __type__: { object }
  272. },
  273. hierarchicalRepulsion: {
  274. centralGravity: { number },
  275. springLength: { number },
  276. springConstant: { number },
  277. nodeDistance: { number },
  278. damping: { number },
  279. __type__: { object }
  280. },
  281. maxVelocity: { number },
  282. minVelocity: { number }, // px/s
  283. solver: { string: ['barnesHut', 'repulsion', 'hierarchicalRepulsion', 'forceAtlas2Based'] },
  284. stabilization: {
  285. enabled: { boolean },
  286. iterations: { number }, // maximum number of iteration to stabilize
  287. updateInterval: { number },
  288. onlyDynamicEdges: { boolean },
  289. fit: { boolean },
  290. __type__: { object, boolean }
  291. },
  292. timestep: { number },
  293. adaptiveTimestep: { boolean },
  294. __type__: { object, boolean }
  295. },
  296. //globals :
  297. autoResize: { boolean },
  298. clickToUse: { boolean },
  299. locale: { string },
  300. locales: {
  301. __any__: { any },
  302. __type__: { object }
  303. },
  304. height: { string },
  305. width: { string },
  306. __type__: { object }
  307. };
  308. allOptions.groups.__any__ = allOptions.nodes;
  309. allOptions.manipulation.controlNodeStyle = allOptions.nodes;
  310. let configureOptions = {
  311. nodes: {
  312. borderWidth: [1, 0, 10, 1],
  313. borderWidthSelected: [2, 0, 10, 1],
  314. color: {
  315. border: ['color', '#2B7CE9'],
  316. background: ['color', '#97C2FC'],
  317. highlight: {
  318. border: ['color', '#2B7CE9'],
  319. background: ['color', '#D2E5FF']
  320. },
  321. hover: {
  322. border: ['color', '#2B7CE9'],
  323. background: ['color', '#D2E5FF']
  324. }
  325. },
  326. fixed: {
  327. x: false,
  328. y: false
  329. },
  330. font: {
  331. color: ['color', '#343434'],
  332. size: [14, 0, 100, 1], // px
  333. face: ['arial', 'verdana', 'tahoma'],
  334. background: ['color', 'none'],
  335. strokeWidth: [0, 0, 50, 1], // px
  336. strokeColor: ['color', '#ffffff']
  337. },
  338. //group: 'string',
  339. hidden: false,
  340. labelHighlightBold: true,
  341. //icon: {
  342. // face: 'string', //'FontAwesome',
  343. // code: 'string', //'\uf007',
  344. // size: [50, 0, 200, 1], //50,
  345. // color: ['color','#2B7CE9'] //'#aa00ff'
  346. //},
  347. //image: 'string', // --> URL
  348. physics: true,
  349. scaling: {
  350. min: [10, 0, 200, 1],
  351. max: [30, 0, 200, 1],
  352. label: {
  353. enabled: false,
  354. min: [14, 0, 200, 1],
  355. max: [30, 0, 200, 1],
  356. maxVisible: [30, 0, 200, 1],
  357. drawThreshold: [5, 0, 20, 1]
  358. }
  359. },
  360. shadow: {
  361. enabled: false,
  362. color: 'rgba(0,0,0,0.5)',
  363. size: [10, 0, 20, 1],
  364. x: [5, -30, 30, 1],
  365. y: [5, -30, 30, 1]
  366. },
  367. shape: ['ellipse', 'box', 'circle', 'database', 'diamond', 'dot', 'square', 'star', 'text', 'triangle', 'triangleDown'],
  368. shapeProperties: {
  369. borderDashes: false,
  370. borderRadius: [6, 0, 20, 1],
  371. interpolation: true,
  372. useImageSize: false
  373. },
  374. size: [25, 0, 200, 1]
  375. },
  376. edges: {
  377. arrows: {
  378. to: { enabled: false, scaleFactor: [1, 0, 3, 0.05], type: 'arrow' },
  379. middle: { enabled: false, scaleFactor: [1, 0, 3, 0.05], type: 'arrow' },
  380. from: { enabled: false, scaleFactor: [1, 0, 3, 0.05], type: 'arrow' }
  381. },
  382. arrowStrikethrough: true,
  383. color: {
  384. color: ['color', '#848484'],
  385. highlight: ['color', '#848484'],
  386. hover: ['color', '#848484'],
  387. inherit: ['from', 'to', 'both', true, false],
  388. opacity: [1, 0, 1, 0.05]
  389. },
  390. dashes: false,
  391. font: {
  392. color: ['color', '#343434'],
  393. size: [14, 0, 100, 1], // px
  394. face: ['arial', 'verdana', 'tahoma'],
  395. background: ['color', 'none'],
  396. strokeWidth: [2, 0, 50, 1], // px
  397. strokeColor: ['color', '#ffffff'],
  398. align: ['horizontal', 'top', 'middle', 'bottom']
  399. },
  400. hidden: false,
  401. hoverWidth: [1.5, 0, 5, 0.1],
  402. labelHighlightBold: true,
  403. physics: true,
  404. scaling: {
  405. min: [1, 0, 100, 1],
  406. max: [15, 0, 100, 1],
  407. label: {
  408. enabled: true,
  409. min: [14, 0, 200, 1],
  410. max: [30, 0, 200, 1],
  411. maxVisible: [30, 0, 200, 1],
  412. drawThreshold: [5, 0, 20, 1]
  413. }
  414. },
  415. selectionWidth: [1.5, 0, 5, 0.1],
  416. selfReferenceSize: [20, 0, 200, 1],
  417. shadow: {
  418. enabled: false,
  419. color: 'rgba(0,0,0,0.5)',
  420. size: [10, 0, 20, 1],
  421. x: [5, -30, 30, 1],
  422. y: [5, -30, 30, 1]
  423. },
  424. smooth: {
  425. enabled: true,
  426. type: ['dynamic', 'continuous', 'discrete', 'diagonalCross', 'straightCross', 'horizontal', 'vertical', 'curvedCW', 'curvedCCW', 'cubicBezier'],
  427. forceDirection: ['horizontal', 'vertical', 'none'],
  428. roundness: [0.5, 0, 1, 0.05]
  429. },
  430. width: [1, 0, 30, 1]
  431. },
  432. layout: {
  433. //randomSeed: [0, 0, 500, 1],
  434. //improvedLayout: true,
  435. hierarchical: {
  436. enabled: false,
  437. levelSeparation: [150, 20, 500, 5],
  438. nodeSpacing: [100, 20, 500, 5],
  439. treeSpacing: [200, 20, 500, 5],
  440. blockShifting: true,
  441. edgeMinimization: true,
  442. parentCentralization: true,
  443. direction: ['UD', 'DU', 'LR', 'RL'], // UD, DU, LR, RL
  444. sortMethod: ['hubsize', 'directed'] // hubsize, directed
  445. }
  446. },
  447. interaction: {
  448. dragNodes: true,
  449. dragView: true,
  450. hideEdgesOnDrag: false,
  451. hideNodesOnDrag: false,
  452. hover: false,
  453. keyboard: {
  454. enabled: false,
  455. speed: { x: [10, 0, 40, 1], y: [10, 0, 40, 1], zoom: [0.02, 0, 0.1, 0.005] },
  456. bindToWindow: true
  457. },
  458. multiselect: false,
  459. navigationButtons: false,
  460. selectable: true,
  461. selectConnectedEdges: true,
  462. hoverConnectedEdges: true,
  463. tooltipDelay: [300, 0, 1000, 25],
  464. zoomView: true
  465. },
  466. manipulation: {
  467. enabled: false,
  468. initiallyActive: false
  469. },
  470. physics: {
  471. enabled: true,
  472. barnesHut: {
  473. //theta: [0.5, 0.1, 1, 0.05],
  474. gravitationalConstant: [-2000, -30000, 0, 50],
  475. centralGravity: [0.3, 0, 10, 0.05],
  476. springLength: [95, 0, 500, 5],
  477. springConstant: [0.04, 0, 1.2, 0.005],
  478. damping: [0.09, 0, 1, 0.01],
  479. avoidOverlap: [0, 0, 1, 0.01]
  480. },
  481. forceAtlas2Based: {
  482. //theta: [0.5, 0.1, 1, 0.05],
  483. gravitationalConstant: [-50, -500, 0, 1],
  484. centralGravity: [0.01, 0, 1, 0.005],
  485. springLength: [95, 0, 500, 5],
  486. springConstant: [0.08, 0, 1.2, 0.005],
  487. damping: [0.4, 0, 1, 0.01],
  488. avoidOverlap: [0, 0, 1, 0.01]
  489. },
  490. repulsion: {
  491. centralGravity: [0.2, 0, 10, 0.05],
  492. springLength: [200, 0, 500, 5],
  493. springConstant: [0.05, 0, 1.2, 0.005],
  494. nodeDistance: [100, 0, 500, 5],
  495. damping: [0.09, 0, 1, 0.01]
  496. },
  497. hierarchicalRepulsion: {
  498. centralGravity: [0.2, 0, 10, 0.05],
  499. springLength: [100, 0, 500, 5],
  500. springConstant: [0.01, 0, 1.2, 0.005],
  501. nodeDistance: [120, 0, 500, 5],
  502. damping: [0.09, 0, 1, 0.01]
  503. },
  504. maxVelocity: [50, 0, 150, 1],
  505. minVelocity: [0.1, 0.01, 0.5, 0.01],
  506. solver: ['barnesHut', 'forceAtlas2Based', 'repulsion', 'hierarchicalRepulsion'],
  507. timestep: [0.5, 0.01, 1, 0.01],
  508. //adaptiveTimestep: true
  509. }
  510. };
  511. export {allOptions, configureOptions};