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.

252 lines
7.6 KiB

  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 bool = 'boolean';
  10. let number = 'number';
  11. let array = 'array';
  12. let date = 'date';
  13. let object = 'object'; // should only be in a __type__ property
  14. let dom = 'dom';
  15. let moment = 'moment';
  16. let any = 'any';
  17. let allOptions = {
  18. configure: {
  19. enabled: { 'boolean': bool},
  20. filter: { 'boolean': bool,'function': 'function'},
  21. container: {dom},
  22. __type__: {object, 'boolean': bool,'function': 'function'}
  23. },
  24. //globals :
  25. align: {string},
  26. rtl: { 'boolean': bool, 'undefined': 'undefined'},
  27. rollingMode: { 'boolean': bool, 'undefined': 'undefined'},
  28. verticalScroll: { 'boolean': bool, 'undefined': 'undefined'},
  29. horizontalScroll: { 'boolean': bool, 'undefined': 'undefined'},
  30. autoResize: { 'boolean': bool},
  31. throttleRedraw: {number}, // TODO: DEPRICATED see https://github.com/almende/vis/issues/2511
  32. clickToUse: { 'boolean': bool},
  33. dataAttributes: {string, array},
  34. editable: {
  35. add: { 'boolean': bool, 'undefined': 'undefined'},
  36. remove: { 'boolean': bool, 'undefined': 'undefined'},
  37. updateGroup: { 'boolean': bool, 'undefined': 'undefined'},
  38. updateTime: { 'boolean': bool, 'undefined': 'undefined'},
  39. overrideItems: { 'boolean': bool, 'undefined': 'undefined'},
  40. __type__: { 'boolean': bool, object}
  41. },
  42. end: {number, date, string, moment},
  43. format: {
  44. minorLabels: {
  45. millisecond: {string,'undefined': 'undefined'},
  46. second: {string,'undefined': 'undefined'},
  47. minute: {string,'undefined': 'undefined'},
  48. hour: {string,'undefined': 'undefined'},
  49. weekday: {string,'undefined': 'undefined'},
  50. day: {string,'undefined': 'undefined'},
  51. month: {string,'undefined': 'undefined'},
  52. year: {string,'undefined': 'undefined'},
  53. __type__: {object, 'function': 'function'}
  54. },
  55. majorLabels: {
  56. millisecond: {string,'undefined': 'undefined'},
  57. second: {string,'undefined': 'undefined'},
  58. minute: {string,'undefined': 'undefined'},
  59. hour: {string,'undefined': 'undefined'},
  60. weekday: {string,'undefined': 'undefined'},
  61. day: {string,'undefined': 'undefined'},
  62. month: {string,'undefined': 'undefined'},
  63. year: {string,'undefined': 'undefined'},
  64. __type__: {object, 'function': 'function'}
  65. },
  66. __type__: {object}
  67. },
  68. moment: {'function': 'function'},
  69. groupOrder: {string, 'function': 'function'},
  70. groupEditable: {
  71. add: { 'boolean': bool, 'undefined': 'undefined'},
  72. remove: { 'boolean': bool, 'undefined': 'undefined'},
  73. order: { 'boolean': bool, 'undefined': 'undefined'},
  74. __type__: { 'boolean': bool, object}
  75. },
  76. groupOrderSwap: {'function': 'function'},
  77. height: {string, number},
  78. hiddenDates: {
  79. start: {date, number, string, moment},
  80. end: {date, number, string, moment},
  81. repeat: {string},
  82. __type__: {object, array}
  83. },
  84. itemsAlwaysDraggable: { 'boolean': bool},
  85. locale:{string},
  86. locales:{
  87. __any__: {any},
  88. __type__: {object}
  89. },
  90. margin: {
  91. axis: {number},
  92. item: {
  93. horizontal: {number,'undefined': 'undefined'},
  94. vertical: {number,'undefined': 'undefined'},
  95. __type__: {object,number}
  96. },
  97. __type__: {object,number}
  98. },
  99. max: {date, number, string, moment},
  100. maxHeight: {number, string},
  101. maxMinorChars: {number},
  102. min: {date, number, string, moment},
  103. minHeight: {number, string},
  104. moveable: { 'boolean': bool},
  105. multiselect: { 'boolean': bool},
  106. multiselectPerGroup: { 'boolean': bool},
  107. onAdd: {'function': 'function'},
  108. onUpdate: {'function': 'function'},
  109. onMove: {'function': 'function'},
  110. onMoving: {'function': 'function'},
  111. onRemove: {'function': 'function'},
  112. onAddGroup: {'function': 'function'},
  113. onMoveGroup: {'function': 'function'},
  114. onRemoveGroup: {'function': 'function'},
  115. order: {'function': 'function'},
  116. orientation: {
  117. axis: {string,'undefined': 'undefined'},
  118. item: {string,'undefined': 'undefined'},
  119. __type__: {string, object}
  120. },
  121. selectable: { 'boolean': bool},
  122. showCurrentTime: { 'boolean': bool},
  123. showMajorLabels: { 'boolean': bool},
  124. showMinorLabels: { 'boolean': bool},
  125. stack: { 'boolean': bool},
  126. stackSubgroups: { 'boolean': bool},
  127. snap: {'function': 'function', 'null': 'null'},
  128. start: {date, number, string, moment},
  129. template: {'function': 'function'},
  130. groupTemplate: {'function': 'function'},
  131. visibleFrameTemplate: {string, 'function': 'function'},
  132. tooltip: {
  133. followMouse: { 'boolean': bool },
  134. overflowMethod: { 'string': ['cap', 'flip'] },
  135. __type__: {object}
  136. },
  137. tooltipOnItemUpdateTime: {
  138. template: {'function': 'function'},
  139. __type__: { 'boolean': bool, object}
  140. },
  141. timeAxis: {
  142. scale: {string,'undefined': 'undefined'},
  143. step: {number,'undefined': 'undefined'},
  144. __type__: {object}
  145. },
  146. type: {string},
  147. width: {string, number},
  148. zoomable: { 'boolean': bool},
  149. zoomKey: {string: ['ctrlKey', 'altKey', 'metaKey', '']},
  150. zoomMax: {number},
  151. zoomMin: {number},
  152. __type__: {object}
  153. };
  154. let configureOptions = {
  155. global: {
  156. align: ['center', 'left', 'right'],
  157. direction: false,
  158. autoResize: true,
  159. clickToUse: false,
  160. // dataAttributes: ['all'], // FIXME: can be 'all' or string[]
  161. editable: {
  162. add: false,
  163. remove: false,
  164. updateGroup: false,
  165. updateTime: false
  166. },
  167. end: '',
  168. format: {
  169. minorLabels: {
  170. millisecond:'SSS',
  171. second: 's',
  172. minute: 'HH:mm',
  173. hour: 'HH:mm',
  174. weekday: 'ddd D',
  175. day: 'D',
  176. month: 'MMM',
  177. year: 'YYYY'
  178. },
  179. majorLabels: {
  180. millisecond:'HH:mm:ss',
  181. second: 'D MMMM HH:mm',
  182. minute: 'ddd D MMMM',
  183. hour: 'ddd D MMMM',
  184. weekday: 'MMMM YYYY',
  185. day: 'MMMM YYYY',
  186. month: 'YYYY',
  187. year: ''
  188. }
  189. },
  190. //groupOrder: {string, 'function': 'function'},
  191. groupsDraggable: false,
  192. height: '',
  193. //hiddenDates: {object, array},
  194. locale: '',
  195. margin: {
  196. axis: [20, 0, 100, 1],
  197. item: {
  198. horizontal: [10, 0, 100, 1],
  199. vertical: [10, 0, 100, 1]
  200. }
  201. },
  202. max: '',
  203. maxHeight: '',
  204. maxMinorChars: [7, 0, 20, 1],
  205. min: '',
  206. minHeight: '',
  207. moveable: false,
  208. multiselect: false,
  209. multiselectPerGroup: false,
  210. //onAdd: {'function': 'function'},
  211. //onUpdate: {'function': 'function'},
  212. //onMove: {'function': 'function'},
  213. //onMoving: {'function': 'function'},
  214. //onRename: {'function': 'function'},
  215. //order: {'function': 'function'},
  216. orientation: {
  217. axis: ['both', 'bottom', 'top'],
  218. item: ['bottom', 'top']
  219. },
  220. selectable: true,
  221. showCurrentTime: false,
  222. showMajorLabels: true,
  223. showMinorLabels: true,
  224. stack: true,
  225. stackSubgroups: true,
  226. //snap: {'function': 'function', nada},
  227. start: '',
  228. //template: {'function': 'function'},
  229. //timeAxis: {
  230. // scale: ['millisecond', 'second', 'minute', 'hour', 'weekday', 'day', 'month', 'year'],
  231. // step: [1, 1, 10, 1]
  232. //},
  233. tooltip: {
  234. followMouse: false,
  235. overflowMethod: 'flip'
  236. },
  237. tooltipOnItemUpdateTime: false,
  238. type: ['box', 'point', 'range', 'background'],
  239. width: '100%',
  240. zoomable: true,
  241. zoomKey: ['ctrlKey', 'altKey', 'metaKey', ''],
  242. zoomMax: [315360000000000, 10, 315360000000000, 1],
  243. zoomMin: [10, 10, 315360000000000, 1]
  244. }
  245. };
  246. export {allOptions, configureOptions};