@contrail/documents 1.0.101 → 1.0.102
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.
|
@@ -16,21 +16,24 @@ var DynamicTextDisplayFunction;
|
|
|
16
16
|
})(DynamicTextDisplayFunction = exports.DynamicTextDisplayFunction || (exports.DynamicTextDisplayFunction = {}));
|
|
17
17
|
class DynamicTextUtil {
|
|
18
18
|
static getTextFromFrameMemberValues(displayFunction, property, memberValues) {
|
|
19
|
-
const formatter = new types_1.PropertyValueFormatter();
|
|
20
19
|
let text = '';
|
|
20
|
+
if (memberValues.length === 0) {
|
|
21
|
+
return text;
|
|
22
|
+
}
|
|
23
|
+
const formatter = new types_1.PropertyValueFormatter();
|
|
21
24
|
if (displayFunction === DynamicTextDisplayFunction.AVERAGE) {
|
|
22
|
-
memberValues = memberValues.filter(
|
|
25
|
+
memberValues = memberValues.filter(e => e !== null && e !== undefined && !isNaN(e));
|
|
23
26
|
text = formatter.formatValueForProperty(memberValues.reduce((a, b) => a + b, 0) / memberValues.length, property);
|
|
24
27
|
}
|
|
25
28
|
else if (displayFunction === DynamicTextDisplayFunction.SUM) {
|
|
26
|
-
memberValues = memberValues.filter(
|
|
29
|
+
memberValues = memberValues.filter(e => e !== null && e !== undefined && !isNaN(e));
|
|
27
30
|
text = formatter.formatValueForProperty(memberValues.reduce((a, b) => a + b, 0), property);
|
|
28
31
|
}
|
|
29
32
|
else if (displayFunction === DynamicTextDisplayFunction.UNIQUE_ARRAY) {
|
|
30
33
|
text = Array.from(new Set(memberValues
|
|
31
|
-
.filter(
|
|
34
|
+
.filter(e => e !== null && e !== undefined)
|
|
32
35
|
.flat()
|
|
33
|
-
.map(
|
|
36
|
+
.map(e => formatter.formatValueForProperty(e, property))))
|
|
34
37
|
.sort()
|
|
35
38
|
.join(', ');
|
|
36
39
|
}
|
|
@@ -39,14 +42,14 @@ class DynamicTextUtil {
|
|
|
39
42
|
text = formatter.formatValueForProperty(memberValues[0], property);
|
|
40
43
|
}
|
|
41
44
|
else if (displayFunction === DynamicTextDisplayFunction.LAST) {
|
|
42
|
-
text = formatter.formatValueForProperty([memberValues.length - 1], property);
|
|
45
|
+
text = formatter.formatValueForProperty(memberValues[memberValues.length - 1], property);
|
|
43
46
|
}
|
|
44
47
|
else if (displayFunction === DynamicTextDisplayFunction.MIN) {
|
|
45
|
-
memberValues = memberValues.filter(
|
|
48
|
+
memberValues = memberValues.filter(e => e !== null && e !== undefined);
|
|
46
49
|
text = formatter.formatValueForProperty(Math.min(...memberValues), property);
|
|
47
50
|
}
|
|
48
51
|
else if (displayFunction === DynamicTextDisplayFunction.MAX) {
|
|
49
|
-
memberValues = memberValues.filter(
|
|
52
|
+
memberValues = memberValues.filter(e => e !== null && e !== undefined);
|
|
50
53
|
text = formatter.formatValueForProperty(Math.max(...memberValues), property);
|
|
51
54
|
}
|
|
52
55
|
return text;
|