@dhis2/analytics 26.8.2 → 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/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/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
|
@@ -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) => {
|
|
@@ -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) => {
|