123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- 'use strict';
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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; }
- 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; }
- /**
- * Licensed Materials - Property of IBM
- * IBM Business Analytics (C) Copyright IBM Corp. 2020
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['underscore', './VIPRDecoratable', './VIPRValue'], function (_, VIPRDecoratable, VIPRValue) {
- // implements IDataPoint
- var VIPRDataPoint = function (_VIPRDecoratable) {
- _inherits(VIPRDataPoint, _VIPRDecoratable);
- /**
- * @param {Number} index - the index of this datapoint
- * @param {Object} dataset - the ViprDataSet object
- * @param {Object} dataIteminfo - an object that describes whether dataItems are latlong or have format callbacks.
- * @param {Boolean[]} dataItemInfo.isLatLong - true if this item denotes a lattitude or longitude value
- * @param {Function[]} dataItemInfo.formatter - set if the VIPRDataItem has a formatter
- * @param {Object} context - the context.
- */
- function VIPRDataPoint(index, dataset, dataItemInfo, context) {
- _classCallCheck(this, VIPRDataPoint);
- var _this = _possibleConstructorReturn(this, _VIPRDecoratable.call(this, null, context));
- _this.index = index;
- _this.dataset = dataset;
- _this.dataItemInfo = dataItemInfo;
- _this.context = context;
- _this.queryResult = dataset.queryResult;
- _this.viprValues = {}; //Keep any viprValue (IValue) objects.
- return _this;
- }
- /**
- * @param {Number} resultItemIndex - the index of this categorical resultItem in the QueryResult AND the VIPRDataSet
- * @returns {Number} the index of the tuple for this item that this datapoint represents.
- */
- VIPRDataPoint.prototype.getTupleIndex = function getTupleIndex(resultItemIndex) {
- var tupleIndex = this.queryResult.getValueIndex(this.index, resultItemIndex);
- // Keep a reverse-reference from tuple to the datapoint
- var viprDataItem = this.dataset.getDataItem && this.dataset.getDataItem(resultItemIndex);
- viprDataItem && viprDataItem.getTuple(tupleIndex).addDataPoint(this);
- return tupleIndex;
- };
- /**
- * @param {Number} resultItemIndex - the index of this continuous resultItem in the QueryResult AND the VIPRDataSet
- * @returns {Object} A VIPRValue API which includes a getValue() getCaption() to get the actual values.
- */
- VIPRDataPoint.prototype.getValue = function getValue(resultItemIndex) {
- if (this.viprValues[resultItemIndex] === undefined) {
- var valueObj = this.queryResult.getValue(this.index, resultItemIndex);
- if (this.dataItemInfo.isLatLong[resultItemIndex]) {
- //For values which are lat/long, the datapoint contains the index in the resultItem values
- //where the lat/long is stored.
- //(using getValue hides this detail except that the value is returned as a tuple array of length 1)
- valueObj = valueObj[0].value;
- }
- this.viprValues[resultItemIndex] = new VIPRValue(valueObj, this.dataItemInfo.formatter[resultItemIndex], resultItemIndex);
- }
- return this.viprValues[resultItemIndex];
- };
- /**
- * @description - Decorate this datapoint with the named decoration
- * @param {string} name - The name of the decoration for this datapoint (eg. selected, highlighted)
- * @returns {Boolean} value - the value of the decoration (usu true, false or undefined)
- */
- VIPRDataPoint.prototype.decorate = function decorate(name, value) {
- value = typeof value === 'undefined' ? true : value;
- _VIPRDecoratable.prototype.decorate.call(this, name, value);
- };
- /**
- * @returns The full, evaluated tuple for the categorical items in this datapoint.
- */
- VIPRDataPoint.prototype.getTupleItems = function getTupleItems() {
- var _this2 = this;
- var items = [];
- this.dataset.dataItems.forEach(function (dataItem, i) {
- if (dataItem.getType() === 'cat' || _this2.dataItemInfo.isLatLong[i]) {
- var value = _this2.queryResult.getValue(_this2.index, i);
- if (Array.isArray(value)) {
- items.push.apply(items, value);
- }
- }
- });
- return items;
- };
- /**
- * @description This additional api returns a key for the datapoint based on the valueIndexes of each categorical tuple
- * @example used to match query result tuples against points in smartAnnotation responses for decorating - see VIPRView)
- * @returns {String} - a "key" of form 'n,m,...' where n and m are the tupleIndexes of each categorical item.
- */
- VIPRDataPoint.prototype.getDataPointKey = function getDataPointKey() {
- var _this3 = this;
- var tupleIndexes = [];
- this.dataset.dataItems.forEach(function (dataItem, i) {
- if (dataItem.getType() === 'cat' || _this3.dataItemInfo.isLatLong[i]) {
- tupleIndexes.push(_this3.queryResult.getValueIndex(_this3.index, i));
- }
- });
- return tupleIndexes.toString();
- };
- return VIPRDataPoint;
- }(VIPRDecoratable);
- return VIPRDataPoint;
- });
- //# sourceMappingURL=VIPRDataPoint.js.map
|