@dhis2/analytics 24.0.7 → 24.0.8
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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [24.0.8](https://github.com/dhis2/analytics/compare/v24.0.7...v24.0.8) (2022-09-06)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* prevent empty values from displaying a legend color ([#1335](https://github.com/dhis2/analytics/issues/1335)) ([5b6567e](https://github.com/dhis2/analytics/commit/5b6567e75ea1d5252f314108998ff24f181f182b))
|
|
7
|
+
|
|
1
8
|
## [24.0.7](https://github.com/dhis2/analytics/compare/v24.0.6...v24.0.7) (2022-08-27)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _legends = require("../legends.js");
|
|
4
|
+
|
|
5
|
+
const positiveLegendSet = {
|
|
6
|
+
legends: [{
|
|
7
|
+
startValue: 65,
|
|
8
|
+
endValue: 75,
|
|
9
|
+
color: '#2171b5',
|
|
10
|
+
id: 'ZuBlFGK8U7D',
|
|
11
|
+
name: '65 - 74'
|
|
12
|
+
}, {
|
|
13
|
+
startValue: 35,
|
|
14
|
+
endValue: 45,
|
|
15
|
+
color: '#9ecae1',
|
|
16
|
+
id: 'XTmLeJHmd3m',
|
|
17
|
+
name: '35 - 44'
|
|
18
|
+
}, {
|
|
19
|
+
startValue: 75,
|
|
20
|
+
endValue: 85,
|
|
21
|
+
color: '#08519c',
|
|
22
|
+
id: 'VPEprgLdi1g',
|
|
23
|
+
name: '75 - 84'
|
|
24
|
+
}, {
|
|
25
|
+
startValue: 25,
|
|
26
|
+
endValue: 35,
|
|
27
|
+
color: '#c6dbef',
|
|
28
|
+
id: 'CqUnYcUy2eb',
|
|
29
|
+
name: '25 - 34'
|
|
30
|
+
}, {
|
|
31
|
+
startValue: 15,
|
|
32
|
+
endValue: 25,
|
|
33
|
+
color: '#deebf7',
|
|
34
|
+
id: 'evLlhbRsG6e',
|
|
35
|
+
name: '15 - 24'
|
|
36
|
+
}, {
|
|
37
|
+
startValue: 0,
|
|
38
|
+
endValue: 5,
|
|
39
|
+
color: '#FFFFFF',
|
|
40
|
+
id: 'GHcJ24t8oEs',
|
|
41
|
+
name: '0 - 4'
|
|
42
|
+
}, {
|
|
43
|
+
startValue: 85,
|
|
44
|
+
endValue: 150,
|
|
45
|
+
color: '#08306b',
|
|
46
|
+
id: 'dPFk7tcCg7U',
|
|
47
|
+
name: '85+'
|
|
48
|
+
}, {
|
|
49
|
+
startValue: 45,
|
|
50
|
+
endValue: 55,
|
|
51
|
+
color: '#6baed6',
|
|
52
|
+
id: 'uHBR7cbKoy3',
|
|
53
|
+
name: '45 - 54'
|
|
54
|
+
}, {
|
|
55
|
+
startValue: 5,
|
|
56
|
+
endValue: 15,
|
|
57
|
+
color: '#f7fbff',
|
|
58
|
+
id: 'RUD8IwOsXEW',
|
|
59
|
+
name: '5 - 14'
|
|
60
|
+
}, {
|
|
61
|
+
startValue: 55,
|
|
62
|
+
endValue: 65,
|
|
63
|
+
color: '#4292c6',
|
|
64
|
+
id: 'UojF9VGBvnE',
|
|
65
|
+
name: '55 - 64'
|
|
66
|
+
}],
|
|
67
|
+
name: 'Positive'
|
|
68
|
+
};
|
|
69
|
+
const negativeLegendSet = {
|
|
70
|
+
legends: [{
|
|
71
|
+
startValue: -48,
|
|
72
|
+
endValue: -36,
|
|
73
|
+
color: '#fecc5c',
|
|
74
|
+
id: 'TR60hS8mQag',
|
|
75
|
+
name: '-48 - -36'
|
|
76
|
+
}, {
|
|
77
|
+
startValue: -1000,
|
|
78
|
+
endValue: -60,
|
|
79
|
+
color: '#D10AFF',
|
|
80
|
+
id: 'nxCTJlHd9V2',
|
|
81
|
+
name: 'Critically low'
|
|
82
|
+
}, {
|
|
83
|
+
startValue: -24,
|
|
84
|
+
endValue: -12,
|
|
85
|
+
color: '#f03b20',
|
|
86
|
+
id: 'JOYfGUtyLJF',
|
|
87
|
+
name: '-24 - -12'
|
|
88
|
+
}, {
|
|
89
|
+
startValue: -60,
|
|
90
|
+
endValue: -48,
|
|
91
|
+
color: '#ffffb2',
|
|
92
|
+
id: 'JodoDUR31ig',
|
|
93
|
+
name: '-60 - -48'
|
|
94
|
+
}, {
|
|
95
|
+
startValue: -12,
|
|
96
|
+
endValue: 0,
|
|
97
|
+
color: '#bd0026',
|
|
98
|
+
id: 'rFFEKuATWaZ',
|
|
99
|
+
name: '-12 - 0'
|
|
100
|
+
}, {
|
|
101
|
+
startValue: 0,
|
|
102
|
+
endValue: 10000,
|
|
103
|
+
color: '#A3A3A3',
|
|
104
|
+
id: 'rOD16kf9YzA',
|
|
105
|
+
name: 'Out of bounds'
|
|
106
|
+
}, {
|
|
107
|
+
startValue: -36,
|
|
108
|
+
endValue: -24,
|
|
109
|
+
color: '#fd8d3c',
|
|
110
|
+
id: 'i682LxWmGQ6',
|
|
111
|
+
name: '-36 - -24'
|
|
112
|
+
}],
|
|
113
|
+
name: 'Negative'
|
|
114
|
+
};
|
|
115
|
+
const tests = [{
|
|
116
|
+
legendSet: positiveLegendSet,
|
|
117
|
+
value: 60,
|
|
118
|
+
expected: '#4292c6'
|
|
119
|
+
}, {
|
|
120
|
+
legendSet: positiveLegendSet,
|
|
121
|
+
value: '60.0',
|
|
122
|
+
expected: '#4292c6'
|
|
123
|
+
}, {
|
|
124
|
+
legendSet: positiveLegendSet,
|
|
125
|
+
value: 0,
|
|
126
|
+
expected: '#FFFFFF'
|
|
127
|
+
}, {
|
|
128
|
+
legendSet: positiveLegendSet,
|
|
129
|
+
value: '',
|
|
130
|
+
expected: null
|
|
131
|
+
}, {
|
|
132
|
+
legendSet: positiveLegendSet,
|
|
133
|
+
value: ' ',
|
|
134
|
+
expected: null
|
|
135
|
+
}, {
|
|
136
|
+
legendSet: positiveLegendSet,
|
|
137
|
+
value: 'ABC',
|
|
138
|
+
expected: null
|
|
139
|
+
}, {
|
|
140
|
+
legendSet: negativeLegendSet,
|
|
141
|
+
value: -50,
|
|
142
|
+
expected: '#ffffb2'
|
|
143
|
+
}, {
|
|
144
|
+
legendSet: negativeLegendSet,
|
|
145
|
+
value: '-50.0',
|
|
146
|
+
expected: '#ffffb2'
|
|
147
|
+
}, {
|
|
148
|
+
legendSet: negativeLegendSet,
|
|
149
|
+
value: 0,
|
|
150
|
+
expected: '#A3A3A3'
|
|
151
|
+
}, {
|
|
152
|
+
legendSet: negativeLegendSet,
|
|
153
|
+
value: '',
|
|
154
|
+
expected: null
|
|
155
|
+
}];
|
|
156
|
+
describe('getColorByValueFromLegendSet', () => {
|
|
157
|
+
tests.forEach(t => {
|
|
158
|
+
it("Legend set: ".concat(t.legendSet.name, ", value: ").concat(t.value, ", expected: ").concat(t.expected), () => {
|
|
159
|
+
expect((0, _legends.getColorByValueFromLegendSet)(t.legendSet, t.value)).toEqual(t.expected);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
});
|
|
@@ -16,8 +16,8 @@ exports.LEGEND_DISPLAY_STYLE_TEXT = LEGEND_DISPLAY_STYLE_TEXT;
|
|
|
16
16
|
const getLegendByValueFromLegendSet = (legendSet, value) => {
|
|
17
17
|
var _legendSet$legends;
|
|
18
18
|
|
|
19
|
-
return 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
|
|
20
|
-
);
|
|
19
|
+
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
|
|
20
|
+
) : null;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
exports.getLegendByValueFromLegendSet = getLegendByValueFromLegendSet;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { getColorByValueFromLegendSet } from '../legends.js';
|
|
2
|
+
const positiveLegendSet = {
|
|
3
|
+
legends: [{
|
|
4
|
+
startValue: 65,
|
|
5
|
+
endValue: 75,
|
|
6
|
+
color: '#2171b5',
|
|
7
|
+
id: 'ZuBlFGK8U7D',
|
|
8
|
+
name: '65 - 74'
|
|
9
|
+
}, {
|
|
10
|
+
startValue: 35,
|
|
11
|
+
endValue: 45,
|
|
12
|
+
color: '#9ecae1',
|
|
13
|
+
id: 'XTmLeJHmd3m',
|
|
14
|
+
name: '35 - 44'
|
|
15
|
+
}, {
|
|
16
|
+
startValue: 75,
|
|
17
|
+
endValue: 85,
|
|
18
|
+
color: '#08519c',
|
|
19
|
+
id: 'VPEprgLdi1g',
|
|
20
|
+
name: '75 - 84'
|
|
21
|
+
}, {
|
|
22
|
+
startValue: 25,
|
|
23
|
+
endValue: 35,
|
|
24
|
+
color: '#c6dbef',
|
|
25
|
+
id: 'CqUnYcUy2eb',
|
|
26
|
+
name: '25 - 34'
|
|
27
|
+
}, {
|
|
28
|
+
startValue: 15,
|
|
29
|
+
endValue: 25,
|
|
30
|
+
color: '#deebf7',
|
|
31
|
+
id: 'evLlhbRsG6e',
|
|
32
|
+
name: '15 - 24'
|
|
33
|
+
}, {
|
|
34
|
+
startValue: 0,
|
|
35
|
+
endValue: 5,
|
|
36
|
+
color: '#FFFFFF',
|
|
37
|
+
id: 'GHcJ24t8oEs',
|
|
38
|
+
name: '0 - 4'
|
|
39
|
+
}, {
|
|
40
|
+
startValue: 85,
|
|
41
|
+
endValue: 150,
|
|
42
|
+
color: '#08306b',
|
|
43
|
+
id: 'dPFk7tcCg7U',
|
|
44
|
+
name: '85+'
|
|
45
|
+
}, {
|
|
46
|
+
startValue: 45,
|
|
47
|
+
endValue: 55,
|
|
48
|
+
color: '#6baed6',
|
|
49
|
+
id: 'uHBR7cbKoy3',
|
|
50
|
+
name: '45 - 54'
|
|
51
|
+
}, {
|
|
52
|
+
startValue: 5,
|
|
53
|
+
endValue: 15,
|
|
54
|
+
color: '#f7fbff',
|
|
55
|
+
id: 'RUD8IwOsXEW',
|
|
56
|
+
name: '5 - 14'
|
|
57
|
+
}, {
|
|
58
|
+
startValue: 55,
|
|
59
|
+
endValue: 65,
|
|
60
|
+
color: '#4292c6',
|
|
61
|
+
id: 'UojF9VGBvnE',
|
|
62
|
+
name: '55 - 64'
|
|
63
|
+
}],
|
|
64
|
+
name: 'Positive'
|
|
65
|
+
};
|
|
66
|
+
const negativeLegendSet = {
|
|
67
|
+
legends: [{
|
|
68
|
+
startValue: -48,
|
|
69
|
+
endValue: -36,
|
|
70
|
+
color: '#fecc5c',
|
|
71
|
+
id: 'TR60hS8mQag',
|
|
72
|
+
name: '-48 - -36'
|
|
73
|
+
}, {
|
|
74
|
+
startValue: -1000,
|
|
75
|
+
endValue: -60,
|
|
76
|
+
color: '#D10AFF',
|
|
77
|
+
id: 'nxCTJlHd9V2',
|
|
78
|
+
name: 'Critically low'
|
|
79
|
+
}, {
|
|
80
|
+
startValue: -24,
|
|
81
|
+
endValue: -12,
|
|
82
|
+
color: '#f03b20',
|
|
83
|
+
id: 'JOYfGUtyLJF',
|
|
84
|
+
name: '-24 - -12'
|
|
85
|
+
}, {
|
|
86
|
+
startValue: -60,
|
|
87
|
+
endValue: -48,
|
|
88
|
+
color: '#ffffb2',
|
|
89
|
+
id: 'JodoDUR31ig',
|
|
90
|
+
name: '-60 - -48'
|
|
91
|
+
}, {
|
|
92
|
+
startValue: -12,
|
|
93
|
+
endValue: 0,
|
|
94
|
+
color: '#bd0026',
|
|
95
|
+
id: 'rFFEKuATWaZ',
|
|
96
|
+
name: '-12 - 0'
|
|
97
|
+
}, {
|
|
98
|
+
startValue: 0,
|
|
99
|
+
endValue: 10000,
|
|
100
|
+
color: '#A3A3A3',
|
|
101
|
+
id: 'rOD16kf9YzA',
|
|
102
|
+
name: 'Out of bounds'
|
|
103
|
+
}, {
|
|
104
|
+
startValue: -36,
|
|
105
|
+
endValue: -24,
|
|
106
|
+
color: '#fd8d3c',
|
|
107
|
+
id: 'i682LxWmGQ6',
|
|
108
|
+
name: '-36 - -24'
|
|
109
|
+
}],
|
|
110
|
+
name: 'Negative'
|
|
111
|
+
};
|
|
112
|
+
const tests = [{
|
|
113
|
+
legendSet: positiveLegendSet,
|
|
114
|
+
value: 60,
|
|
115
|
+
expected: '#4292c6'
|
|
116
|
+
}, {
|
|
117
|
+
legendSet: positiveLegendSet,
|
|
118
|
+
value: '60.0',
|
|
119
|
+
expected: '#4292c6'
|
|
120
|
+
}, {
|
|
121
|
+
legendSet: positiveLegendSet,
|
|
122
|
+
value: 0,
|
|
123
|
+
expected: '#FFFFFF'
|
|
124
|
+
}, {
|
|
125
|
+
legendSet: positiveLegendSet,
|
|
126
|
+
value: '',
|
|
127
|
+
expected: null
|
|
128
|
+
}, {
|
|
129
|
+
legendSet: positiveLegendSet,
|
|
130
|
+
value: ' ',
|
|
131
|
+
expected: null
|
|
132
|
+
}, {
|
|
133
|
+
legendSet: positiveLegendSet,
|
|
134
|
+
value: 'ABC',
|
|
135
|
+
expected: null
|
|
136
|
+
}, {
|
|
137
|
+
legendSet: negativeLegendSet,
|
|
138
|
+
value: -50,
|
|
139
|
+
expected: '#ffffb2'
|
|
140
|
+
}, {
|
|
141
|
+
legendSet: negativeLegendSet,
|
|
142
|
+
value: '-50.0',
|
|
143
|
+
expected: '#ffffb2'
|
|
144
|
+
}, {
|
|
145
|
+
legendSet: negativeLegendSet,
|
|
146
|
+
value: 0,
|
|
147
|
+
expected: '#A3A3A3'
|
|
148
|
+
}, {
|
|
149
|
+
legendSet: negativeLegendSet,
|
|
150
|
+
value: '',
|
|
151
|
+
expected: null
|
|
152
|
+
}];
|
|
153
|
+
describe('getColorByValueFromLegendSet', () => {
|
|
154
|
+
tests.forEach(t => {
|
|
155
|
+
it("Legend set: ".concat(t.legendSet.name, ", value: ").concat(t.value, ", expected: ").concat(t.expected), () => {
|
|
156
|
+
expect(getColorByValueFromLegendSet(t.legendSet, t.value)).toEqual(t.expected);
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
});
|
|
@@ -5,8 +5,8 @@ export const LEGEND_DISPLAY_STYLE_TEXT = 'TEXT';
|
|
|
5
5
|
export const getLegendByValueFromLegendSet = (legendSet, value) => {
|
|
6
6
|
var _legendSet$legends;
|
|
7
7
|
|
|
8
|
-
return 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
|
|
9
|
-
);
|
|
8
|
+
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
|
|
9
|
+
) : null;
|
|
10
10
|
};
|
|
11
11
|
export const getColorByValueFromLegendSet = (legendSet, value) => {
|
|
12
12
|
const legend = getLegendByValueFromLegendSet(legendSet, value);
|