@gooddata/react-components
Version:
GoodData.UI - A powerful JavaScript library for building analytical applications
73 lines • 2.63 kB
JavaScript
;
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) 2007-2019 GoodData Corporation
var isNil = require("lodash/isNil");
var common_1 = require("./common");
function getStackConfiguration(config) {
if (config === void 0) { config = {}; }
var stackMeasures = config.stackMeasures, stackMeasuresToPercent = config.stackMeasuresToPercent;
if (isNil(stackMeasures) && isNil(stackMeasuresToPercent)) {
return config;
}
return __assign({}, config, { stacking: Boolean(stackMeasuresToPercent) || Boolean(stackMeasures) });
}
function getBucketsProps(props) {
var measures = props.measures, stackBy = props.stackBy;
var viewBy = common_1.getViewByTwoAttributes(props.viewBy);
if (viewBy.length <= 1) {
return {
measures: measures || [],
viewBy: viewBy,
stackBy: stackBy ? [stackBy] : [],
};
}
// for case viewBy 2 attributes
var firstMeasure = measures[0]; // only take first measure
var firstAttribute = viewBy[0], secondAttribute = viewBy[1]; // only take first two attributes
return {
measures: [firstMeasure],
viewBy: [firstAttribute],
stackBy: [secondAttribute],
};
}
exports.getBucketsProps = getBucketsProps;
function getConfigProps(props) {
var viewBy = common_1.getViewByTwoAttributes(props.viewBy);
if (viewBy.length <= 1) {
return getStackConfiguration(props.config);
}
return {
stacking: false,
stackMeasures: false,
stackMeasuresToPercent: false,
};
}
exports.getConfigProps = getConfigProps;
/**
* Show warning to SDK user in console log
* @param props
*/
function verifyBuckets(props) {
var viewBy = common_1.getViewByTwoAttributes(props.viewBy);
if (viewBy.length <= 1) {
return;
}
var _a = props.measures, measures = _a === void 0 ? [] : _a, stackBy = props.stackBy;
if (measures.length > 1 || stackBy) {
// tslint:disable-next-line:no-console max-line-length
console.warn("When there are two attributes in viewBy, only first measure is taken and attribute in stackBy is ignored");
}
}
exports.verifyBuckets = verifyBuckets;
//# sourceMappingURL=areaChart.js.map