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.

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