@hisptz/dhis2-analytics 1.0.10 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/components/ChartAnalytics/ChartAnalytics.stories.js +1 -1
- package/build/cjs/components/CircularProgressDashboard/CircularProgressIndicator.stories.js +1 -1
- package/build/cjs/components/Map/Map.stories.js +1 -1
- package/build/cjs/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.js +1 -1
- package/build/cjs/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.js +1 -1
- package/build/cjs/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.js +8 -1
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.js +1 -1
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.js +1 -1
- package/build/cjs/components/PivotTable/PivotTable.stories.js +277 -0
- package/build/cjs/components/PivotTable/components/AssignedCategoriesIcon/index.js +32 -0
- package/build/cjs/components/PivotTable/components/PivotTable.js +60 -0
- package/build/cjs/components/PivotTable/components/PivotTableBody.js +41 -0
- package/build/cjs/components/PivotTable/components/PivotTableCell.js +40 -0
- package/build/cjs/components/PivotTable/components/PivotTableClippedAxis.js +26 -0
- package/build/cjs/components/PivotTable/components/PivotTableColumnHeaderCell.js +71 -0
- package/build/cjs/components/PivotTable/components/PivotTableColumnHeaders.js +60 -0
- package/build/cjs/components/PivotTable/components/PivotTableContainer.js +33 -0
- package/build/cjs/components/PivotTable/components/PivotTableDimensionLabelCell.js +77 -0
- package/build/cjs/components/PivotTable/components/PivotTableEmptyCell.js +22 -0
- package/build/cjs/components/PivotTable/components/PivotTableEmptyRow.js +33 -0
- package/build/cjs/components/PivotTable/components/PivotTableEngineContext.js +25 -0
- package/build/cjs/components/PivotTable/components/PivotTableHead.js +35 -0
- package/build/cjs/components/PivotTable/components/PivotTableHeaderCell.js +37 -0
- package/build/cjs/components/PivotTable/components/PivotTableRow.js +65 -0
- package/build/cjs/components/PivotTable/components/PivotTableRowHeaderCell.js +49 -0
- package/build/cjs/components/PivotTable/components/PivotTableTitleRow.js +52 -0
- package/build/cjs/components/PivotTable/components/PivotTableTitleRows.js +46 -0
- package/build/cjs/components/PivotTable/components/PivotTableValueCell.js +69 -0
- package/build/cjs/components/PivotTable/constants/dataTypes.js +129 -0
- package/build/cjs/components/PivotTable/constants/pivotTable.js +64 -0
- package/build/cjs/components/PivotTable/constants/predefinedDimensions.js +62 -0
- package/build/cjs/components/PivotTable/constants/valueTypes.js +55 -0
- package/build/cjs/components/PivotTable/data/column-data.json +210 -0
- package/build/cjs/components/PivotTable/hooks/useParentSize.js +41 -0
- package/build/cjs/components/PivotTable/hooks/useScrollPosition.js +38 -0
- package/build/cjs/components/PivotTable/hooks/useSortableColumns.js +34 -0
- package/build/cjs/components/PivotTable/hooks/useTableClipping.js +53 -0
- package/build/cjs/components/PivotTable/index.js +47 -0
- package/build/cjs/components/PivotTable/interfaces/index.js +1 -0
- package/build/cjs/components/PivotTable/services/adaptiveClippingController.js +197 -0
- package/build/cjs/components/PivotTable/services/engine.js +901 -0
- package/build/cjs/components/PivotTable/utils/getOuLevelAndGroupText.js +71 -0
- package/build/cjs/components/PivotTable/utils/index.js +322 -0
- package/build/cjs/components/PivotTable/utils/isColorBright.js +29 -0
- package/build/cjs/components/PivotTable/utils/layout/dimension.js +61 -0
- package/build/cjs/components/PivotTable/utils/layout/dimensionGetId.js +12 -0
- package/build/cjs/components/PivotTable/utils/layout/dimensionGetItems.js +12 -0
- package/build/cjs/components/PivotTable/utils/layout/dimensionIs.js +9 -0
- package/build/cjs/components/PivotTable/utils/layout/dimensionIsEmpty.js +9 -0
- package/build/cjs/components/PivotTable/utils/layout/dimensionIsValid.js +25 -0
- package/build/cjs/components/PivotTable/utils/legend.js +40 -0
- package/build/cjs/components/PivotTable/utils/ouIdHelper/index.js +27 -0
- package/build/cjs/components/SingleValueContainer/SingleValueContainer.stories.js +1 -1
- package/build/cjs/index.js +11 -0
- package/build/cjs/locales/en/translations.json +33 -0
- package/build/es/components/ChartAnalytics/ChartAnalytics.stories.js +1 -1
- package/build/es/components/CircularProgressDashboard/CircularProgressIndicator.stories.js +1 -1
- package/build/es/components/Map/Map.stories.js +1 -1
- package/build/es/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.js +1 -1
- package/build/es/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.js +1 -1
- package/build/es/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.js +8 -1
- package/build/es/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.js +1 -1
- package/build/es/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.js +1 -1
- package/build/es/components/PivotTable/PivotTable.stories.js +268 -0
- package/build/es/components/PivotTable/components/AssignedCategoriesIcon/index.js +24 -0
- package/build/es/components/PivotTable/components/PivotTable.js +51 -0
- package/build/es/components/PivotTable/components/PivotTableBody.js +33 -0
- package/build/es/components/PivotTable/components/PivotTableCell.js +32 -0
- package/build/es/components/PivotTable/components/PivotTableClippedAxis.js +18 -0
- package/build/es/components/PivotTable/components/PivotTableColumnHeaderCell.js +62 -0
- package/build/es/components/PivotTable/components/PivotTableColumnHeaders.js +52 -0
- package/build/es/components/PivotTable/components/PivotTableContainer.js +25 -0
- package/build/es/components/PivotTable/components/PivotTableDimensionLabelCell.js +68 -0
- package/build/es/components/PivotTable/components/PivotTableEmptyCell.js +14 -0
- package/build/es/components/PivotTable/components/PivotTableEmptyRow.js +25 -0
- package/build/es/components/PivotTable/components/PivotTableEngineContext.js +14 -0
- package/build/es/components/PivotTable/components/PivotTableHead.js +27 -0
- package/build/es/components/PivotTable/components/PivotTableHeaderCell.js +29 -0
- package/build/es/components/PivotTable/components/PivotTableRow.js +57 -0
- package/build/es/components/PivotTable/components/PivotTableRowHeaderCell.js +41 -0
- package/build/es/components/PivotTable/components/PivotTableTitleRow.js +42 -0
- package/build/es/components/PivotTable/components/PivotTableTitleRows.js +37 -0
- package/build/es/components/PivotTable/components/PivotTableValueCell.js +60 -0
- package/build/es/components/PivotTable/constants/dataTypes.js +98 -0
- package/build/es/components/PivotTable/constants/pivotTable.js +29 -0
- package/build/es/components/PivotTable/constants/predefinedDimensions.js +44 -0
- package/build/es/components/PivotTable/constants/valueTypes.js +27 -0
- package/build/es/components/PivotTable/data/column-data.json +210 -0
- package/build/es/components/PivotTable/hooks/useParentSize.js +33 -0
- package/build/es/components/PivotTable/hooks/useScrollPosition.js +30 -0
- package/build/es/components/PivotTable/hooks/useSortableColumns.js +27 -0
- package/build/es/components/PivotTable/hooks/useTableClipping.js +46 -0
- package/build/es/components/PivotTable/index.js +26 -0
- package/build/es/components/PivotTable/interfaces/index.js +1 -0
- package/build/es/components/PivotTable/services/adaptiveClippingController.js +191 -0
- package/build/es/components/PivotTable/services/engine.js +894 -0
- package/build/es/components/PivotTable/utils/getOuLevelAndGroupText.js +63 -0
- package/build/es/components/PivotTable/utils/index.js +309 -0
- package/build/es/components/PivotTable/utils/isColorBright.js +22 -0
- package/build/es/components/PivotTable/utils/layout/dimension.js +48 -0
- package/build/es/components/PivotTable/utils/layout/dimensionGetId.js +5 -0
- package/build/es/components/PivotTable/utils/layout/dimensionGetItems.js +5 -0
- package/build/es/components/PivotTable/utils/layout/dimensionIs.js +2 -0
- package/build/es/components/PivotTable/utils/layout/dimensionIsEmpty.js +2 -0
- package/build/es/components/PivotTable/utils/layout/dimensionIsValid.js +18 -0
- package/build/es/components/PivotTable/utils/legend.js +27 -0
- package/build/es/components/PivotTable/utils/ouIdHelper/index.js +17 -0
- package/build/es/components/SingleValueContainer/SingleValueContainer.stories.js +1 -1
- package/build/es/index.js +1 -0
- package/build/es/locales/en/translations.json +33 -0
- package/build/types/components/PivotTable/components/AssignedCategoriesIcon/index.d.ts +3 -0
- package/build/types/components/PivotTable/components/PivotTable.d.ts +12 -0
- package/build/types/components/PivotTable/components/PivotTableBody.d.ts +7 -0
- package/build/types/components/PivotTable/components/PivotTableCell.d.ts +17 -0
- package/build/types/components/PivotTable/components/PivotTableClippedAxis.d.ts +7 -0
- package/build/types/components/PivotTable/components/PivotTableColumnHeaderCell.d.ts +13 -0
- package/build/types/components/PivotTable/components/PivotTableColumnHeaders.d.ts +11 -0
- package/build/types/components/PivotTable/components/PivotTableContainer.d.ts +8 -0
- package/build/types/components/PivotTable/components/PivotTableDimensionLabelCell.d.ts +13 -0
- package/build/types/components/PivotTable/components/PivotTableEmptyCell.d.ts +7 -0
- package/build/types/components/PivotTable/components/PivotTableEmptyRow.d.ts +5 -0
- package/build/types/components/PivotTable/components/PivotTableEngineContext.d.ts +8 -0
- package/build/types/components/PivotTable/components/PivotTableHead.d.ts +21 -0
- package/build/types/components/PivotTable/components/PivotTableHeaderCell.d.ts +22 -0
- package/build/types/components/PivotTable/components/PivotTableRow.d.ts +19 -0
- package/build/types/components/PivotTable/components/PivotTableRowHeaderCell.d.ts +8 -0
- package/build/types/components/PivotTable/components/PivotTableTitleRow.d.ts +21 -0
- package/build/types/components/PivotTable/components/PivotTableTitleRows.d.ts +12 -0
- package/build/types/components/PivotTable/components/PivotTableValueCell.d.ts +8 -0
- package/build/types/components/PivotTable/constants/dataTypes.d.ts +90 -0
- package/build/types/components/PivotTable/constants/pivotTable.d.ts +29 -0
- package/build/types/components/PivotTable/constants/predefinedDimensions.d.ts +80 -0
- package/build/types/components/PivotTable/constants/valueTypes.d.ts +22 -0
- package/build/types/components/PivotTable/hooks/useParentSize.d.ts +8 -0
- package/build/types/components/PivotTable/hooks/useScrollPosition.d.ts +5 -0
- package/build/types/components/PivotTable/hooks/useSortableColumns.d.ts +8 -0
- package/build/types/components/PivotTable/hooks/useTableClipping.d.ts +24 -0
- package/build/types/components/PivotTable/index.d.ts +26 -0
- package/build/types/components/PivotTable/interfaces/index.d.ts +72 -0
- package/build/types/components/PivotTable/services/adaptiveClippingController.d.ts +44 -0
- package/build/types/components/PivotTable/services/engine.d.ts +252 -0
- package/build/types/components/PivotTable/utils/getOuLevelAndGroupText.d.ts +1 -0
- package/build/types/components/PivotTable/utils/index.d.ts +38 -0
- package/build/types/components/PivotTable/utils/isColorBright.d.ts +1 -0
- package/build/types/components/PivotTable/utils/layout/dimension.d.ts +35 -0
- package/build/types/components/PivotTable/utils/layout/dimensionGetId.d.ts +3 -0
- package/build/types/components/PivotTable/utils/layout/dimensionGetItems.d.ts +3 -0
- package/build/types/components/PivotTable/utils/layout/dimensionIs.d.ts +1 -0
- package/build/types/components/PivotTable/utils/layout/dimensionIsEmpty.d.ts +3 -0
- package/build/types/components/PivotTable/utils/layout/dimensionIsValid.d.ts +5 -0
- package/build/types/components/PivotTable/utils/legend.d.ts +11 -0
- package/build/types/components/PivotTable/utils/ouIdHelper/index.d.ts +10 -0
- package/build/types/index.d.ts +1 -0
- package/package.json +6 -3
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getOuLevelAndGroupText = void 0;
|
|
7
|
+
var _dimensionGetItems = require("./layout/dimensionGetItems.js");
|
|
8
|
+
var _dimensionIs = require("./layout/dimensionIs.js");
|
|
9
|
+
var _ouIdHelper = require("./ouIdHelper");
|
|
10
|
+
var _predefinedDimensions = require("../constants/predefinedDimensions");
|
|
11
|
+
var _d2I18n = _interopRequireDefault(require("@dhis2/d2-i18n"));
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
const getOuLevelAndGroupText = (filter, metaData) => {
|
|
14
|
+
if (!(0, _dimensionIs.dimensionIs)(_predefinedDimensions.DIMENSION_ID_ORGUNIT)) {
|
|
15
|
+
return '';
|
|
16
|
+
}
|
|
17
|
+
const items = (0, _dimensionGetItems.dimensionGetItems)(filter);
|
|
18
|
+
const hasOuLevel = items.some(item => _ouIdHelper.ouIdHelper.hasLevelPrefix(item.id));
|
|
19
|
+
const hasOuGroup = items.some(item => _ouIdHelper.ouIdHelper.hasGroupPrefix(item.id));
|
|
20
|
+
const filterFragments = [];
|
|
21
|
+
if (hasOuGroup) {
|
|
22
|
+
filterFragments.push(getLevelAndGroupText(items, metaData, false));
|
|
23
|
+
}
|
|
24
|
+
if (hasOuLevel) {
|
|
25
|
+
filterFragments.push(getLevelAndGroupText(items, metaData, true));
|
|
26
|
+
}
|
|
27
|
+
return filterFragments.join(' - ');
|
|
28
|
+
};
|
|
29
|
+
exports.getOuLevelAndGroupText = getOuLevelAndGroupText;
|
|
30
|
+
const getLevelAndGroupText = (items, metaData, isLevel) => {
|
|
31
|
+
const getNameFromMetadata = id => metaData.items[id] ? metaData.items[id].name : id;
|
|
32
|
+
const dynamicOuItems = items.filter(item => isLevel ? _ouIdHelper.ouIdHelper.hasLevelPrefix(item.id) : _ouIdHelper.ouIdHelper.hasGroupPrefix(item.id));
|
|
33
|
+
const lastItem = dynamicOuItems.length > 1 ? dynamicOuItems.pop() : null;
|
|
34
|
+
const dynamicOuNames = dynamicOuItems.map(item => getNameFromMetadata(_ouIdHelper.ouIdHelper.removePrefix(item.id))).join(', ');
|
|
35
|
+
let allDynamicOuNames;
|
|
36
|
+
if (lastItem) {
|
|
37
|
+
const lastOuName = getNameFromMetadata(_ouIdHelper.ouIdHelper.removePrefix(lastItem.id));
|
|
38
|
+
allDynamicOuNames = _d2I18n.default.t('{{dynamicOuNames}} and {{lastOuName}}', {
|
|
39
|
+
dynamicOuNames,
|
|
40
|
+
lastOuName
|
|
41
|
+
});
|
|
42
|
+
} else {
|
|
43
|
+
allDynamicOuNames = dynamicOuNames;
|
|
44
|
+
}
|
|
45
|
+
const staticOuNames = items.filter(item => !_ouIdHelper.ouIdHelper.hasGroupPrefix(item.id) && !_ouIdHelper.ouIdHelper.hasLevelPrefix(item.id)).map(item => getNameFromMetadata(item.id)).join(', ');
|
|
46
|
+
let ouLevelAndGroupText = '';
|
|
47
|
+
if (!staticOuNames) {
|
|
48
|
+
if (isLevel) {
|
|
49
|
+
ouLevelAndGroupText = _d2I18n.default.t('{{allDynamicOuNames}} levels', {
|
|
50
|
+
allDynamicOuNames
|
|
51
|
+
});
|
|
52
|
+
} else {
|
|
53
|
+
ouLevelAndGroupText = _d2I18n.default.t('{{allDynamicOuNames}} groups', {
|
|
54
|
+
allDynamicOuNames
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
if (isLevel) {
|
|
59
|
+
ouLevelAndGroupText = _d2I18n.default.t('{{allDynamicOuNames}} levels in {{staticOuNames}}', {
|
|
60
|
+
allDynamicOuNames,
|
|
61
|
+
staticOuNames
|
|
62
|
+
});
|
|
63
|
+
} else {
|
|
64
|
+
ouLevelAndGroupText = _d2I18n.default.t('{{allDynamicOuNames}} groups in {{staticOuNames}}', {
|
|
65
|
+
allDynamicOuNames,
|
|
66
|
+
staticOuNames
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return ouLevelAndGroupText;
|
|
71
|
+
};
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.clipPartitionedAxis = exports.applyLegendSet = void 0;
|
|
7
|
+
exports.getFilterText = getFilterText;
|
|
8
|
+
exports.renderValue = exports.parseValue = exports.measureTextWithWrapping = exports.getHeaderForDisplay = void 0;
|
|
9
|
+
var _getOuLevelAndGroupText = require("./getOuLevelAndGroupText");
|
|
10
|
+
var _dimensionGetItems = require("./layout/dimensionGetItems");
|
|
11
|
+
var _dimensionIs = require("./layout/dimensionIs");
|
|
12
|
+
var _ouIdHelper = require("./ouIdHelper");
|
|
13
|
+
var _predefinedDimensions = require("../constants/predefinedDimensions");
|
|
14
|
+
var _pivotTable = require("../constants/pivotTable");
|
|
15
|
+
var _valueTypes = require("../constants/valueTypes");
|
|
16
|
+
var _ui = require("@dhis2/ui");
|
|
17
|
+
var _legend = require("./legend");
|
|
18
|
+
var _isColorBright = require("./isColorBright.js");
|
|
19
|
+
// @ts-nocheck
|
|
20
|
+
|
|
21
|
+
const parseValue = valueString => {
|
|
22
|
+
const parsedValue = parseFloat(valueString);
|
|
23
|
+
if (isNaN(parsedValue)) {
|
|
24
|
+
return valueString;
|
|
25
|
+
}
|
|
26
|
+
return parsedValue;
|
|
27
|
+
};
|
|
28
|
+
exports.parseValue = parseValue;
|
|
29
|
+
let canvas;
|
|
30
|
+
const getContext = fontSize => {
|
|
31
|
+
if (!canvas) {
|
|
32
|
+
canvas = document.createElement('canvas');
|
|
33
|
+
}
|
|
34
|
+
const ctx = canvas.getContext('2d');
|
|
35
|
+
ctx.font = `${fontSize}px Roboto, Arial, sans-serif`;
|
|
36
|
+
return ctx;
|
|
37
|
+
};
|
|
38
|
+
const measureText = function (text) {
|
|
39
|
+
let fontSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 11;
|
|
40
|
+
const ctx = getContext(fontSize);
|
|
41
|
+
const textMetrics = ctx.measureText(text);
|
|
42
|
+
return textMetrics.width;
|
|
43
|
+
};
|
|
44
|
+
const measureTextWithWrapping = (text, _ref) => {
|
|
45
|
+
let {
|
|
46
|
+
fontSize = 11,
|
|
47
|
+
maxWidth = _pivotTable.CLIPPED_CELL_MAX_SIZE,
|
|
48
|
+
justifyBuffer = _pivotTable.WRAPPED_TEXT_JUSTIFY_BUFFER,
|
|
49
|
+
lineHeight = _pivotTable.WRAPPED_TEXT_LINE_HEIGHT
|
|
50
|
+
} = _ref;
|
|
51
|
+
if (!text) {
|
|
52
|
+
return {
|
|
53
|
+
width: 0,
|
|
54
|
+
height: 0
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
// Multiple consecutive linebreaks are combined into one
|
|
58
|
+
const paragraphs = String(text).split(/\n/);
|
|
59
|
+
const lines = [];
|
|
60
|
+
let currentLine = '';
|
|
61
|
+
let currentLineWidth = 0;
|
|
62
|
+
let maxLineWidth = 0;
|
|
63
|
+
while (paragraphs.length) {
|
|
64
|
+
var _paragraphs$shift$spl, _paragraphs$shift;
|
|
65
|
+
// Currently, all different whitespace types are ignored and assumed to be just a space
|
|
66
|
+
const words = (_paragraphs$shift$spl = (_paragraphs$shift = paragraphs.shift()) === null || _paragraphs$shift === void 0 ? void 0 : _paragraphs$shift.split(/\s+/)) !== null && _paragraphs$shift$spl !== void 0 ? _paragraphs$shift$spl : [];
|
|
67
|
+
while (words.length) {
|
|
68
|
+
const nextWord = (currentLineWidth === 0 ? '' : ' ') + words.shift();
|
|
69
|
+
const nextWordWidth = measureText(nextWord, fontSize);
|
|
70
|
+
if (maxWidth && currentLineWidth + nextWordWidth > maxWidth) {
|
|
71
|
+
if (currentLineWidth <= maxWidth - justifyBuffer) {
|
|
72
|
+
// Wrapping this word would cause an unnaturally short line
|
|
73
|
+
// For now we allow the cell to expand to fit this word
|
|
74
|
+
// In the future, we might intelligently hyphenate the word
|
|
75
|
+
// TODO: if splitting words how would we localize hyphens?
|
|
76
|
+
// Do nothing, keep the word on this line
|
|
77
|
+
} else {
|
|
78
|
+
maxLineWidth = Math.max(currentLineWidth, maxLineWidth);
|
|
79
|
+
lines.push(currentLine);
|
|
80
|
+
currentLine = '';
|
|
81
|
+
currentLineWidth = 0;
|
|
82
|
+
words.unshift(nextWord.substring(1)); // Get rid of the extra space
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
currentLine += nextWord;
|
|
87
|
+
currentLineWidth += nextWordWidth;
|
|
88
|
+
}
|
|
89
|
+
if (currentLineWidth > 0) {
|
|
90
|
+
maxLineWidth = Math.max(currentLineWidth, maxLineWidth);
|
|
91
|
+
lines.push(currentLine);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
normalizedText: lines.join('\n'),
|
|
96
|
+
width: maxLineWidth,
|
|
97
|
+
height: lines.length * fontSize * lineHeight // TODO: use lineHeight=1 for last line?
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
exports.measureTextWithWrapping = measureTextWithWrapping;
|
|
101
|
+
const trimTrailingZeros = stringValue => stringValue.replace(/\.?0+$/, '');
|
|
102
|
+
const decimalSeparator = '.';
|
|
103
|
+
const separateDigitGroups = (stringValue, decimalSeparator) => {
|
|
104
|
+
const isNegative = stringValue[0] === '-';
|
|
105
|
+
const [integer, remainder] = stringValue.replace(/^-/, '').split('.');
|
|
106
|
+
const groups = [];
|
|
107
|
+
for (let i = integer.length; i > 0; i -= 3) {
|
|
108
|
+
groups.unshift(integer.substring(i - 3, i));
|
|
109
|
+
}
|
|
110
|
+
if (isNegative) {
|
|
111
|
+
groups[0] = '-' + groups[0];
|
|
112
|
+
}
|
|
113
|
+
if (remainder) {
|
|
114
|
+
const trimmedRemainder = trimTrailingZeros(remainder);
|
|
115
|
+
if (trimmedRemainder.length) {
|
|
116
|
+
groups[groups.length - 1] += decimalSeparator + remainder;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return groups;
|
|
120
|
+
};
|
|
121
|
+
const getSeparator = visualization => {
|
|
122
|
+
switch (visualization.digitGroupSeparator) {
|
|
123
|
+
case 'SPACE':
|
|
124
|
+
return ' ';
|
|
125
|
+
case 'COMMA':
|
|
126
|
+
return ',';
|
|
127
|
+
case 'NONE':
|
|
128
|
+
default:
|
|
129
|
+
return '';
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
const toFixedPrecisionString = (value, skipRounding) => {
|
|
133
|
+
if (typeof value !== 'number') {
|
|
134
|
+
// Values returned from the server should keep their string representation
|
|
135
|
+
return value;
|
|
136
|
+
}
|
|
137
|
+
const precision = skipRounding ? 10 : value > -1 && value < 1 ? 2 : 1;
|
|
138
|
+
return value.toFixed(precision);
|
|
139
|
+
};
|
|
140
|
+
const renderValue = (value, valueType, visualization) => {
|
|
141
|
+
if (!(0, _valueTypes.isNumericValueType)(valueType) || value === undefined) {
|
|
142
|
+
return String(value).replace(/[^\S\n]+/, ' ');
|
|
143
|
+
}
|
|
144
|
+
if (visualization.numberType === _pivotTable.NUMBER_TYPE_ROW_PERCENTAGE || visualization.numberType === _pivotTable.NUMBER_TYPE_COLUMN_PERCENTAGE) {
|
|
145
|
+
const stringValue = trimTrailingZeros(toFixedPrecisionString(value * 100, visualization.skipRounding));
|
|
146
|
+
return separateDigitGroups(stringValue, decimalSeparator).join(getSeparator(visualization)) + '%';
|
|
147
|
+
} else {
|
|
148
|
+
const stringValue = toFixedPrecisionString(value, visualization.skipRounding);
|
|
149
|
+
return separateDigitGroups(stringValue, decimalSeparator).join(getSeparator(visualization));
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
exports.renderValue = renderValue;
|
|
153
|
+
const getLegendSet = (engine, dxDimension) => {
|
|
154
|
+
var _engine$visualization, _engine$visualization2, _engine$visualization3;
|
|
155
|
+
let legendSetId;
|
|
156
|
+
switch ((_engine$visualization = engine.visualization.legend) === null || _engine$visualization === void 0 ? void 0 : _engine$visualization.strategy) {
|
|
157
|
+
case _legend.LEGEND_DISPLAY_STRATEGY_BY_DATA_ITEM:
|
|
158
|
+
if (dxDimension && dxDimension.legendSet) {
|
|
159
|
+
legendSetId = dxDimension.legendSet;
|
|
160
|
+
}
|
|
161
|
+
break;
|
|
162
|
+
case _legend.LEGEND_DISPLAY_STRATEGY_FIXED:
|
|
163
|
+
default:
|
|
164
|
+
legendSetId = (_engine$visualization2 = engine.visualization.legend) === null || _engine$visualization2 === void 0 ? void 0 : (_engine$visualization3 = _engine$visualization2.set) === null || _engine$visualization3 === void 0 ? void 0 : _engine$visualization3.id;
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
return engine.legendSets[legendSetId];
|
|
168
|
+
};
|
|
169
|
+
const buildStyleObject = (legendColor, engine) => {
|
|
170
|
+
var _engine$visualization4;
|
|
171
|
+
const style = {};
|
|
172
|
+
switch ((_engine$visualization4 = engine.visualization.legend) === null || _engine$visualization4 === void 0 ? void 0 : _engine$visualization4.style) {
|
|
173
|
+
case _legend.LEGEND_DISPLAY_STYLE_TEXT:
|
|
174
|
+
style.color = legendColor;
|
|
175
|
+
break;
|
|
176
|
+
case _legend.LEGEND_DISPLAY_STYLE_FILL:
|
|
177
|
+
default:
|
|
178
|
+
style.backgroundColor = legendColor;
|
|
179
|
+
if ((0, _isColorBright.isColorBright)(legendColor)) {
|
|
180
|
+
style.color = _ui.colors.grey900;
|
|
181
|
+
} else {
|
|
182
|
+
style.color = _ui.colors.white;
|
|
183
|
+
}
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
return style;
|
|
187
|
+
};
|
|
188
|
+
const applyLegendSet = (value, dxDimension, engine) => {
|
|
189
|
+
if (isNaN(value) || !engine.legendSets) {
|
|
190
|
+
return {};
|
|
191
|
+
}
|
|
192
|
+
const legendSet = getLegendSet(engine, dxDimension);
|
|
193
|
+
if (!legendSet) {
|
|
194
|
+
return {};
|
|
195
|
+
}
|
|
196
|
+
const legendColor = (0, _legend.getColorByValueFromLegendSet)(legendSet, value);
|
|
197
|
+
if (!legendColor) {
|
|
198
|
+
return {};
|
|
199
|
+
}
|
|
200
|
+
return buildStyleObject(legendColor, engine);
|
|
201
|
+
};
|
|
202
|
+
exports.applyLegendSet = applyLegendSet;
|
|
203
|
+
function getFilterText(filters, metaData) {
|
|
204
|
+
if (!Array.isArray(filters) || !filters.length) {
|
|
205
|
+
return '';
|
|
206
|
+
}
|
|
207
|
+
const titleFragments = [];
|
|
208
|
+
let i;
|
|
209
|
+
let l;
|
|
210
|
+
filters.forEach(filter => {
|
|
211
|
+
const items = (0, _dimensionGetItems.dimensionGetItems)(filter);
|
|
212
|
+
if ((0, _dimensionIs.dimensionIs)(filter, _predefinedDimensions.DIMENSION_ID_ORGUNIT) && items.some(_ref2 => {
|
|
213
|
+
let {
|
|
214
|
+
id
|
|
215
|
+
} = _ref2;
|
|
216
|
+
return _ouIdHelper.ouIdHelper.hasGroupPrefix(id) || _ouIdHelper.ouIdHelper.hasLevelPrefix(id);
|
|
217
|
+
})) {
|
|
218
|
+
titleFragments.push((0, _getOuLevelAndGroupText.getOuLevelAndGroupText)(filter, metaData));
|
|
219
|
+
} else {
|
|
220
|
+
const filterItems = metaData.dimensions[filter.dimension];
|
|
221
|
+
if (Array.isArray(filterItems)) {
|
|
222
|
+
l = filterItems.length;
|
|
223
|
+
let id;
|
|
224
|
+
const sectionParts = [];
|
|
225
|
+
for (i = 0; i < l; i++) {
|
|
226
|
+
id = filterItems[i];
|
|
227
|
+
|
|
228
|
+
// if the value is present in items take the name to show from there
|
|
229
|
+
if (metaData.items[id]) {
|
|
230
|
+
sectionParts.push(metaData.items[id].name);
|
|
231
|
+
}
|
|
232
|
+
// otherwise use the values directly
|
|
233
|
+
// this is a temporary fix to avoid app crashing when using filters with data items in EV
|
|
234
|
+
else {
|
|
235
|
+
sectionParts.push(metaData.items[filter.dimension].name + ': ' + filterItems.join(', '));
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
titleFragments.push(sectionParts.join(', '));
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
return titleFragments.join(' - ');
|
|
244
|
+
}
|
|
245
|
+
const headerStacksAreEqual = (a, b, limit) => {
|
|
246
|
+
for (let i = 0; i <= limit; ++i) {
|
|
247
|
+
if (a[i] !== b[i]) {
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return true;
|
|
252
|
+
};
|
|
253
|
+
const getHeaderForDisplay = _ref3 => {
|
|
254
|
+
let {
|
|
255
|
+
start,
|
|
256
|
+
count,
|
|
257
|
+
index,
|
|
258
|
+
dimensionLevel,
|
|
259
|
+
getHeader,
|
|
260
|
+
showHierarchy
|
|
261
|
+
} = _ref3;
|
|
262
|
+
const header = getHeader(index);
|
|
263
|
+
const showHeader = index === start || !headerStacksAreEqual(header, getHeader(index - 1), dimensionLevel);
|
|
264
|
+
if (!showHeader) {
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
let span = 1;
|
|
268
|
+
for (let i = index + 1; i < start + count; ++i) {
|
|
269
|
+
if (!headerStacksAreEqual(getHeader(i), header, dimensionLevel)) {
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
++span;
|
|
273
|
+
}
|
|
274
|
+
const currentHeader = header[dimensionLevel];
|
|
275
|
+
const includesHierarchy = showHierarchy && (currentHeader === null || currentHeader === void 0 ? void 0 : currentHeader.hierarchy);
|
|
276
|
+
const label = includesHierarchy ? currentHeader.hierarchy.join(' / ') : currentHeader === null || currentHeader === void 0 ? void 0 : currentHeader.name;
|
|
277
|
+
return {
|
|
278
|
+
span,
|
|
279
|
+
label,
|
|
280
|
+
includesHierarchy
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
exports.getHeaderForDisplay = getHeaderForDisplay;
|
|
284
|
+
const clipPartitionedAxis = _ref4 => {
|
|
285
|
+
let {
|
|
286
|
+
partitionSize,
|
|
287
|
+
partitions,
|
|
288
|
+
axisMap,
|
|
289
|
+
widthMap,
|
|
290
|
+
viewportWidth,
|
|
291
|
+
viewportPosition,
|
|
292
|
+
totalWidth
|
|
293
|
+
} = _ref4;
|
|
294
|
+
const partition = Math.floor(viewportPosition / partitionSize);
|
|
295
|
+
if (partitions[partition] === undefined) {
|
|
296
|
+
return {
|
|
297
|
+
indices: [0],
|
|
298
|
+
pre: 0,
|
|
299
|
+
post: 0
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
let start = partitions[partition] - partitions[0];
|
|
303
|
+
while (start < axisMap.length && widthMap[axisMap[start]].pre < viewportPosition) {
|
|
304
|
+
++start;
|
|
305
|
+
}
|
|
306
|
+
start = start === 0 ? start : start - 1;
|
|
307
|
+
const pre = widthMap[axisMap[start]].pre;
|
|
308
|
+
const indices = [];
|
|
309
|
+
let end = start;
|
|
310
|
+
while (end < axisMap.length && widthMap[axisMap[end]].pre < viewportPosition + viewportWidth) {
|
|
311
|
+
indices.push(end);
|
|
312
|
+
++end;
|
|
313
|
+
}
|
|
314
|
+
end = end === 0 ? end : end - 1;
|
|
315
|
+
const post = totalWidth - (widthMap[axisMap[end]].pre + widthMap[axisMap[end]].size);
|
|
316
|
+
return {
|
|
317
|
+
indices,
|
|
318
|
+
pre,
|
|
319
|
+
post
|
|
320
|
+
};
|
|
321
|
+
};
|
|
322
|
+
exports.clipPartitionedAxis = clipPartitionedAxis;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isColorBright = void 0;
|
|
7
|
+
const calculateColorBrightness = function (rgb) {
|
|
8
|
+
if (!rgb) {
|
|
9
|
+
return 0;
|
|
10
|
+
}
|
|
11
|
+
return Math.round((parseInt(rgb[0]) * 299 + parseInt(rgb[1]) * 587 + parseInt(rgb[2]) * 114) / 1000);
|
|
12
|
+
};
|
|
13
|
+
const isHex = color => {
|
|
14
|
+
return typeof color === 'string' && color.charAt(0) === '#';
|
|
15
|
+
};
|
|
16
|
+
const hexToRgb = hex => {
|
|
17
|
+
let result;
|
|
18
|
+
if (typeof hex === "string") {
|
|
19
|
+
result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
20
|
+
}
|
|
21
|
+
return result ? [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16)] : null;
|
|
22
|
+
};
|
|
23
|
+
const isColorBright = color => {
|
|
24
|
+
if (isHex(color)) {
|
|
25
|
+
color = hexToRgb(color);
|
|
26
|
+
}
|
|
27
|
+
return calculateColorBrightness(color) > 125;
|
|
28
|
+
};
|
|
29
|
+
exports.isColorBright = isColorBright;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DIMENSION_PROP_REPETITION = exports.DIMENSION_PROP_PROGRAM_STAGE = exports.DIMENSION_PROP_LEGEND_SET = exports.DIMENSION_PROP_ITEMS = exports.DIMENSION_PROP_ID = exports.DIMENSION_PROP_FILTER = exports.DIMENSION_PROPS = exports.DIMENSION = void 0;
|
|
7
|
+
var _isObject = _interopRequireDefault(require("lodash/isObject"));
|
|
8
|
+
var _isString = _interopRequireDefault(require("lodash/isString"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
// Dimension
|
|
11
|
+
|
|
12
|
+
const DIMENSION = {
|
|
13
|
+
isValid: dimension => (0, _isObject.default)(dimension)
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// Props
|
|
17
|
+
exports.DIMENSION = DIMENSION;
|
|
18
|
+
const DIMENSION_PROP_ID = {
|
|
19
|
+
name: 'dimension',
|
|
20
|
+
defaultValue: '',
|
|
21
|
+
required: true,
|
|
22
|
+
isValid: prop => (0, _isString.default)(prop)
|
|
23
|
+
};
|
|
24
|
+
exports.DIMENSION_PROP_ID = DIMENSION_PROP_ID;
|
|
25
|
+
const DIMENSION_PROP_ITEMS = {
|
|
26
|
+
name: 'items',
|
|
27
|
+
defaultValue: [],
|
|
28
|
+
required: false,
|
|
29
|
+
isValid: prop => Array.isArray(prop)
|
|
30
|
+
};
|
|
31
|
+
exports.DIMENSION_PROP_ITEMS = DIMENSION_PROP_ITEMS;
|
|
32
|
+
const DIMENSION_PROP_FILTER = {
|
|
33
|
+
name: 'filter',
|
|
34
|
+
defaultValue: [],
|
|
35
|
+
required: false,
|
|
36
|
+
isValid: prop => (0, _isString.default)(prop)
|
|
37
|
+
};
|
|
38
|
+
exports.DIMENSION_PROP_FILTER = DIMENSION_PROP_FILTER;
|
|
39
|
+
const DIMENSION_PROP_LEGEND_SET = {
|
|
40
|
+
name: 'legendSet',
|
|
41
|
+
defaultValue: [],
|
|
42
|
+
required: false,
|
|
43
|
+
isValid: prop => (0, _isString.default)(prop)
|
|
44
|
+
};
|
|
45
|
+
exports.DIMENSION_PROP_LEGEND_SET = DIMENSION_PROP_LEGEND_SET;
|
|
46
|
+
const DIMENSION_PROP_PROGRAM_STAGE = {
|
|
47
|
+
name: 'programStage',
|
|
48
|
+
defaultValue: {},
|
|
49
|
+
required: false,
|
|
50
|
+
isValid: prop => (0, _isObject.default)(prop)
|
|
51
|
+
};
|
|
52
|
+
exports.DIMENSION_PROP_PROGRAM_STAGE = DIMENSION_PROP_PROGRAM_STAGE;
|
|
53
|
+
const DIMENSION_PROP_REPETITION = {
|
|
54
|
+
name: 'repetition',
|
|
55
|
+
defaultValue: [],
|
|
56
|
+
required: false,
|
|
57
|
+
isValid: prop => Array.isArray(prop)
|
|
58
|
+
};
|
|
59
|
+
exports.DIMENSION_PROP_REPETITION = DIMENSION_PROP_REPETITION;
|
|
60
|
+
const DIMENSION_PROPS = [DIMENSION_PROP_ID, DIMENSION_PROP_ITEMS, DIMENSION_PROP_FILTER, DIMENSION_PROP_LEGEND_SET, DIMENSION_PROP_PROGRAM_STAGE, DIMENSION_PROP_REPETITION];
|
|
61
|
+
exports.DIMENSION_PROPS = DIMENSION_PROPS;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.dimensionGetId = void 0;
|
|
7
|
+
var _dimension = require("./dimension");
|
|
8
|
+
const dimensionGetId = dimension => {
|
|
9
|
+
var _dimension$DIMENSION_;
|
|
10
|
+
return (_dimension$DIMENSION_ = dimension[_dimension.DIMENSION_PROP_PROGRAM_STAGE.name]) !== null && _dimension$DIMENSION_ !== void 0 && _dimension$DIMENSION_.id ? `${dimension[_dimension.DIMENSION_PROP_PROGRAM_STAGE.name].id}.${dimension[_dimension.DIMENSION_PROP_ID.name]}` : dimension[_dimension.DIMENSION_PROP_ID.name];
|
|
11
|
+
};
|
|
12
|
+
exports.dimensionGetId = dimensionGetId;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.dimensionGetItems = void 0;
|
|
7
|
+
var _dimension = require("./dimension");
|
|
8
|
+
var _dimensionIsValid = require("./dimensionIsValid");
|
|
9
|
+
const dimensionGetItems = dimension => (0, _dimensionIsValid.dimensionIsValid)(dimension, {
|
|
10
|
+
requireItems: true
|
|
11
|
+
}) ? dimension[_dimension.DIMENSION_PROP_ITEMS.name] : _dimension.DIMENSION_PROP_ITEMS.defaultValue;
|
|
12
|
+
exports.dimensionGetItems = dimensionGetItems;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.dimensionIs = void 0;
|
|
7
|
+
var _dimension = require("./dimension");
|
|
8
|
+
const dimensionIs = (dimension, dimensionId) => dimension[_dimension.DIMENSION_PROP_ID.name] === dimensionId;
|
|
9
|
+
exports.dimensionIs = dimensionIs;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.dimensionIsEmpty = void 0;
|
|
7
|
+
var _dimension = require("./dimension");
|
|
8
|
+
const dimensionIsEmpty = dimension => !(_dimension.DIMENSION.isValid(dimension) && _dimension.DIMENSION_PROP_ITEMS.isValid(dimension[_dimension.DIMENSION_PROP_ITEMS.name]) && dimension[_dimension.DIMENSION_PROP_ITEMS.name].length);
|
|
9
|
+
exports.dimensionIsEmpty = dimensionIsEmpty;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.dimensionIsValid = void 0;
|
|
7
|
+
var _dimension = require("./dimension");
|
|
8
|
+
var _dimensionIsEmpty = require("./dimensionIsEmpty");
|
|
9
|
+
const dimensionIsValid = function (dimension) {
|
|
10
|
+
let {
|
|
11
|
+
requireItems
|
|
12
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
13
|
+
if (!_dimension.DIMENSION.isValid(dimension)) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
const requiredProps = _dimension.DIMENSION_PROPS.filter(prop => prop.required);
|
|
17
|
+
if (!requiredProps.every(prop => prop.isValid(dimension[prop.name]))) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
if (requireItems === true && (0, _dimensionIsEmpty.dimensionIsEmpty)(dimension)) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
};
|
|
25
|
+
exports.dimensionIsValid = dimensionIsValid;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getLegendSetByDisplayStrategy = exports.getLegendByValueFromLegendSet = exports.getColorByValueFromLegendSet = exports.LEGEND_DISPLAY_STYLE_TEXT = exports.LEGEND_DISPLAY_STYLE_FILL = exports.LEGEND_DISPLAY_STRATEGY_FIXED = exports.LEGEND_DISPLAY_STRATEGY_BY_DATA_ITEM = void 0;
|
|
7
|
+
const LEGEND_DISPLAY_STRATEGY_BY_DATA_ITEM = 'BY_DATA_ITEM';
|
|
8
|
+
exports.LEGEND_DISPLAY_STRATEGY_BY_DATA_ITEM = LEGEND_DISPLAY_STRATEGY_BY_DATA_ITEM;
|
|
9
|
+
const LEGEND_DISPLAY_STRATEGY_FIXED = 'FIXED';
|
|
10
|
+
exports.LEGEND_DISPLAY_STRATEGY_FIXED = LEGEND_DISPLAY_STRATEGY_FIXED;
|
|
11
|
+
const LEGEND_DISPLAY_STYLE_FILL = 'FILL';
|
|
12
|
+
exports.LEGEND_DISPLAY_STYLE_FILL = LEGEND_DISPLAY_STYLE_FILL;
|
|
13
|
+
const LEGEND_DISPLAY_STYLE_TEXT = 'TEXT';
|
|
14
|
+
exports.LEGEND_DISPLAY_STYLE_TEXT = LEGEND_DISPLAY_STYLE_TEXT;
|
|
15
|
+
const getLegendByValueFromLegendSet = (legendSet, value) => {
|
|
16
|
+
var _legendSet$legends;
|
|
17
|
+
return Number.isInteger(parseInt(value)) ? legendSet === null || legendSet === void 0 ? void 0 : (_legendSet$legends = legendSet.legends) === null || _legendSet$legends === void 0 ? void 0 : _legendSet$legends.find(legend => value >= legend.startValue && value < legend.endValue // TODO: Confirm inclusive/exclusive bounds
|
|
18
|
+
) : null;
|
|
19
|
+
};
|
|
20
|
+
exports.getLegendByValueFromLegendSet = getLegendByValueFromLegendSet;
|
|
21
|
+
const getColorByValueFromLegendSet = (legendSet, value) => {
|
|
22
|
+
const legend = getLegendByValueFromLegendSet(legendSet, value);
|
|
23
|
+
return legend && legend.color;
|
|
24
|
+
};
|
|
25
|
+
exports.getColorByValueFromLegendSet = getColorByValueFromLegendSet;
|
|
26
|
+
const getLegendSetByDisplayStrategy = _ref => {
|
|
27
|
+
let {
|
|
28
|
+
displayStrategy,
|
|
29
|
+
legendSets,
|
|
30
|
+
legendSetId
|
|
31
|
+
} = _ref;
|
|
32
|
+
if (displayStrategy === LEGEND_DISPLAY_STRATEGY_FIXED && legendSets.length) {
|
|
33
|
+
return legendSets[0];
|
|
34
|
+
} else if (displayStrategy === LEGEND_DISPLAY_STRATEGY_BY_DATA_ITEM) {
|
|
35
|
+
return legendSets.find(legendSet => legendSet.id === legendSetId);
|
|
36
|
+
} else {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.getLegendSetByDisplayStrategy = getLegendSetByDisplayStrategy;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ouIdHelper = exports.USER_ORG_UNIT_GRANDCHILDREN = exports.USER_ORG_UNIT_CHILDREN = exports.USER_ORG_UNIT = void 0;
|
|
7
|
+
const LEVEL_ID_PREFIX = 'LEVEL';
|
|
8
|
+
const GROUP_ID_PREFIX = 'OU_GROUP';
|
|
9
|
+
const USER_ORG_UNIT = 'USER_ORGUNIT';
|
|
10
|
+
exports.USER_ORG_UNIT = USER_ORG_UNIT;
|
|
11
|
+
const USER_ORG_UNIT_CHILDREN = 'USER_ORGUNIT_CHILDREN';
|
|
12
|
+
exports.USER_ORG_UNIT_CHILDREN = USER_ORG_UNIT_CHILDREN;
|
|
13
|
+
const USER_ORG_UNIT_GRANDCHILDREN = 'USER_ORGUNIT_GRANDCHILDREN';
|
|
14
|
+
exports.USER_ORG_UNIT_GRANDCHILDREN = USER_ORG_UNIT_GRANDCHILDREN;
|
|
15
|
+
const hasGroupPrefix = id => id.substr(0, GROUP_ID_PREFIX.length) === GROUP_ID_PREFIX;
|
|
16
|
+
const hasLevelPrefix = id => id.substr(0, LEVEL_ID_PREFIX.length) === LEVEL_ID_PREFIX;
|
|
17
|
+
const stripLevelPrefix = id => hasLevelPrefix(id) ? id.substr(LEVEL_ID_PREFIX.length + 1) : id;
|
|
18
|
+
const stripGroupPrefix = id => hasGroupPrefix(id) ? id.substr(GROUP_ID_PREFIX.length + 1) : id;
|
|
19
|
+
const removePrefix = id => stripGroupPrefix(stripLevelPrefix(id));
|
|
20
|
+
const ouIdHelper = Object.freeze({
|
|
21
|
+
addLevelPrefix: id => `${LEVEL_ID_PREFIX}-${removePrefix(id)}`,
|
|
22
|
+
addGroupPrefix: id => `${GROUP_ID_PREFIX}-${removePrefix(id)}`,
|
|
23
|
+
removePrefix,
|
|
24
|
+
hasGroupPrefix,
|
|
25
|
+
hasLevelPrefix
|
|
26
|
+
});
|
|
27
|
+
exports.ouIdHelper = ouIdHelper;
|
|
@@ -118,7 +118,7 @@ SingleValuesWithDecimalPlaces.args = {
|
|
|
118
118
|
}]
|
|
119
119
|
};
|
|
120
120
|
var _default = {
|
|
121
|
-
title: "
|
|
121
|
+
title: "Analytics/Single Value Container",
|
|
122
122
|
component: _.SingleValueContainer,
|
|
123
123
|
decorators: [SingleValueStory => {
|
|
124
124
|
return /*#__PURE__*/_react.default.createElement(SingleValueStory, null);
|
package/build/cjs/index.js
CHANGED
|
@@ -46,4 +46,15 @@ Object.keys(_SingleValueContainer).forEach(function (key) {
|
|
|
46
46
|
return _SingleValueContainer[key];
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
|
+
});
|
|
50
|
+
var _PivotTable = require("./components/PivotTable");
|
|
51
|
+
Object.keys(_PivotTable).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _PivotTable[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _PivotTable[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
49
60
|
});
|