1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- 'use strict';
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- /*
- * 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.
- */
- /**
- * @class KPIDOMProvider
- * @hideconstructor
- * @classdesc Implements DOMProviderAPI
- */
- define(['jquery', './api/DOMProviderAPI', '../../../../lib/@waca/dashboard-common/dist/core/APIFactory'], function ($, DomProviderAPI, APIFactory) {
- var KPIDOMProvider = function () {
- function KPIDOMProvider(options) {
- _classCallCheck(this, KPIDOMProvider);
- this._domNode = options.features.ContentViewDOM.getNode();
- this.liveWidgetDOM = options.features.LiveWidgetDOM;
- this.visualization = options.features.Visualization;
- var type = this.visualization.getType();
- if (type === 'KPI') {
- this.liveWidgetDOM.registerProvider(this.getAPI());
- }
- }
- KPIDOMProvider.prototype.getAPI = function getAPI() {
- if (!this._api) {
- this._api = APIFactory.createAPI(this, [DomProviderAPI]);
- }
- return this._api;
- };
- /**
- * @implements DomProviderAPI.getUIJSON
- */
- KPIDOMProvider.prototype.getUIJSON = function getUIJSON() {
- return {
- base: this._retrieve('base'),
- target: this._retrieve('target'),
- time: this._retrieveTime()
- };
- };
- KPIDOMProvider.prototype._retrieveTime = function _retrieveTime() {
- var $timeChart = $(this._domNode).find('div.dataview.kpi-widget > div.kpi-widget-content > div.kpi-widget-sparkline.widget svg.Rave2LineRenderer g.element-shape > path.line');
- if ($timeChart.length > 0) {
- return {
- color: $timeChart.css('stroke')
- };
- }
- };
- KPIDOMProvider.prototype._retrieve = function _retrieve(slot) {
- var selectorRoot = 'div.dataview > div.kpi-widget-content > div.kpi-widget-value.kpi-widget-' + slot + '-value.labeled-value > div.labeled-value';
- var $label = $(this._domNode).find(selectorRoot + '-label > span');
- if ($label.length > 0) {
- var $value = $(this._domNode).find(selectorRoot + '-value > span');
- var $shape = $(this._domNode).find(selectorRoot + '-value > svg > use');
- return {
- label: {
- text: $label.text(),
- color: $label.css('color')
- },
- value: {
- text: $value.text(),
- color: $value.css('color'),
- shape: $shape.attr('xlink:href')
- }
- };
- }
- };
- return KPIDOMProvider;
- }();
- return KPIDOMProvider;
- });
- //# sourceMappingURL=KPIDOMProvider.js.map
|