PostProcessAutobinningAxisLabels.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. 'use strict';
  2. /*
  3. *+------------------------------------------------------------------------+
  4. *| Licensed Materials - Property of IBM
  5. *| IBM Cognos Products: BI Dashboard
  6. *| (C) Copyright IBM Corp. 2018
  7. *|
  8. *| US Government Users Restricted Rights - Use, duplication or disclosure
  9. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  10. *+------------------------------------------------------------------------+
  11. */
  12. define(['./VisQueryPostProcessor', 'underscore'], function (VisQueryPostprocessor, _) {
  13. 'use strict';
  14. /**
  15. * This Class does Query result response post-processing for extracting and overwriting the axis label with the autobin caption correctly
  16. **/
  17. var PostprocessorClass = VisQueryPostprocessor.extend({
  18. /**
  19. * @Constructor
  20. * @param {Object} options
  21. */
  22. init: function init(options) {
  23. PostprocessorClass.inherited('init', this, arguments);
  24. this.mappingAPI = options.mappingAPI;
  25. this.slotAPI = this.mappingAPI.getSlotAPIs()[0];
  26. this.visAPI = options.visAPI;
  27. this.dataItems = this._queryResultData.dataItems;
  28. },
  29. /**
  30. * Rewrites the axis label for the non-cont/non measure slot axis
  31. * and corrects it to be the correct auto bin caption
  32. * if autobinning is turned on
  33. *
  34. * @return {QueryResultData}
  35. */
  36. _processData: function _processData() {
  37. var _this = this;
  38. _.each(this.dataItems, function (dataItem, key, memo) {
  39. // check if non-cont/measure
  40. if (dataItem.items && dataItem.items.length) {
  41. _.each(dataItem.itemClass.h, function (h) {
  42. var curItemId = h.u; // this is datasetName.label, used for finding
  43. var newLabel = _this.slotAPI.getAutobinCaption(curItemId);
  44. if (newLabel) {
  45. h.d = newLabel;
  46. }
  47. });
  48. }
  49. memo[key] = dataItem;
  50. });
  51. //Process Done
  52. return this._queryResultData;
  53. }
  54. });
  55. return PostprocessorClass;
  56. });
  57. //# sourceMappingURL=PostProcessAutobinningAxisLabels.js.map