@dhis2/analytics 26.8.1 → 26.8.3
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/AboutAOUnit/utils.js +17 -1
- package/build/cjs/locales/en/translations.json +2 -0
- package/build/cjs/modules/__tests__/renderValue.spec.js +10 -10
- package/build/cjs/modules/pivotTable/PivotTableEngine.js +6 -1
- package/build/cjs/modules/renderValue.js +1 -1
- package/build/es/components/AboutAOUnit/utils.js +14 -0
- package/build/es/locales/en/translations.json +2 -0
- package/build/es/modules/__tests__/renderValue.spec.js +10 -10
- package/build/es/modules/pivotTable/PivotTableEngine.js +7 -2
- package/build/es/modules/renderValue.js +1 -1
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getTranslatedString = exports.AO_TYPE_VISUALIZATION = exports.AO_TYPE_MAP = exports.AO_TYPE_EVENT_VISUALIZATION = exports.AOTypeMap = void 0;
|
|
6
|
+
exports.getTranslatedString = exports.AO_TYPE_VISUALIZATION = exports.AO_TYPE_MAP = exports.AO_TYPE_EVENT_VISUALIZATION = exports.AO_TYPE_EVENT_REPORT = exports.AO_TYPE_EVENT_CHART = exports.AOTypeMap = void 0;
|
|
7
7
|
var _d2I18n = _interopRequireDefault(require("@dhis2/d2-i18n"));
|
|
8
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
9
|
const AO_TYPE_VISUALIZATION = 'visualization';
|
|
@@ -12,6 +12,10 @@ const AO_TYPE_MAP = 'map';
|
|
|
12
12
|
exports.AO_TYPE_MAP = AO_TYPE_MAP;
|
|
13
13
|
const AO_TYPE_EVENT_VISUALIZATION = 'eventVisualization';
|
|
14
14
|
exports.AO_TYPE_EVENT_VISUALIZATION = AO_TYPE_EVENT_VISUALIZATION;
|
|
15
|
+
const AO_TYPE_EVENT_CHART = 'eventChart';
|
|
16
|
+
exports.AO_TYPE_EVENT_CHART = AO_TYPE_EVENT_CHART;
|
|
17
|
+
const AO_TYPE_EVENT_REPORT = 'eventReport';
|
|
18
|
+
exports.AO_TYPE_EVENT_REPORT = AO_TYPE_EVENT_REPORT;
|
|
15
19
|
const AOTypeMap = {
|
|
16
20
|
[AO_TYPE_VISUALIZATION]: {
|
|
17
21
|
apiEndpoint: 'visualizations'
|
|
@@ -21,6 +25,12 @@ const AOTypeMap = {
|
|
|
21
25
|
},
|
|
22
26
|
[AO_TYPE_EVENT_VISUALIZATION]: {
|
|
23
27
|
apiEndpoint: 'eventVisualizations'
|
|
28
|
+
},
|
|
29
|
+
[AO_TYPE_EVENT_CHART]: {
|
|
30
|
+
apiEndpoint: 'eventCharts'
|
|
31
|
+
},
|
|
32
|
+
[AO_TYPE_EVENT_REPORT]: {
|
|
33
|
+
apiEndpoint: 'eventReports'
|
|
24
34
|
}
|
|
25
35
|
};
|
|
26
36
|
exports.AOTypeMap = AOTypeMap;
|
|
@@ -35,6 +45,12 @@ const texts = {
|
|
|
35
45
|
[AO_TYPE_VISUALIZATION]: {
|
|
36
46
|
unitTitle: _d2I18n.default.t('About this visualization')
|
|
37
47
|
},
|
|
48
|
+
[AO_TYPE_EVENT_CHART]: {
|
|
49
|
+
unitTitle: _d2I18n.default.t('About this event chart')
|
|
50
|
+
},
|
|
51
|
+
[AO_TYPE_EVENT_REPORT]: {
|
|
52
|
+
unitTitle: _d2I18n.default.t('About this event report')
|
|
53
|
+
},
|
|
38
54
|
[NO_TYPE]: {
|
|
39
55
|
unitTitle: _d2I18n.default.t('About this visualization')
|
|
40
56
|
}
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
"About this map": "About this map",
|
|
20
20
|
"About this line list": "About this line list",
|
|
21
21
|
"About this visualization": "About this visualization",
|
|
22
|
+
"About this event chart": "About this event chart",
|
|
23
|
+
"About this event report": "About this event report",
|
|
22
24
|
"This app could not retrieve required data.": "This app could not retrieve required data.",
|
|
23
25
|
"Network error": "Network error",
|
|
24
26
|
"Data / Edit calculation": "Data / Edit calculation",
|
|
@@ -10,19 +10,19 @@ const tests = [
|
|
|
10
10
|
// Numbers
|
|
11
11
|
{
|
|
12
12
|
value: 1000.5,
|
|
13
|
-
expected: '1 000.
|
|
13
|
+
expected: '1 000.50',
|
|
14
14
|
valueType: _valueTypes.VALUE_TYPE_NUMBER,
|
|
15
15
|
round: true,
|
|
16
16
|
dgs: DGS_SPACE
|
|
17
17
|
}, {
|
|
18
|
-
value: 33777889.
|
|
19
|
-
expected: '33,777,889.
|
|
18
|
+
value: 33777889.555,
|
|
19
|
+
expected: '33,777,889.55',
|
|
20
20
|
valueType: _valueTypes.VALUE_TYPE_NUMBER,
|
|
21
21
|
round: true,
|
|
22
22
|
dgs: DGS_COMMA
|
|
23
23
|
}, {
|
|
24
24
|
value: 33777889.556,
|
|
25
|
-
expected: '33 777 889.
|
|
25
|
+
expected: '33 777 889.56',
|
|
26
26
|
valueType: _valueTypes.VALUE_TYPE_NUMBER,
|
|
27
27
|
round: true,
|
|
28
28
|
dgs: DGS_SPACE
|
|
@@ -35,7 +35,7 @@ const tests = [
|
|
|
35
35
|
dgs: DGS_SPACE
|
|
36
36
|
}, {
|
|
37
37
|
value: 33777889.56,
|
|
38
|
-
expected: '33777889.
|
|
38
|
+
expected: '33777889.56',
|
|
39
39
|
valueType: _valueTypes.VALUE_TYPE_NUMBER,
|
|
40
40
|
round: true,
|
|
41
41
|
dgs: DGS_NONE
|
|
@@ -53,7 +53,7 @@ const tests = [
|
|
|
53
53
|
dgs: DGS_SPACE
|
|
54
54
|
}, {
|
|
55
55
|
value: 1.101,
|
|
56
|
-
expected: '1.
|
|
56
|
+
expected: '1.10',
|
|
57
57
|
valueType: _valueTypes.VALUE_TYPE_NUMBER,
|
|
58
58
|
round: true,
|
|
59
59
|
dgs: DGS_SPACE
|
|
@@ -107,15 +107,15 @@ const tests = [
|
|
|
107
107
|
round: false,
|
|
108
108
|
dgs: DGS_SPACE
|
|
109
109
|
}, {
|
|
110
|
-
value: -0.
|
|
111
|
-
expected: '-2.
|
|
110
|
+
value: -0.02345,
|
|
111
|
+
expected: '-2.34%',
|
|
112
112
|
valueType: _valueTypes.VALUE_TYPE_NUMBER,
|
|
113
113
|
numberType: _pivotTableConstants.NUMBER_TYPE_ROW_PERCENTAGE,
|
|
114
114
|
round: true,
|
|
115
115
|
dgs: DGS_SPACE
|
|
116
116
|
}, {
|
|
117
|
-
value: -0.
|
|
118
|
-
expected: '-2.
|
|
117
|
+
value: -0.02345,
|
|
118
|
+
expected: '-2.345%',
|
|
119
119
|
valueType: _valueTypes.VALUE_TYPE_NUMBER,
|
|
120
120
|
numberType: _pivotTableConstants.NUMBER_TYPE_ROW_PERCENTAGE,
|
|
121
121
|
round: false,
|
|
@@ -550,7 +550,12 @@ class PivotTableEngine {
|
|
|
550
550
|
} else {
|
|
551
551
|
totalCell.valueType = currentValueType;
|
|
552
552
|
}
|
|
553
|
-
|
|
553
|
+
|
|
554
|
+
// compute subtotals and totals for all numeric and boolean value types
|
|
555
|
+
// in that case, force value type of subtotal and total cells to NUMBER to format them correctly
|
|
556
|
+
// (see DHIS2-9155)
|
|
557
|
+
if ((0, _valueTypes.isNumericValueType)(dxDimension === null || dxDimension === void 0 ? void 0 : dxDimension.valueType) || (0, _valueTypes.isBooleanValueType)(dxDimension === null || dxDimension === void 0 ? void 0 : dxDimension.valueType)) {
|
|
558
|
+
totalCell.valueType = _valueTypes.VALUE_TYPE_NUMBER;
|
|
554
559
|
dataFields.forEach(field => {
|
|
555
560
|
const headerIndex = this.dimensionLookup.dataHeaders[field];
|
|
556
561
|
const value = (0, _parseValue.parseValue)(dataRow[headerIndex]);
|
|
@@ -43,7 +43,7 @@ const toFixedPrecisionString = (value, skipRounding) => {
|
|
|
43
43
|
// Values returned from the server should keep their string representation
|
|
44
44
|
return value;
|
|
45
45
|
}
|
|
46
|
-
const precision = skipRounding ? 10 :
|
|
46
|
+
const precision = skipRounding ? 10 : 2;
|
|
47
47
|
return value.toFixed(precision);
|
|
48
48
|
};
|
|
49
49
|
const renderValue = (value, valueType, visualization) => {
|
|
@@ -2,6 +2,8 @@ import i18n from '@dhis2/d2-i18n';
|
|
|
2
2
|
export const AO_TYPE_VISUALIZATION = 'visualization';
|
|
3
3
|
export const AO_TYPE_MAP = 'map';
|
|
4
4
|
export const AO_TYPE_EVENT_VISUALIZATION = 'eventVisualization';
|
|
5
|
+
export const AO_TYPE_EVENT_CHART = 'eventChart';
|
|
6
|
+
export const AO_TYPE_EVENT_REPORT = 'eventReport';
|
|
5
7
|
export const AOTypeMap = {
|
|
6
8
|
[AO_TYPE_VISUALIZATION]: {
|
|
7
9
|
apiEndpoint: 'visualizations'
|
|
@@ -11,6 +13,12 @@ export const AOTypeMap = {
|
|
|
11
13
|
},
|
|
12
14
|
[AO_TYPE_EVENT_VISUALIZATION]: {
|
|
13
15
|
apiEndpoint: 'eventVisualizations'
|
|
16
|
+
},
|
|
17
|
+
[AO_TYPE_EVENT_CHART]: {
|
|
18
|
+
apiEndpoint: 'eventCharts'
|
|
19
|
+
},
|
|
20
|
+
[AO_TYPE_EVENT_REPORT]: {
|
|
21
|
+
apiEndpoint: 'eventReports'
|
|
14
22
|
}
|
|
15
23
|
};
|
|
16
24
|
const NO_TYPE = 'NO_TYPE';
|
|
@@ -24,6 +32,12 @@ const texts = {
|
|
|
24
32
|
[AO_TYPE_VISUALIZATION]: {
|
|
25
33
|
unitTitle: i18n.t('About this visualization')
|
|
26
34
|
},
|
|
35
|
+
[AO_TYPE_EVENT_CHART]: {
|
|
36
|
+
unitTitle: i18n.t('About this event chart')
|
|
37
|
+
},
|
|
38
|
+
[AO_TYPE_EVENT_REPORT]: {
|
|
39
|
+
unitTitle: i18n.t('About this event report')
|
|
40
|
+
},
|
|
27
41
|
[NO_TYPE]: {
|
|
28
42
|
unitTitle: i18n.t('About this visualization')
|
|
29
43
|
}
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
"About this map": "About this map",
|
|
20
20
|
"About this line list": "About this line list",
|
|
21
21
|
"About this visualization": "About this visualization",
|
|
22
|
+
"About this event chart": "About this event chart",
|
|
23
|
+
"About this event report": "About this event report",
|
|
22
24
|
"This app could not retrieve required data.": "This app could not retrieve required data.",
|
|
23
25
|
"Network error": "Network error",
|
|
24
26
|
"Data / Edit calculation": "Data / Edit calculation",
|
|
@@ -8,19 +8,19 @@ const tests = [
|
|
|
8
8
|
// Numbers
|
|
9
9
|
{
|
|
10
10
|
value: 1000.5,
|
|
11
|
-
expected: '1 000.
|
|
11
|
+
expected: '1 000.50',
|
|
12
12
|
valueType: VALUE_TYPE_NUMBER,
|
|
13
13
|
round: true,
|
|
14
14
|
dgs: DGS_SPACE
|
|
15
15
|
}, {
|
|
16
|
-
value: 33777889.
|
|
17
|
-
expected: '33,777,889.
|
|
16
|
+
value: 33777889.555,
|
|
17
|
+
expected: '33,777,889.55',
|
|
18
18
|
valueType: VALUE_TYPE_NUMBER,
|
|
19
19
|
round: true,
|
|
20
20
|
dgs: DGS_COMMA
|
|
21
21
|
}, {
|
|
22
22
|
value: 33777889.556,
|
|
23
|
-
expected: '33 777 889.
|
|
23
|
+
expected: '33 777 889.56',
|
|
24
24
|
valueType: VALUE_TYPE_NUMBER,
|
|
25
25
|
round: true,
|
|
26
26
|
dgs: DGS_SPACE
|
|
@@ -33,7 +33,7 @@ const tests = [
|
|
|
33
33
|
dgs: DGS_SPACE
|
|
34
34
|
}, {
|
|
35
35
|
value: 33777889.56,
|
|
36
|
-
expected: '33777889.
|
|
36
|
+
expected: '33777889.56',
|
|
37
37
|
valueType: VALUE_TYPE_NUMBER,
|
|
38
38
|
round: true,
|
|
39
39
|
dgs: DGS_NONE
|
|
@@ -51,7 +51,7 @@ const tests = [
|
|
|
51
51
|
dgs: DGS_SPACE
|
|
52
52
|
}, {
|
|
53
53
|
value: 1.101,
|
|
54
|
-
expected: '1.
|
|
54
|
+
expected: '1.10',
|
|
55
55
|
valueType: VALUE_TYPE_NUMBER,
|
|
56
56
|
round: true,
|
|
57
57
|
dgs: DGS_SPACE
|
|
@@ -105,15 +105,15 @@ const tests = [
|
|
|
105
105
|
round: false,
|
|
106
106
|
dgs: DGS_SPACE
|
|
107
107
|
}, {
|
|
108
|
-
value: -0.
|
|
109
|
-
expected: '-2.
|
|
108
|
+
value: -0.02345,
|
|
109
|
+
expected: '-2.34%',
|
|
110
110
|
valueType: VALUE_TYPE_NUMBER,
|
|
111
111
|
numberType: NUMBER_TYPE_ROW_PERCENTAGE,
|
|
112
112
|
round: true,
|
|
113
113
|
dgs: DGS_SPACE
|
|
114
114
|
}, {
|
|
115
|
-
value: -0.
|
|
116
|
-
expected: '-2.
|
|
115
|
+
value: -0.02345,
|
|
116
|
+
expected: '-2.345%',
|
|
117
117
|
valueType: VALUE_TYPE_NUMBER,
|
|
118
118
|
numberType: NUMBER_TYPE_ROW_PERCENTAGE,
|
|
119
119
|
round: false,
|
|
@@ -6,7 +6,7 @@ import times from 'lodash/times';
|
|
|
6
6
|
import { DIMENSION_TYPE_DATA, DIMENSION_TYPE_DATA_ELEMENT_GROUP_SET, DIMENSION_TYPE_ORGANISATION_UNIT, DIMENSION_TYPE_PERIOD } from '../dataTypes.js';
|
|
7
7
|
import { DIMENSION_ID_ORGUNIT } from '../predefinedDimensions.js';
|
|
8
8
|
import { renderValue } from '../renderValue.js';
|
|
9
|
-
import { VALUE_TYPE_NUMBER, VALUE_TYPE_TEXT } from '../valueTypes.js';
|
|
9
|
+
import { VALUE_TYPE_NUMBER, VALUE_TYPE_TEXT, isBooleanValueType, isNumericValueType } from '../valueTypes.js';
|
|
10
10
|
import { AdaptiveClippingController } from './AdaptiveClippingController.js';
|
|
11
11
|
import { addToTotalIfNumber } from './addToTotalIfNumber.js';
|
|
12
12
|
import { parseValue } from './parseValue.js';
|
|
@@ -543,7 +543,12 @@ export class PivotTableEngine {
|
|
|
543
543
|
} else {
|
|
544
544
|
totalCell.valueType = currentValueType;
|
|
545
545
|
}
|
|
546
|
-
|
|
546
|
+
|
|
547
|
+
// compute subtotals and totals for all numeric and boolean value types
|
|
548
|
+
// in that case, force value type of subtotal and total cells to NUMBER to format them correctly
|
|
549
|
+
// (see DHIS2-9155)
|
|
550
|
+
if (isNumericValueType(dxDimension === null || dxDimension === void 0 ? void 0 : dxDimension.valueType) || isBooleanValueType(dxDimension === null || dxDimension === void 0 ? void 0 : dxDimension.valueType)) {
|
|
551
|
+
totalCell.valueType = VALUE_TYPE_NUMBER;
|
|
547
552
|
dataFields.forEach(field => {
|
|
548
553
|
const headerIndex = this.dimensionLookup.dataHeaders[field];
|
|
549
554
|
const value = parseValue(dataRow[headerIndex]);
|
|
@@ -36,7 +36,7 @@ const toFixedPrecisionString = (value, skipRounding) => {
|
|
|
36
36
|
// Values returned from the server should keep their string representation
|
|
37
37
|
return value;
|
|
38
38
|
}
|
|
39
|
-
const precision = skipRounding ? 10 :
|
|
39
|
+
const precision = skipRounding ? 10 : 2;
|
|
40
40
|
return value.toFixed(precision);
|
|
41
41
|
};
|
|
42
42
|
export const renderValue = (value, valueType, visualization) => {
|