UNPKG

@gooddata/react-components

Version:

GoodData.UI - A powerful JavaScript library for building analytical applications

106 lines 5.81 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); // (C) 2019-2020 GoodData Corporation var React = require("react"); var react_dom_1 = require("react-dom"); var cloneDeep = require("lodash/cloneDeep"); var get = require("lodash/get"); var set = require("lodash/set"); var without = require("lodash/without"); var BucketNames = require("../../../../constants/bucketNames"); var bucketConfig_1 = require("../../../utils/bucketConfig"); var PluggableBaseChart_1 = require("../baseChart/PluggableBaseChart"); var bucket_1 = require("../../../constants/bucket"); var bucketHelper_1 = require("../../../utils/bucketHelper"); var comboChartUiConfigHelperDeprecated_1 = require("../../../utils/uiConfigHelpers/comboChartUiConfigHelperDeprecated"); var sort_1 = require("../../../utils/sort"); var UnsupportedConfigurationPanel_1 = require("../../configurationPanels/UnsupportedConfigurationPanel"); var uiConfig_1 = require("../../../constants/uiConfig"); var visualizationTypes_1 = require("../../../../constants/visualizationTypes"); var PluggableComboChartDeprecated = /** @class */ (function (_super) { __extends(PluggableComboChartDeprecated, _super); function PluggableComboChartDeprecated(props) { var _this = _super.call(this, props) || this; _this.type = visualizationTypes_1.VisualizationTypes.COMBO; _this.supportedPropertiesList = []; _this.initializeProperties(props.visualizationProperties); return _this; } PluggableComboChartDeprecated.prototype.getExtendedReferencePoint = function (referencePoint) { var clonedReferencePoint = cloneDeep(referencePoint); var newReferencePoint = __assign({}, clonedReferencePoint, { uiConfig: cloneDeep(uiConfig_1.COMBO_CHART_UICONFIG_DEPRECATED) }); var buckets = get(clonedReferencePoint, bucket_1.BUCKETS, []); var attributes = bucketHelper_1.getAllAttributeItemsWithPreference(buckets, [ BucketNames.TREND, BucketNames.VIEW, ]).slice(0, 1); var measures = []; var secondaryMeasures = []; // ref. point has both my buckets -> reuse them fully if (bucketHelper_1.hasBucket(buckets, BucketNames.MEASURES) && bucketHelper_1.hasBucket(buckets, BucketNames.SECONDARY_MEASURES)) { measures = bucketHelper_1.getBucketItemsByType(buckets, BucketNames.MEASURES, [bucket_1.METRIC]); secondaryMeasures = bucketHelper_1.getBucketItemsByType(buckets, BucketNames.SECONDARY_MEASURES, [bucket_1.METRIC]); var restMeasures = bucketHelper_1.getBucketItemsWithExcludeByType(buckets, [BucketNames.MEASURES, BucketNames.SECONDARY_MEASURES], [bucket_1.METRIC]); secondaryMeasures = secondaryMeasures.concat(restMeasures); } else { // take all measures, first and its derived to primary, rest to secondary var allMeasures = bucketHelper_1.getAllItemsByType(buckets, [bucket_1.METRIC]); measures = bucketHelper_1.getFirstMasterWithDerived(allMeasures); secondaryMeasures = without.apply(void 0, [allMeasures].concat(measures)); } set(newReferencePoint, bucket_1.BUCKETS, [ { localIdentifier: BucketNames.MEASURES, items: measures, }, { localIdentifier: BucketNames.SECONDARY_MEASURES, items: secondaryMeasures, }, { localIdentifier: BucketNames.VIEW, items: attributes, }, ]); newReferencePoint = comboChartUiConfigHelperDeprecated_1.setComboChartUiConfigDeprecated(newReferencePoint, this.intl, this.type); newReferencePoint = bucketConfig_1.configurePercent(newReferencePoint, false); newReferencePoint = bucketConfig_1.configureOverTimeComparison(newReferencePoint, !!this.featureFlags.enableWeekFilters); newReferencePoint = bucketHelper_1.applyUiConfig(newReferencePoint); newReferencePoint = sort_1.removeSort(newReferencePoint); return Promise.resolve(bucketHelper_1.sanitizeFilters(newReferencePoint)); }; PluggableComboChartDeprecated.prototype.renderConfigurationPanel = function () { if (document.querySelector(this.configPanelElement)) { var properties = this.visualizationProperties || {}; react_dom_1.render(React.createElement(UnsupportedConfigurationPanel_1.default, { locale: this.locale, pushData: this.callbacks.pushData, properties: properties }), document.querySelector(this.configPanelElement)); } }; return PluggableComboChartDeprecated; }(PluggableBaseChart_1.PluggableBaseChart)); exports.PluggableComboChartDeprecated = PluggableComboChartDeprecated; //# sourceMappingURL=PluggableComboChartDeprecated.js.map