VisualizationAPI.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. /**
  4. * Licensed Materials - Property of IBM
  5. * IBM Business Analytics (C) Copyright IBM Corp. 2018, 2020
  6. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. */
  8. /**
  9. * @interface VisualizationAPI
  10. * @classdesc API class that is used to control visualizations.
  11. * @example content.getFeature('Visualization')
  12. */
  13. define([], function () {
  14. var VisualizationAPI = function () {
  15. function VisualizationAPI() {
  16. _classCallCheck(this, VisualizationAPI);
  17. }
  18. /**
  19. * @description Registers a visualization event handler.
  20. * @function VisualizationAPI#on
  21. * @private
  22. *
  23. * @param {String} name Event name
  24. * @param {Function} name Event handler
  25. * @return Object that has a remove function that removes the event handler.
  26. */
  27. VisualizationAPI.prototype.on = function on() {};
  28. /**
  29. * @description Deregisters a visualization event handler.
  30. * @function VisualizationAPI#off
  31. * @private
  32. *
  33. * @param {String} name Event name
  34. * @param {Function} name Event handler
  35. *
  36. */
  37. VisualizationAPI.prototype.off = function off() {};
  38. /**
  39. * @description Returns the data source used by the visualization.
  40. * @function VisualizationAPI#getDataSource
  41. * @private
  42. *
  43. * @return DataSourceAPI
  44. */
  45. VisualizationAPI.prototype.getDataSource = function getDataSource() {};
  46. /**
  47. * @description Sets the data source to be used by the visualization.
  48. * @function VisualizationAPI#setDataSource
  49. * @private
  50. *
  51. * @param {String} datasourceId Unique data source identifier
  52. * @return {Promise<DataSourceAPI>}
  53. */
  54. VisualizationAPI.prototype.setDataSource = function setDataSource() /* datasourceId */{};
  55. /**
  56. * @description Gets an array of MetadataColumnAPI objects that are used in the visualization.
  57. * @function VisualizationAPI#getUsedMetadataColumnList
  58. * @private
  59. *
  60. * @return {MetadataColumnAPI[]}
  61. */
  62. VisualizationAPI.prototype.getUsedMetadataColumnList = function getUsedMetadataColumnList() {};
  63. /**
  64. * @description Returns the slots interface, which can be used to get and set information about the slots and data mappings in the visualization.
  65. * @function VisualizationAPI#getSlots
  66. * @public
  67. *
  68. * @return {SlotsAPI} Slots object
  69. *
  70. */
  71. VisualizationAPI.prototype.getSlots = function getSlots() {};
  72. /**
  73. * @description Returns the visulization type that is being used.
  74. * @function VisualizationAPI#getType
  75. * @public
  76. *
  77. * @returns {String} Type (e.g. Bar, Area, etc)
  78. * @example
  79. * // will return the string 'Bar'
  80. * visualization.getType()
  81. *
  82. */
  83. VisualizationAPI.prototype.getType = function getType() {};
  84. /**
  85. * @description Returns true if the widget matches the spec provided in the parameter.
  86. * We currently only support matches with a spec that has only a visId and localFilters.
  87. * Anything else will cause an error.
  88. *
  89. * @function VisualizationAPI#matches
  90. * @private
  91. *
  92. * @returns {{visId: String, localFilters: Object}} Spec object to match. For more info about the content, refer to the visualization specification
  93. * @example
  94. *
  95. * visualization.matches({
  96. * "visId": "com.ibm.vis.rave2bundlecolumn",
  97. * "localFilters": [{
  98. * "id": "banking.Business",
  99. * "columnId": "banking.Business",
  100. * "values": [
  101. * {
  102. * "d": "Corporate Finance",
  103. * "u": "Corporate Finance"
  104. * },
  105. * {
  106. * "d": "Retail Banking",
  107. * "u": "Retail Banking"
  108. * }
  109. * ],
  110. * "excludedValues": [],
  111. * "operator": "notin",
  112. * "type": null,
  113. * "binsLabel": ""
  114. * },
  115. * {
  116. * "id": "banking.Year_",
  117. * "columnId": "banking.Year_",
  118. * "values": [
  119. * {
  120. * "d": "2008",
  121. * "u": "2008"
  122. * },
  123. * {
  124. * "d": "2009",
  125. * "u": "2009"
  126. * }
  127. * ],
  128. * "excludedValues": [],
  129. * "operator": "in",
  130. * "type": null,
  131. * "binsLabel": "Year"
  132. * },
  133. * {
  134. * "id": "banking.Recovery_Amount_sum",
  135. * "columnId": "banking.Recovery_Amount",
  136. * "values": [
  137. * {
  138. * "d": 31234327.54830128,
  139. * "u": 31234327.54830128
  140. * },
  141. * {
  142. * "d": 35389734.47129045,
  143. * "u": 35389734.47129045
  144. * }
  145. * ],
  146. * "excludedValues": [],
  147. * "operator": "between",
  148. * "aggregationType": "sum",
  149. * "preOrPost": "post"
  150. * }]
  151. *})
  152. *
  153. */
  154. VisualizationAPI.prototype.matches = function matches() {};
  155. /**
  156. * @description Returns the visualization definition. The definition describes various aspects of the visualization like name, slots, properties, etc.
  157. * @function VisualizationAPI#getDefinition
  158. * @private
  159. *
  160. * @returns {VisDefinitionAPI} vis defintion
  161. *
  162. */
  163. VisualizationAPI.prototype.getDefinition = function getDefinition() {};
  164. /**
  165. * @function Visualization#getSavedPrompts
  166. * @description Gets the API of SavedPrompts.
  167. * @private
  168. *
  169. * @return {SavedPromptsAPI} API of SavedPrompts
  170. */
  171. VisualizationAPI.prototype.getSavedPrompts = function getSavedPrompts() {};
  172. /**
  173. * @description Gets the local filters.
  174. * @function VisualizationAPI#getLocalFilters
  175. *
  176. * @returns {FiltersAPI}
  177. */
  178. VisualizationAPI.prototype.getLocalFilters = function getLocalFilters() {};
  179. /**
  180. * @description Sets the visualization type, where 'auto' will set the visualization to the recommended type.
  181. * @function VisualizationAPI#setType
  182. * @public
  183. *
  184. * @param {String} type For example: auto, Bar, Area, etc.
  185. * @param {SetOptions} options
  186. *
  187. * @todo - define the type enum (can be found in SmartsToVizMapping.js)
  188. */
  189. VisualizationAPI.prototype.setType = function setType() /* type, options */{};
  190. /**
  191. * @description Indicates whether the visualization type is locked or not.
  192. * An unlocked visualization type will use the recommender when new columns are added and the viz type might change as we add more columns.
  193. * A locked visualization type will always used the current visualization as we add new columns to the slots.
  194. *
  195. * @function VisualizationAPI#isTypeLocked
  196. * @private
  197. *
  198. * @param {Boolean} isTypeLocked
  199. *
  200. */
  201. VisualizationAPI.prototype.isTypeLocked = function isTypeLocked() {};
  202. /**
  203. * @description Locks the visualization.
  204. * An unlocked visualization type will use the recommender when new columns are added and the viz type might change as we add more columns.
  205. * A locked visualization type will always used the current visualization as we add new columns to the slots.
  206. *
  207. * @function VisualizationAPI#lockType
  208. * @private
  209. *
  210. * @param {SetOptions} Options
  211. *
  212. */
  213. VisualizationAPI.prototype.lockType = function lockType() /* options */{};
  214. /**
  215. * @description Unlocks the visualization.
  216. * An unlocked visualization type will use the recommender when new columns are added and the viz type might change as we add more columns.
  217. * A locked visualization type will always used the current visualization as we add new columns to the slots.
  218. * @function VisualizationAPI#unlockType
  219. * @private
  220. *
  221. * @param {SetOptions} Options
  222. *
  223. */
  224. VisualizationAPI.prototype.unlockType = function unlockType() /* options */{};
  225. // /**
  226. // * @description Returns the decorator object that can be used to decorate the data in the visualization.
  227. // * If the visualizatoin support multiple datasets and no view id is provided, then the decorator for the first dataset is returned.
  228. // *
  229. // * @function VisualizationAPI#getDecorator
  230. // * @private
  231. // *
  232. // * @param {String} [viewId] Data view id. If not provided, the decorator for the first data view is returned.
  233. // *
  234. // * @return {DecoratorAPI} decorator object
  235. // *
  236. // */
  237. // getDecorator(/* dataViewId */) {}
  238. // /**
  239. // * @description Return a list of decorator object that can be used to decorate the data in the visualization.
  240. // * Each dataset will have its own decorator object.
  241. // *
  242. // * @function VisualizationAPI#getDecoratorList.
  243. // * @private
  244. // *
  245. // * @return {DecoratorAPI[]} decorator object
  246. // *
  247. // */
  248. // getDecoratorList() {}
  249. /**
  250. * @description Returns true if hasUnavailableMetadataColumns references a column that is no longer available.
  251. * @function VisualizationAPI#hasUnavailableMetadataColumns
  252. * @public
  253. *
  254. * @returns {Boolean}
  255. */
  256. VisualizationAPI.prototype.hasUnavailableMetadataColumns = function hasUnavailableMetadataColumns() {};
  257. return VisualizationAPI;
  258. }();
  259. /**
  260. * @description Enum for all supported DECORATIONS
  261. * @readonly
  262. * @enum {String}
  263. * @private
  264. * @constant
  265. * @memberOf VisualizationAPI
  266. */
  267. VisualizationAPI.DECORATIONS = {
  268. HIGHLIGHT: 'highlight',
  269. SELECT: 'select',
  270. TOOLTIP: 'tooltip'
  271. };
  272. return VisualizationAPI;
  273. });
  274. //# sourceMappingURL=VisualizationAPI.js.map