@gooddata/react-components
Version:
GoodData.UI - A powerful JavaScript library for building analytical applications
91 lines • 5.38 kB
JavaScript
;
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 bucketConfig_1 = require("../../../utils/bucketConfig");
var cloneDeep = require("lodash/cloneDeep");
var PluggableBaseChart_1 = require("../baseChart/PluggableBaseChart");
var bucketHelper_1 = require("../../../utils/bucketHelper");
var bucket_1 = require("../../../constants/bucket");
var sort_1 = require("../../../utils/sort");
var bulletChartUiConfigHelper_1 = require("../../../utils/uiConfigHelpers/bulletChartUiConfigHelper");
var uiConfig_1 = require("../../../constants/uiConfig");
var supportedProperties_1 = require("../../../constants/supportedProperties");
var BulletChartConfigurationPanel_1 = require("../../configurationPanels/BulletChartConfigurationPanel");
var propertiesHelper_1 = require("../../../utils/propertiesHelper");
var visualizationTypes_1 = require("../../../../constants/visualizationTypes");
var bucketHelper_2 = require("./bucketHelper");
var PluggableBulletChart = /** @class */ (function (_super) {
__extends(PluggableBulletChart, _super);
function PluggableBulletChart(props) {
var _this = _super.call(this, props) || this;
_this.type = visualizationTypes_1.VisualizationTypes.BULLET;
_this.supportedPropertiesList = supportedProperties_1.BULLET_CHART_SUPPORTED_PROPERTIES;
_this.initializeProperties(props.visualizationProperties);
return _this;
}
PluggableBulletChart.prototype.getExtendedReferencePoint = function (referencePoint) {
var clonedReferencePoint = cloneDeep(referencePoint);
var newReferencePoint = __assign({}, clonedReferencePoint, { uiConfig: cloneDeep(uiConfig_1.DEFAULT_BULLET_CHART_CONFIG) });
var buckets = bucketHelper_2.transformBuckets(newReferencePoint.buckets);
newReferencePoint[bucket_1.BUCKETS] = buckets;
newReferencePoint = bulletChartUiConfigHelper_1.getBulletChartUiConfig(newReferencePoint, this.intl, this.type);
newReferencePoint = bucketConfig_1.configurePercent(newReferencePoint, true);
newReferencePoint = bucketConfig_1.configureOverTimeComparison(newReferencePoint, !!this.featureFlags.enableWeekFilters);
newReferencePoint = propertiesHelper_1.getReferencePointWithSupportedProperties(newReferencePoint, this.supportedPropertiesList);
newReferencePoint = sort_1.removeSort(newReferencePoint);
this.setPrimaryMeasureIsMissingError(buckets);
return Promise.resolve(bucketHelper_1.sanitizeFilters(newReferencePoint));
};
PluggableBulletChart.prototype.renderConfigurationPanel = function () {
if (document.querySelector(this.configPanelElement)) {
react_dom_1.render(React.createElement(BulletChartConfigurationPanel_1.default, { locale: this.locale, references: this.references, properties: this.visualizationProperties, propertiesMeta: this.propertiesMeta, mdObject: this.mdObject, colors: this.colors, pushData: this.handlePushData, type: this.type, isError: this.isError, isLoading: this.isLoading, featureFlags: this.featureFlags }), document.querySelector(this.configPanelElement));
}
};
PluggableBulletChart.prototype.mergeDerivedBucketItems = function (referencePoint, bucket, newDerivedBucketItems) {
return bucket.items.reduce(function (resultItems, bucketItem) {
resultItems.push(bucketItem);
var newDerivedBucketItem = bucketHelper_1.findDerivedBucketItem(bucketItem, newDerivedBucketItems);
var shouldAddItem = newDerivedBucketItem &&
!bucketHelper_1.isDerivedBucketItem(bucketItem) &&
!bucketHelper_1.hasDerivedBucketItems(bucketItem, referencePoint.buckets);
if (shouldAddItem) {
resultItems.push(newDerivedBucketItem);
}
return resultItems;
}, []);
};
PluggableBulletChart.prototype.setPrimaryMeasureIsMissingError = function (measureBuckets) {
this.isError =
measureBuckets[0].items.length === 0 &&
(measureBuckets[1].items.length > 0 || measureBuckets[2].items.length > 0);
};
return PluggableBulletChart;
}(PluggableBaseChart_1.PluggableBaseChart));
exports.PluggableBulletChart = PluggableBulletChart;
//# sourceMappingURL=PluggableBulletChart.js.map