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.

241 lines
7.3 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. snap: {'function': 'function', 'null': 'null'},
  127. start: {date, number, string, moment},
  128. template: {'function': 'function'},
  129. groupTemplate: {'function': 'function'},
  130. visibleFrameTemplate: {string, 'function': 'function'},
  131. tooltipOnItemUpdateTime: {
  132. template: {'function': 'function'},
  133. __type__: { 'boolean': bool, object}
  134. },
  135. timeAxis: {
  136. scale: {string,'undefined': 'undefined'},
  137. step: {number,'undefined': 'undefined'},
  138. __type__: {object}
  139. },
  140. type: {string},
  141. width: {string, number},
  142. zoomable: { 'boolean': bool},
  143. zoomKey: {string: ['ctrlKey', 'altKey', 'metaKey', '']},
  144. zoomMax: {number},
  145. zoomMin: {number},
  146. __type__: {object}
  147. };
  148. let configureOptions = {
  149. global: {
  150. align: ['center', 'left', 'right'],
  151. direction: false,
  152. autoResize: true,
  153. clickToUse: false,
  154. // dataAttributes: ['all'], // FIXME: can be 'all' or string[]
  155. editable: {
  156. add: false,
  157. remove: false,
  158. updateGroup: false,
  159. updateTime: false
  160. },
  161. end: '',
  162. format: {
  163. minorLabels: {
  164. millisecond:'SSS',
  165. second: 's',
  166. minute: 'HH:mm',
  167. hour: 'HH:mm',
  168. weekday: 'ddd D',
  169. day: 'D',
  170. month: 'MMM',
  171. year: 'YYYY'
  172. },
  173. majorLabels: {
  174. millisecond:'HH:mm:ss',
  175. second: 'D MMMM HH:mm',
  176. minute: 'ddd D MMMM',
  177. hour: 'ddd D MMMM',
  178. weekday: 'MMMM YYYY',
  179. day: 'MMMM YYYY',
  180. month: 'YYYY',
  181. year: ''
  182. }
  183. },
  184. //groupOrder: {string, 'function': 'function'},
  185. groupsDraggable: false,
  186. height: '',
  187. //hiddenDates: {object, array},
  188. locale: '',
  189. margin: {
  190. axis: [20, 0, 100, 1],
  191. item: {
  192. horizontal: [10, 0, 100, 1],
  193. vertical: [10, 0, 100, 1]
  194. }
  195. },
  196. max: '',
  197. maxHeight: '',
  198. maxMinorChars: [7, 0, 20, 1],
  199. min: '',
  200. minHeight: '',
  201. moveable: false,
  202. multiselect: false,
  203. multiselectPerGroup: false,
  204. //onAdd: {'function': 'function'},
  205. //onUpdate: {'function': 'function'},
  206. //onMove: {'function': 'function'},
  207. //onMoving: {'function': 'function'},
  208. //onRename: {'function': 'function'},
  209. //order: {'function': 'function'},
  210. orientation: {
  211. axis: ['both', 'bottom', 'top'],
  212. item: ['bottom', 'top']
  213. },
  214. selectable: true,
  215. showCurrentTime: false,
  216. showMajorLabels: true,
  217. showMinorLabels: true,
  218. stack: true,
  219. //snap: {'function': 'function', nada},
  220. start: '',
  221. //template: {'function': 'function'},
  222. //timeAxis: {
  223. // scale: ['millisecond', 'second', 'minute', 'hour', 'weekday', 'day', 'month', 'year'],
  224. // step: [1, 1, 10, 1]
  225. //},
  226. tooltipOnItemUpdateTime: false,
  227. type: ['box', 'point', 'range', 'background'],
  228. width: '100%',
  229. zoomable: true,
  230. zoomKey: ['ctrlKey', 'altKey', 'metaKey', ''],
  231. zoomMax: [315360000000000, 10, 315360000000000, 1],
  232. zoomMin: [10, 10, 315360000000000, 1]
  233. }
  234. };
  235. export {allOptions, configureOptions};