PostProcessMeasuresAsSeries.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5. /*
  6. *+------------------------------------------------------------------------+
  7. *| Licensed Materials - Property of IBM
  8. *| IBM Cognos Products: BI Dashboard
  9. *| (C) Copyright IBM Corp. 2017, 2020
  10. *|
  11. *| US Government Users Restricted Rights - Use, duplication or disclosure
  12. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  13. *+------------------------------------------------------------------------+
  14. */
  15. define(['jquery', 'underscore', './QueryPostProcessor', '../../../../widgets/livewidget/nls/StringResources', '../../../../widgets/livewidget/query/QueryResultDataUtils', '../../../../apiHelpers/SlotAPIHelper'], function ($, _, QueryPostProcessor, StringResources, QueryResultDataUtils, SlotAPIHelper) {
  16. /**
  17. * This Class does Query result response post-processing such as processing the original query result
  18. * into a data re-structure to support multiple measures as series.
  19. **/
  20. var PostProcessMeasuresAsSeries = function (_QueryPostProcessor) {
  21. _inherits(PostProcessMeasuresAsSeries, _QueryPostProcessor);
  22. /**
  23. * @Constructor
  24. * @param {Object} options
  25. */
  26. function PostProcessMeasuresAsSeries(options) {
  27. _classCallCheck(this, PostProcessMeasuresAsSeries);
  28. var _this = _possibleConstructorReturn(this, _QueryPostProcessor.call(this, options));
  29. _this.visualization = options.visualization;
  30. _this.queryDefinition = options.queryDefinition;
  31. return _this;
  32. }
  33. /**
  34. * Process Query result based on the passed options to constructor.
  35. * For instance, limit the rows of datapoints so that in the response, for
  36. * specified dataitem, 'product', there will be only three tuples returned
  37. *
  38. * @return {QueryResultData}
  39. */
  40. PostProcessMeasuresAsSeries.prototype._processData = function _processData() {
  41. if (this._queryResultData && this._queryResultData.data && this._canProcess()) {
  42. var result = this._categorizeDataItems();
  43. // post-process the data items
  44. this._processDataItems(result);
  45. // post-process the data points
  46. this._processDataPoints(result);
  47. }
  48. //Process Done
  49. return this._queryResultData;
  50. };
  51. /**
  52. * Determine whether multiple measure series is supported
  53. */
  54. PostProcessMeasuresAsSeries.prototype._canProcess = function _canProcess() {
  55. var slots = this._getDatasetSlotList();
  56. var hasMultiMeasuresSeries = false,
  57. hasMultiMeasuresVal = false;
  58. _.each(slots, function (slot) {
  59. hasMultiMeasuresSeries = hasMultiMeasuresSeries || SlotAPIHelper.isMultiMeasuresSeriesSlot(slot);
  60. hasMultiMeasuresVal = hasMultiMeasuresVal || SlotAPIHelper.isMultiMeasuresValueSlot(slot);
  61. });
  62. return hasMultiMeasuresSeries && hasMultiMeasuresVal;
  63. };
  64. /**
  65. * Get the mapped projectionId for each dataItem.
  66. *
  67. * note: the logic here should be the same in visQueryBuilder.js:_slotToProjections()
  68. */
  69. PostProcessMeasuresAsSeries.prototype._getQueryProjectionId = function _getQueryProjectionId(slot, dataItemIdx) {
  70. // We don't project MultiMeasureSeries dataItem
  71. if (SlotAPIHelper.isMultiMeasuresSeriesOrValue(slot, dataItemIdx)) {
  72. return null;
  73. }
  74. var dataItemList = slot.getDataItemList();
  75. var validDataItemIds = _.filter(dataItemList, function (dataItem, idx) {
  76. return !SlotAPIHelper.isMultiMeasuresSeriesOrValue(slot, idx);
  77. });
  78. if (slot.isStacked() && validDataItemIds.length > 1) {
  79. return slot.getId();
  80. }
  81. return dataItemList[dataItemIdx].getId();
  82. };
  83. /**
  84. * Categorize the existing data items by category and ordinals
  85. * Keep track of data items original index and also the slot Id it which the data item is mapped.
  86. * The original index later allows the data points (prior to restructure) to access the mapping slot and data item.
  87. *
  88. * Despite the result data being the original data, the slot mapping already includes the multi-measures series mapping.
  89. * The slot mapping for mult-measures series needs to be ignored at this stage in order to match with the original data.
  90. */
  91. PostProcessMeasuresAsSeries.prototype._categorizeDataItems = function _categorizeDataItems() {
  92. var result = {
  93. cats: [],
  94. ords: [],
  95. commonIndices: {},
  96. mappedIndices: {},
  97. extraDataItems: []
  98. };
  99. var resultQueryDataItems = this._queryResultData.dataItems;
  100. var allProjectionIds = _.map(resultQueryDataItems, function (dataItem) {
  101. return dataItem.itemClass.id;
  102. });
  103. var mappedProjectionIds = [];
  104. var slotList = this._getDatasetSlotList();
  105. for (var i = 0; i < slotList.length; i++) {
  106. var slot = slotList[i];
  107. var dataItemList = slot.getDataItemList();
  108. for (var dataItemIdx = 0; dataItemIdx < dataItemList.length; dataItemIdx++) {
  109. var queryProjectionId = this._getQueryProjectionId(slot, dataItemIdx);
  110. if (queryProjectionId) {
  111. var type = dataItemList[dataItemIdx].getType();
  112. var idx = allProjectionIds.indexOf(queryProjectionId);
  113. var newEntry = {
  114. item: idx !== -1 ? resultQueryDataItems[idx] : undefined,
  115. slotId: slot.getId(),
  116. index: idx !== -1 ? idx : undefined
  117. };
  118. if (newEntry.index !== undefined) {
  119. result.mappedIndices[newEntry.index] = true;
  120. if (type === 'fact' && !slot.getDefinition().isMultiMeasureSupported()) {
  121. result.commonIndices[newEntry.index] = true;
  122. }
  123. }
  124. (type === 'attribute' ? result.cats : result.ords).push(newEntry);
  125. mappedProjectionIds.push(queryProjectionId);
  126. }
  127. }
  128. }
  129. var extraDataItemIds = _.difference(allProjectionIds, mappedProjectionIds);
  130. resultQueryDataItems.forEach(function (dataItem, index) {
  131. if (extraDataItemIds.indexOf(dataItem.itemClass.id) !== -1) {
  132. result.commonIndices[index] = true;
  133. result.extraDataItems.push({ dataItem: dataItem });
  134. }
  135. });
  136. return result;
  137. };
  138. /**
  139. * Process the data items
  140. * Consolidate the multiple measures to one measure data item and a extra series to indicate the measure
  141. */
  142. PostProcessMeasuresAsSeries.prototype._processDataItems = function _processDataItems(dataItems) {
  143. var _this2 = this;
  144. var resultData = this._queryResultData;
  145. var slots = this._getDatasetSlotList();
  146. // rebuild the dataItems from scratch!
  147. resultData.dataItems.length = 0;
  148. // maintain the order based on slots
  149. for (var i = 0; i < slots.length; i++) {
  150. var slot = slots[i];
  151. var dataItem = void 0;
  152. var isCategory = slot.getDataItemList()[0].getType() === 'attribute';
  153. if (isCategory) {
  154. if (SlotAPIHelper.isMultiMeasuresSeriesSlot(slot)) {
  155. var measures = _.map(dataItems.ords, function (ordinal) {
  156. var slotDefinition = _this2.visualization.getDefinition().getSlot(ordinal.slotId);
  157. var supportsMultiMeasure = slotDefinition.getProperty('multiMeasure');
  158. if (ordinal && ordinal.item && ordinal.item.itemClass && supportsMultiMeasure) {
  159. return ordinal.item.itemClass.h[0];
  160. }
  161. return undefined;
  162. });
  163. measures = _.compact(measures);
  164. // apply the multiple measures as a series
  165. dataItem = this._getSeriesDataItemforMultipleMeasures(dataItems.cats, measures, slot);
  166. } else {
  167. dataItem = this._getDataItem(dataItems.cats, slot);
  168. }
  169. } else if (SlotAPIHelper.isMultiMeasuresValueSlot(slot)) {
  170. // apply the value for all measures
  171. dataItem = this._getValueDataItemForMultipleMeasures(slot);
  172. } else {
  173. var matchDataItems = this._getDataItem(dataItems.ords, slot, /*findAll*/true);
  174. resultData.dataItems.push.apply(resultData.dataItems, matchDataItems);
  175. }
  176. if (dataItem) {
  177. resultData.dataItems.push(dataItem);
  178. }
  179. }
  180. dataItems.extraDataItems.forEach(function (extraDataItem) {
  181. extraDataItem.index = resultData.dataItems.length;
  182. resultData.dataItems.push(extraDataItem.dataItem);
  183. });
  184. };
  185. /**
  186. * Find the data item mapped to a slot
  187. */
  188. PostProcessMeasuresAsSeries.prototype._getDataItem = function _getDataItem(items, slot, findAll) {
  189. var slotItems = [];
  190. items.forEach(function (item) {
  191. if (item.slotId === slot.getId()) {
  192. slotItems.push(item.item);
  193. }
  194. });
  195. return findAll ? slotItems : slotItems[0];
  196. };
  197. /**
  198. * Collect the unique values from a category data item
  199. */
  200. PostProcessMeasuresAsSeries.prototype._getCategoryDataItemValues = function _getCategoryDataItemValues(categoryItem, stackIndex) {
  201. if (stackIndex > -1) {
  202. var stackValues = {};
  203. // collect the unique values
  204. _.each(categoryItem.items, function (item) {
  205. stackValues[item.t[stackIndex].u] = item.t[stackIndex];
  206. });
  207. var keys = Object.keys(stackValues);
  208. return _.map(keys, function (key) {
  209. return stackValues[key];
  210. });
  211. }
  212. return [];
  213. };
  214. /**
  215. * Create a category data item for the multiple measures series
  216. */
  217. PostProcessMeasuresAsSeries.prototype._getSeriesDataItemforMultipleMeasures = function _getSeriesDataItemforMultipleMeasures(cats, measures, slot) {
  218. return {
  219. itemClass: this._getSeriesDataItemClass(cats, slot),
  220. items: this._getSeriesTupleItems(cats, measures, slot)
  221. };
  222. };
  223. /**
  224. * Collect column ids from data item list of a given slot
  225. */
  226. PostProcessMeasuresAsSeries.prototype._getSlotColumnIds = function _getSlotColumnIds(slot) {
  227. return _.map(slot.getDataItemList(), function (dataItem) {
  228. return dataItem.getColumnId();
  229. });
  230. };
  231. /**
  232. * Collect all series data item class
  233. */
  234. PostProcessMeasuresAsSeries.prototype._getSeriesDataItemClass = function _getSeriesDataItemClass(cats, slot) {
  235. var ids = this._getSlotColumnIds(slot);
  236. var stackedItem = this._getDataItem(cats, slot);
  237. return {
  238. id: slot.getId(),
  239. h: _.map(ids, function (id, index) {
  240. if (SlotAPIHelper.isMultiMeasuresSeriesOrValue(slot, index)) {
  241. return {
  242. u: SlotAPIHelper.MULTI_MEASURES_SERIES,
  243. d: StringResources.get('MeasuresCaption')
  244. };
  245. } else {
  246. if (stackedItem && stackedItem.itemClass) {
  247. return _.find(stackedItem.itemClass.h, function (header) {
  248. return header.u === id;
  249. });
  250. }
  251. return undefined;
  252. }
  253. })
  254. };
  255. };
  256. /**
  257. * Collect all series data item tuple items
  258. */
  259. PostProcessMeasuresAsSeries.prototype._getSeriesTupleItems = function _getSeriesTupleItems(cats, measures, slot) {
  260. var _this3 = this;
  261. var rows = [];
  262. var baseRows = [];
  263. var catItem = this._getDataItem(cats, slot);
  264. var stackIds = catItem ? _.map(catItem.itemClass.h, function (header) {
  265. return header.u;
  266. }) : [];
  267. var ids = this._getSlotColumnIds(slot);
  268. var _loop = function _loop(index) {
  269. var id = ids[index];
  270. var isMultiMeasureSeries = SlotAPIHelper.isMultiMeasuresSeriesOrValue(slot, index);
  271. var values = isMultiMeasureSeries ? measures : _this3._getCategoryDataItemValues(catItem, stackIds.indexOf(id));
  272. //clean up rows and baseRows, so that no defect occurs in the loop with more than 2 ids.
  273. if (rows.length != 0) {
  274. baseRows = rows;
  275. }
  276. rows = [];
  277. if (baseRows.length > 0) {
  278. if (values.length > 0) {
  279. // Should preserve the drop order in multi measure series slot so iterate from baseRows to values
  280. for (var j = 0; j < baseRows.length; j++) {
  281. var row = baseRows[j];
  282. // duplicate the values tuple
  283. var clone = values.slice();
  284. for (var valueIndex = 0; valueIndex < clone.length; valueIndex++) {
  285. var value = clone[valueIndex];
  286. var newRow = valueIndex === 0 ? row : $.extend(true, {}, row);
  287. newRow.t[index] = isMultiMeasureSeries ? {
  288. u: _this3._getMultiMeasureMun(valueIndex),
  289. d: value.d,
  290. aggregate: value.aggregate
  291. } : value;
  292. rows.push(newRow);
  293. }
  294. }
  295. } else {
  296. // since there are no data to duplicate, simply update the base rows with null data
  297. baseRows.forEach(function (row) {
  298. row.t[index] = {
  299. u: null,
  300. d: null
  301. };
  302. });
  303. }
  304. } else {
  305. // prepare the base tuple item rows
  306. baseRows.push.apply(baseRows, _.map(values, function (value, index) {
  307. return {
  308. t: [isMultiMeasureSeries ? {
  309. u: value && value.u ? _this3._getMultiMeasureMun(index) : 'undefined',
  310. d: value && value.d ? value.d : 'undefined',
  311. aggregate: value.aggregate
  312. } : value]
  313. };
  314. }));
  315. }
  316. };
  317. for (var index = 0; index < ids.length; index++) {
  318. _loop(index);
  319. }
  320. // finish with the base rows if not expecting a category (i.e. not nested)
  321. if (!catItem && rows.length === 0) {
  322. rows.push.apply(rows, baseRows.slice());
  323. }
  324. return rows;
  325. };
  326. /**
  327. * Create a measure data item for the multiple measure values
  328. */
  329. PostProcessMeasuresAsSeries.prototype._getValueDataItemForMultipleMeasures = function _getValueDataItemForMultipleMeasures(slot) {
  330. return {
  331. itemClass: {
  332. id: slot.getId(),
  333. h: [{
  334. u: SlotAPIHelper.MULTI_MEASURES_VALUE,
  335. d: StringResources.get('ValuesCaption')
  336. }]
  337. }
  338. };
  339. };
  340. /**
  341. * Process all data point to restructure the data for multiple measures value and series
  342. */
  343. PostProcessMeasuresAsSeries.prototype._processDataPoints = function _processDataPoints(dataItems) {
  344. // prepare the new index for each slot
  345. var newIndices = this._allocateDataPointIndices(dataItems.extraDataItems);
  346. // restructured data
  347. var newData = [];
  348. var resultData = this._queryResultData;
  349. var multiMeasureSeriesId = this._getMultiMeasureSeriesId();
  350. var resultDataData = resultData.data;
  351. for (var i = 0; i < resultDataData.length; i++) {
  352. var datapoint = resultDataData[i];
  353. this._restructureDataPoint(dataItems, datapoint, newIndices, newData, multiMeasureSeriesId);
  354. }
  355. resultData.data = newData;
  356. };
  357. /**
  358. * Allocate the datapoint index for each data item.
  359. * Since the multiple measures are wrapped into a single measure with an extra series for the measures,
  360. * None of the slots would have multiple data items.
  361. *
  362. * ie. category, multimeasure_series, category(series), value
  363. * indices: {
  364. * seriesIndex: 1,
  365. * valueIndex: 3,
  366. * catIndices: [0, 2]
  367. * }
  368. */
  369. PostProcessMeasuresAsSeries.prototype._allocateDataPointIndices = function _allocateDataPointIndices(extraDataItems) {
  370. var catIndex = 0;
  371. var commonValueIndex = 0;
  372. var slots = this._getDatasetSlotList();
  373. var indices = {
  374. seriesIndex: -1,
  375. valueIndex: -1,
  376. commonIndices: [],
  377. catIndices: []
  378. };
  379. slots.forEach(function (slot, slotIndex) {
  380. var isCategory = slot.getDataItemList()[0].getType() === 'attribute';
  381. if (isCategory) {
  382. if (SlotAPIHelper.isMultiMeasuresSeriesSlot(slot)) {
  383. indices.seriesIndex = slotIndex;
  384. } else {
  385. indices.catIndices[catIndex++] = slotIndex;
  386. }
  387. } else if (SlotAPIHelper.isMultiMeasuresValueSlot(slot)) {
  388. indices.valueIndex = slotIndex;
  389. } else {
  390. slot.getDataItemList().forEach(function (dataItem, index) {
  391. indices.commonIndices[commonValueIndex++] = slotIndex + index;
  392. });
  393. }
  394. });
  395. extraDataItems.forEach(function (dataItem) {
  396. return indices.commonIndices[commonValueIndex++] = dataItem.index;
  397. });
  398. return indices;
  399. };
  400. /**
  401. * Restructure a single data point.
  402. * Consolidate multiple measures to one value
  403. * Categorize the measures to one category
  404. */
  405. PostProcessMeasuresAsSeries.prototype._restructureDataPoint = function _restructureDataPoint(dataItems, datapoint, indices, newData, multiMeasureSeriesId) {
  406. var catValueIndex = 0;
  407. var commonValueIndex = 0;
  408. var point = [];
  409. var ordValues = []; // has to be in order
  410. var catItemInSeries = void 0;
  411. var seriesIndexValue = 0;
  412. var slots = this._getDatasetSlotList();
  413. // Prepare the common portion of the data point
  414. for (var valueIndex = 0; valueIndex < datapoint.pt.length; valueIndex++) {
  415. var value = datapoint.pt[valueIndex];
  416. var category = void 0;
  417. for (var i = 0; i < dataItems.cats.length; i++) {
  418. if (dataItems.cats[i].index === valueIndex) {
  419. category = dataItems.cats[i];
  420. break;
  421. }
  422. }
  423. if (category) {
  424. var slot = void 0;
  425. for (var j = 0; j < slots.length; j++) {
  426. if (slots[j].getId() === category.slotId) {
  427. slot = slots[j];
  428. break;
  429. }
  430. }
  431. if (SlotAPIHelper.isMultiMeasuresSeriesSlot(slot)) {
  432. catItemInSeries = category.item;
  433. seriesIndexValue = value;
  434. } else {
  435. point[indices.catIndices[catValueIndex++]] = value;
  436. }
  437. } else if (dataItems.commonIndices[valueIndex]) {
  438. point[indices.commonIndices[commonValueIndex++]] = value;
  439. } else if (dataItems.mappedIndices[valueIndex]) {
  440. // Keep track of the remaining ordinal values (as long as they're 'valid' - mapped to a slot)
  441. ordValues.push(value);
  442. }
  443. }
  444. // Duplicate the data point by each measure
  445. var processedIndices = [];
  446. for (var indexValue = 0; indexValue < ordValues.length; indexValue++) {
  447. var ordValue = ordValues[indexValue];
  448. var pt = indexValue === 0 ? point : point.slice();
  449. pt[indices.seriesIndex] = this._getSeriesIndex(dataItems, indexValue, catItemInSeries, seriesIndexValue, processedIndices, multiMeasureSeriesId);
  450. pt[indices.valueIndex] = ordValue;
  451. newData.push({ pt: pt });
  452. processedIndices.push(indexValue);
  453. }
  454. };
  455. PostProcessMeasuresAsSeries.prototype._getSeriesIndex = function _getSeriesIndex(dataItems, ordIndex, catItemInSeries, originalIndex, processedIndices, multiMeasureSeriesId) {
  456. // The multiSeriesResultItem has tuples built from _getSeriesTupleItems. It's a cross joined tuple set of the multi measure series
  457. var multiSeriesResultItem = this._queryResultData && this._queryResultData.dataItems && this._queryResultData.dataItems[QueryResultDataUtils.getDataItemIndex(this._queryResultData, multiMeasureSeriesId)];
  458. // The target tuple to search in multiSeriesResultItem and return its index
  459. var measureMun = this._getMultiMeasureMun(ordIndex);
  460. var targetTuple = catItemInSeries && catItemInSeries.items[originalIndex].t.map(function (tuple) {
  461. return tuple.u;
  462. }) || [];
  463. targetTuple.push(measureMun);
  464. // Search the target tuple in the cross joined tuple set of the multi measure series, and return the index
  465. var resultIndex = -1;
  466. if (multiSeriesResultItem.items.length !== 0) {
  467. for (var idx = 0; idx < multiSeriesResultItem.items.length; idx++) {
  468. var tuple = multiSeriesResultItem.items[idx];
  469. //check if tuple matches targetTuple & index is not in processedIndices
  470. var matched = this._isMatched(tuple, targetTuple, processedIndices, idx);
  471. if (matched) {
  472. resultIndex = idx;
  473. break;
  474. }
  475. }
  476. }
  477. return resultIndex;
  478. };
  479. PostProcessMeasuresAsSeries.prototype._foundInTarget = function _foundInTarget(u, targetTuple) {
  480. var found = false;
  481. for (var j = 0; j < targetTuple.length; j++) {
  482. if (targetTuple[j] === u) {
  483. found = true;
  484. break;
  485. }
  486. }
  487. return found;
  488. };
  489. PostProcessMeasuresAsSeries.prototype._isMatched = function _isMatched(tuple, targetTuple, processedIndices, idx) {
  490. //check if tuple matches targetTuple & index is not in processedIndices
  491. var idxContained = processedIndices.indexOf(idx) !== -1;
  492. if (idxContained === false) {
  493. var matches = 0;
  494. var len = tuple.t.length;
  495. for (var i = 0; i < len; i++) {
  496. if (this._foundInTarget(tuple.t[i].u, targetTuple)) {
  497. matches++;
  498. }
  499. }
  500. if (matches === tuple.t.length) {
  501. return true;
  502. }
  503. }
  504. return false;
  505. };
  506. PostProcessMeasuresAsSeries.prototype._getMultiMeasureMun = function _getMultiMeasureMun(index) {
  507. if (!this._multiMeasureSlotAPI) {
  508. var slotList = this._getDatasetSlotList();
  509. for (var i = 0; i < slotList.length; i++) {
  510. var slot = slotList[i];
  511. if (SlotAPIHelper.isMultiMeasuresValueSlot(slot)) {
  512. this._multiMeasureSlotAPI = slot;
  513. break;
  514. }
  515. }
  516. }
  517. var dataItemAPIs = this._multiMeasureSlotAPI.getDataItemList();
  518. return dataItemAPIs[index].getId();
  519. };
  520. /**
  521. * Find the slot ID where the multiMeasureSeries is
  522. */
  523. PostProcessMeasuresAsSeries.prototype._getMultiMeasureSeriesId = function _getMultiMeasureSeriesId() {
  524. var slots = this._getDatasetSlotList();
  525. var multiMeasureSeriesSlot = _.find(slots, function (slot) {
  526. return SlotAPIHelper.isMultiMeasuresSeriesSlot(slot);
  527. });
  528. return multiMeasureSeriesSlot && multiMeasureSeriesSlot.getId();
  529. };
  530. PostProcessMeasuresAsSeries.prototype._getDatasetSlotList = function _getDatasetSlotList() {
  531. var _this4 = this;
  532. if (!this._datasetSlotList) {
  533. var slots = this.visualization.getSlots().getMappedSlotList();
  534. this._datasetSlotList = slots.filter(function (slot) {
  535. return slot.getDefinition().getDatasetIdList().indexOf(_this4.queryDefinition.getId()) !== -1;
  536. });
  537. }
  538. return this._datasetSlotList;
  539. };
  540. return PostProcessMeasuresAsSeries;
  541. }(QueryPostProcessor);
  542. return PostProcessMeasuresAsSeries;
  543. });
  544. //# sourceMappingURL=PostProcessMeasuresAsSeries.js.map