InfographicEventTarget.js 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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: Dashboard
  9. *| (C) Copyright IBM Corp. 2019
  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', '../common/NonVIPREventTarget'], function ($, NonVIPREventTarget) {
  16. var InfographicEventTarget = function (_NonVIPREventTarget) {
  17. _inherits(InfographicEventTarget, _NonVIPREventTarget);
  18. function InfographicEventTarget() {
  19. var _ret;
  20. _classCallCheck(this, InfographicEventTarget);
  21. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  22. args[_key] = arguments[_key];
  23. }
  24. var _this = _possibleConstructorReturn(this, _NonVIPREventTarget.call.apply(_NonVIPREventTarget, [this].concat(args)));
  25. var options = args[0] || {};
  26. _this.visControl = options.visControl;
  27. _this.view = options.view;
  28. return _ret = _this.getAPI(), _possibleConstructorReturn(_this, _ret);
  29. }
  30. /**
  31. * Get the array of event targets based on the event.
  32. * Event target represents a data point object that corresponds to the event.
  33. *
  34. * @param event Event object
  35. */
  36. InfographicEventTarget.prototype.getEventTargets = function getEventTargets(event) {
  37. var node = this._getTargetNode(event);
  38. //return null on click since no action will be taken for infographic targets
  39. if (!node || event.type === 'click') {
  40. return [];
  41. }
  42. var $node = $(node);
  43. if (!this.mouseWithinBoundCheck(event)) {
  44. return [];
  45. }
  46. return this._getTargets(event, $node);
  47. };
  48. InfographicEventTarget.prototype.remove = function remove() {
  49. this.visControl = null;
  50. this.view = null;
  51. _NonVIPREventTarget.prototype.remove.call(this);
  52. };
  53. InfographicEventTarget.prototype._getTargets = function _getTargets(event, $node) {
  54. var targets = [];
  55. targets.push({
  56. key: 'label',
  57. type: 'itemclass',
  58. source: $node,
  59. isEdgeSelect: true,
  60. values: this._getTargetValues(),
  61. area: 'visualization'
  62. });
  63. return targets;
  64. };
  65. InfographicEventTarget.prototype._getTargetValues = function _getTargetValues() {
  66. var slots = [];
  67. var value = this.view.infographicValue;
  68. if (value) {
  69. slots.push({ value: value });
  70. }
  71. return slots;
  72. };
  73. return InfographicEventTarget;
  74. }(NonVIPREventTarget);
  75. return InfographicEventTarget;
  76. });
  77. //# sourceMappingURL=InfographicEventTarget.js.map