@sis-cc/dotstatsuite-components 17.14.0 → 17.16.0
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/lib/rules2/src/table/getLayoutData2.js +81 -41
- package/lib/rules2/src/table/parseSeriesIndexesHierarchies.js +55 -42
- package/lib/rules2/src/table/refineLayoutSize2.js +59 -8
- package/package.json +1 -1
- package/src/rules2/src/table/getLayoutData2.js +76 -61
- package/src/rules2/src/table/parseSeriesIndexesHierarchies.js +37 -40
- package/src/rules2/src/table/refineLayoutSize2.js +57 -18
- package/test/getLayoutData2.test.js +142 -33
- package/test/parseSeriesIndexesHierarchies.test.js +1 -0
- package/test/refineLayoutSize2.test.js +117 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getLayoutData = exports.
|
|
6
|
+
exports.getLayoutData = exports.getSerieDataWithoutMissingLines = exports.getSerieDataWithMissingLines = undefined;
|
|
7
7
|
|
|
8
8
|
var _slicedToArray2 = require('babel-runtime/helpers/slicedToArray');
|
|
9
9
|
|
|
@@ -30,10 +30,12 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
30
30
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
31
|
|
|
32
32
|
var getValueData = function getValueData(index, dimension, parentsIndexes) {
|
|
33
|
+
var missingParents = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
33
34
|
return {
|
|
34
35
|
dimension: R.pick(['id', 'name', '__index'], dimension),
|
|
35
36
|
value: (0, _extends3.default)({}, R.pipe(R.pathOr({}, ['values', index]), R.pick(['id', 'name']))(dimension), {
|
|
36
|
-
parents: parentsIndexes
|
|
37
|
+
parents: parentsIndexes,
|
|
38
|
+
missingParents: missingParents
|
|
37
39
|
})
|
|
38
40
|
};
|
|
39
41
|
};
|
|
@@ -55,8 +57,8 @@ var combinedValueDataSetter = function combinedValueDataSetter(valueData) {
|
|
|
55
57
|
};
|
|
56
58
|
|
|
57
59
|
var addValueToSerieData = function addValueToSerieData(dataSetter) {
|
|
58
|
-
return function (index, parentsIndexes, dimension, serieData) {
|
|
59
|
-
var valueData = getValueData(index, dimension, parentsIndexes);
|
|
60
|
+
return function (index, parentsIndexes, dimension, serieData, missingParents) {
|
|
61
|
+
var valueData = getValueData(index, dimension, parentsIndexes, missingParents);
|
|
60
62
|
var valueId = R.path(['value', 'id'], valueData);
|
|
61
63
|
return (0, _extends3.default)({}, serieData, {
|
|
62
64
|
data: dataSetter(valueData, R.prop('data', serieData)),
|
|
@@ -92,7 +94,7 @@ var getAttributesSeries = function getAttributesSeries(validator, attributesSeri
|
|
|
92
94
|
var attr = R.head(R.values(attrs));
|
|
93
95
|
var coordinates = R.propOr({}, 'coordinates', attr);
|
|
94
96
|
var isValid = validator(coordinates);
|
|
95
|
-
if (!isValid && !
|
|
97
|
+
if (!isValid && !R.prop('isObs', attr)) {
|
|
96
98
|
return acc;
|
|
97
99
|
}
|
|
98
100
|
return (0, _extends3.default)({}, acc, attrs);
|
|
@@ -128,27 +130,8 @@ var getSerieFlagsAndSideProps = function getSerieFlagsAndSideProps(coordinates,
|
|
|
128
130
|
return { flags: flags, sideProps: sideProps };
|
|
129
131
|
};
|
|
130
132
|
|
|
131
|
-
var
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
var serieCoordinates = getCoordinates(serie.indexes, topCoordinates, definition);
|
|
135
|
-
var coordinatesValidator = (0, _utils.getLayoutCoordinatesValidator)(serieCoordinates, topCoordinates);
|
|
136
|
-
var attributesValues = getAttributesSeries(coordinatesValidator, attributesSeries);
|
|
137
|
-
|
|
138
|
-
var addMissingParentsLines = function addMissingParentsLines(dataSetter) {
|
|
139
|
-
return function (missingParentsIndexes, parentsIndexes, dim, serieData) {
|
|
140
|
-
return R.reduce(function (parents, index) {
|
|
141
|
-
var missingParentData = addValueToSerieData(dataSetter)(index, parents, dim, serieData);
|
|
142
|
-
lines.push(R.assoc('isEmpty', true, missingParentData));
|
|
143
|
-
return R.append(index, parents);
|
|
144
|
-
}, parentsIndexes, missingParentsIndexes);
|
|
145
|
-
};
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
var addSimpleMissingParentsLines = addMissingParentsLines(simpleValueDataSetter);
|
|
149
|
-
var addCombinedMissingParentsLines = addMissingParentsLines(combinedValueDataSetter);
|
|
150
|
-
|
|
151
|
-
var serieData = R.addIndex(R.reduce)(function (onGoingSerie, entry, index) {
|
|
133
|
+
var getSerieDimensionsData = function getSerieDimensionsData(serie, definition, attributesValues, missingParentsGetter) {
|
|
134
|
+
return R.addIndex(R.reduce)(function (onGoingSerie, entry, index) {
|
|
152
135
|
if (R.has('dimensions', entry)) {
|
|
153
136
|
var combValuesIndexes = R.pathOr([], ['indexes', index], serie);
|
|
154
137
|
var combParentsIndexes = R.pathOr([], ['parentsIndexes', index], serie);
|
|
@@ -158,33 +141,90 @@ var getSerieDatas = exports.getSerieDatas = function getSerieDatas(serie, defini
|
|
|
158
141
|
var valueIndex = Math.abs(R.nth(dimIndex, combValuesIndexes));
|
|
159
142
|
var _parentsIndexes = R.nth(dimIndex, combParentsIndexes) || [];
|
|
160
143
|
var missingParentsIndexes = R.nth(dimIndex, combMissingParentsIndexes) || [];
|
|
161
|
-
|
|
162
|
-
var
|
|
144
|
+
|
|
145
|
+
var _missingParentsGetter = missingParentsGetter(combinedValueDataSetter)(missingParentsIndexes, _parentsIndexes, dimension, combSerie),
|
|
146
|
+
parentsIndexes = _missingParentsGetter.parentsIndexes,
|
|
147
|
+
missingParents = _missingParentsGetter.missingParents;
|
|
148
|
+
|
|
149
|
+
var next = addCombinedValueToSerieData(valueIndex, parentsIndexes, dimension, combSerie, missingParents);
|
|
163
150
|
var value = R.pipe(R.prop('data'), R.last, R.prop('values'), R.last)(next);
|
|
164
151
|
combDimValues = R.assoc(dimension.id, value, combDimValues);
|
|
165
152
|
return next;
|
|
166
153
|
}, R.over(R.lensProp('data'), R.append({ dimension: R.pick(['id', 'name'], entry), values: [] }))(onGoingSerie), R.propOr([], 'dimensions', entry));
|
|
167
154
|
|
|
168
|
-
var combined = combineConcepts(combDimValues, entry,
|
|
169
|
-
|
|
170
|
-
return combined;
|
|
155
|
+
var combined = combineConcepts(combDimValues, entry, onGoingSerie.attributes)(res);
|
|
156
|
+
return R.over(R.lensProp('attributes'), R.omit(entry.concepts), combined);
|
|
171
157
|
}
|
|
172
158
|
|
|
173
159
|
var valueIndex = Math.abs(R.path(['indexes', index], serie));
|
|
174
160
|
var _parentsIndexes = R.pathOr([], ['parentsIndexes', index], serie);
|
|
175
161
|
var missingParentsIndexes = R.pathOr([], ['missingIndexes', index], serie);
|
|
176
|
-
var parentsIndexes = addSimpleMissingParentsLines(missingParentsIndexes, _parentsIndexes, entry, onGoingSerie);
|
|
177
|
-
return addSimpleValueToSerieData(valueIndex, parentsIndexes, entry, onGoingSerie);
|
|
178
|
-
}, { data: [], coordinates: {}, key: '', sideProps: null, flags: [] }, definition);
|
|
179
162
|
|
|
180
|
-
|
|
163
|
+
var _missingParentsGetter2 = missingParentsGetter(simpleValueDataSetter)(missingParentsIndexes, _parentsIndexes, entry, onGoingSerie),
|
|
164
|
+
parentsIndexes = _missingParentsGetter2.parentsIndexes,
|
|
165
|
+
missingParents = _missingParentsGetter2.missingParents;
|
|
166
|
+
|
|
167
|
+
return addSimpleValueToSerieData(valueIndex, parentsIndexes, entry, onGoingSerie, missingParents);
|
|
168
|
+
}, { data: [], key: '', attributes: attributesValues }, definition);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
var getSerieDataWithMissingLines = function getSerieDataWithMissingLines(serie, definition, topCoordinates, attributesSeries, customAttributes, metadataCoordinates) {
|
|
172
|
+
var lines = [];
|
|
173
|
+
|
|
174
|
+
var serieCoordinates = getCoordinates(serie.indexes, topCoordinates, definition);
|
|
175
|
+
var coordinatesValidator = (0, _utils.getLayoutCoordinatesValidator)(serieCoordinates, topCoordinates);
|
|
176
|
+
var attributesValues = getAttributesSeries(coordinatesValidator, attributesSeries);
|
|
177
|
+
|
|
178
|
+
var getMissingParents = function getMissingParents(dataSetter) {
|
|
179
|
+
return function (missingParentsIndexes, _parentsIndexes, dim, serieData) {
|
|
180
|
+
return R.reduce(function (acc, index) {
|
|
181
|
+
var missingParentData = addValueToSerieData(dataSetter)(index, acc.parentsIndexes, dim, serieData);
|
|
182
|
+
lines.push((0, _extends3.default)({}, R.dissoc('attributes', missingParentData), { sideProps: null, flags: [], isEmpty: true }));
|
|
183
|
+
return R.over(R.lensProp('parentsIndexes'), R.append(index), acc);
|
|
184
|
+
}, { parentsIndexes: _parentsIndexes, missingParents: [] }, missingParentsIndexes);
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
var _getSerieDimensionsDa = getSerieDimensionsData(serie, definition, attributesValues, getMissingParents),
|
|
189
|
+
attributes = _getSerieDimensionsDa.attributes,
|
|
190
|
+
serieData = (0, _objectWithoutProperties3.default)(_getSerieDimensionsDa, ['attributes']);
|
|
191
|
+
|
|
192
|
+
var _getSerieFlagsAndSide = getSerieFlagsAndSideProps(serieCoordinates, coordinatesValidator, attributes, customAttributes, metadataCoordinates),
|
|
181
193
|
flags = _getSerieFlagsAndSide.flags,
|
|
182
194
|
sideProps = _getSerieFlagsAndSide.sideProps;
|
|
183
195
|
|
|
184
|
-
|
|
185
|
-
|
|
196
|
+
return R.append((0, _extends3.default)({}, serieData, { flags: flags, sideProps: sideProps }), lines);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
exports.getSerieDataWithMissingLines = getSerieDataWithMissingLines;
|
|
200
|
+
var getSerieDataWithoutMissingLines = function getSerieDataWithoutMissingLines(serie, definition, topCoordinates, attributesSeries, customAttributes, metadataCoordinates) {
|
|
201
|
+
var serieCoordinates = getCoordinates(serie.indexes, topCoordinates, definition);
|
|
202
|
+
var coordinatesValidator = (0, _utils.getLayoutCoordinatesValidator)(serieCoordinates, topCoordinates);
|
|
203
|
+
var attributesValues = getAttributesSeries(coordinatesValidator, attributesSeries);
|
|
204
|
+
|
|
205
|
+
var getMissingParents = function getMissingParents() {
|
|
206
|
+
return function (missingParentsIndexes, _parentsIndexes, dim) {
|
|
207
|
+
return R.reduce(function (acc, index) {
|
|
208
|
+
return {
|
|
209
|
+
parentsIndexes: R.append(index, acc.parentsIndexes),
|
|
210
|
+
missingParents: R.append(R.prop('value', getValueData(index, dim, acc.parentsIndexes)), acc.missingParents)
|
|
211
|
+
};
|
|
212
|
+
}, { parentsIndexes: _parentsIndexes, missingParents: [] }, missingParentsIndexes);
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
var _getSerieDimensionsDa2 = getSerieDimensionsData(serie, definition, attributesValues, getMissingParents),
|
|
217
|
+
attributes = _getSerieDimensionsDa2.attributes,
|
|
218
|
+
serieData = (0, _objectWithoutProperties3.default)(_getSerieDimensionsDa2, ['attributes']);
|
|
219
|
+
|
|
220
|
+
var _getSerieFlagsAndSide2 = getSerieFlagsAndSideProps(serieCoordinates, coordinatesValidator, attributes, customAttributes, metadataCoordinates),
|
|
221
|
+
flags = _getSerieFlagsAndSide2.flags,
|
|
222
|
+
sideProps = _getSerieFlagsAndSide2.sideProps;
|
|
223
|
+
|
|
224
|
+
return (0, _extends3.default)({}, serieData, { flags: flags, sideProps: sideProps });
|
|
186
225
|
};
|
|
187
226
|
|
|
227
|
+
exports.getSerieDataWithoutMissingLines = getSerieDataWithoutMissingLines;
|
|
188
228
|
var getLayoutData = function getLayoutData(layoutIndexes, layout, _ref) {
|
|
189
229
|
var metadataCoordinates = _ref.metadataCoordinates,
|
|
190
230
|
attributesSeries = _ref.attributesSeries,
|
|
@@ -197,7 +237,7 @@ var getLayoutData = function getLayoutData(layoutIndexes, layout, _ref) {
|
|
|
197
237
|
|
|
198
238
|
|
|
199
239
|
var headerData = R.reduce(function (acc, serie) {
|
|
200
|
-
var datas =
|
|
240
|
+
var datas = getSerieDataWithMissingLines(serie, layout.header, topCoordinates, attributesSeries, customAttributes, metadataCoordinates);
|
|
201
241
|
return R.concat(acc, datas);
|
|
202
242
|
}, [], header);
|
|
203
243
|
|
|
@@ -206,9 +246,9 @@ var getLayoutData = function getLayoutData(layoutIndexes, layout, _ref) {
|
|
|
206
246
|
sectionSerie = _ref3[0],
|
|
207
247
|
rowsSeries = _ref3[1];
|
|
208
248
|
|
|
209
|
-
var sectionData =
|
|
210
|
-
return [
|
|
211
|
-
var datas =
|
|
249
|
+
var sectionData = getSerieDataWithoutMissingLines(sectionSerie, layout.sections, topCoordinates, attributesSeries, customAttributes, metadataCoordinates, false);
|
|
250
|
+
return [sectionData, R.reduce(function (acc, serie) {
|
|
251
|
+
var datas = getSerieDataWithMissingLines(serie, layout.rows, R.propOr(topCoordinates, 'coordinates', sectionData), attributesSeries, customAttributes, metadataCoordinates);
|
|
212
252
|
return R.concat(acc, datas);
|
|
213
253
|
}, [], rowsSeries)];
|
|
214
254
|
}, sections);
|
|
@@ -13,6 +13,14 @@ var _set = require('babel-runtime/core-js/set');
|
|
|
13
13
|
|
|
14
14
|
var _set2 = _interopRequireDefault(_set);
|
|
15
15
|
|
|
16
|
+
var _extends2 = require('babel-runtime/helpers/extends');
|
|
17
|
+
|
|
18
|
+
var _extends3 = _interopRequireDefault(_extends2);
|
|
19
|
+
|
|
20
|
+
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
|
|
21
|
+
|
|
22
|
+
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
|
|
23
|
+
|
|
16
24
|
var _ramda = require('ramda');
|
|
17
25
|
|
|
18
26
|
var R = _interopRequireWildcard(_ramda);
|
|
@@ -21,76 +29,81 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
21
29
|
|
|
22
30
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
31
|
|
|
32
|
+
var registerParsedIndexes = function registerParsedIndexes(_ref, register) {
|
|
33
|
+
var isSameSerie = _ref.isSameSerie,
|
|
34
|
+
parsed = (0, _objectWithoutProperties3.default)(_ref, ['isSameSerie']);
|
|
35
|
+
|
|
36
|
+
var merged = R.mergeWith(function (a, b) {
|
|
37
|
+
return R.append(a || [], b);
|
|
38
|
+
}, parsed, register);
|
|
39
|
+
return (0, _extends3.default)({}, merged, { isSameSerie: isSameSerie });
|
|
40
|
+
};
|
|
41
|
+
|
|
24
42
|
var parseSerieIndexesHierarchies = function parseSerieIndexesHierarchies(serieIndexes, previousSerie, dimensions) {
|
|
25
|
-
var
|
|
43
|
+
var defaultIsSameSerie = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
26
44
|
|
|
27
45
|
return R.addIndex(R.reduce)(function (acc, _valueIndex, dimensionIndex) {
|
|
28
46
|
if (R.is(Array, _valueIndex)) {
|
|
29
|
-
var previous = R.isEmpty(previousSerie) ? {} :
|
|
30
|
-
indexes: R.nth(dimensionIndex, previousSerie.indexes || []),
|
|
31
|
-
parentsIndexes: R.nth(dimensionIndex, previousSerie.parentsIndexes || []),
|
|
32
|
-
missingIndexes: R.nth(dimensionIndex, previousSerie.missingIndexes || []),
|
|
33
|
-
registeredIndexes: R.nth(dimensionIndex, previousSerie.registeredIndexes || [])
|
|
34
|
-
};
|
|
47
|
+
var previous = R.isEmpty(previousSerie) ? {} : R.map(R.nth(dimensionIndex), previousSerie);
|
|
35
48
|
var parsed = parseSerieIndexesHierarchies(_valueIndex, previous, R.pathOr([], [dimensionIndex, 'dimensions'], dimensions), acc.isSameSerie);
|
|
36
|
-
return
|
|
37
|
-
parentsIndexes: R.append(parsed.parentsIndexes, acc.parentsIndexes),
|
|
38
|
-
missingIndexes: R.append(parsed.missingIndexes, acc.missingIndexes),
|
|
39
|
-
registeredIndexes: R.append(parsed.registeredIndexes, acc.registeredIndexes),
|
|
40
|
-
isSameSerie: parsed.isSameSerie
|
|
41
|
-
};
|
|
49
|
+
return registerParsedIndexes(parsed, acc);
|
|
42
50
|
}
|
|
43
51
|
var valueIndex = Math.abs(_valueIndex);
|
|
44
|
-
var
|
|
52
|
+
var parents = R.pathOr([], [dimensionIndex, 'values', valueIndex, 'parents'], dimensions);
|
|
45
53
|
var previousIndex = acc.isSameSerie ? R.pathOr(-1, ['indexes', dimensionIndex], previousSerie) : -1;
|
|
46
54
|
var previousRegisteredIndexes = acc.isSameSerie ? R.pathOr(new _set2.default(), ['registeredIndexes', dimensionIndex], previousSerie) : new _set2.default();
|
|
47
55
|
var registeredIndexes = new _set2.default(previousRegisteredIndexes);
|
|
48
56
|
|
|
49
|
-
var _R$reduce = R.reduce(function (_acc,
|
|
50
|
-
if (previousRegisteredIndexes.has(
|
|
51
|
-
return R.over(R.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
var _R$reduce = R.reduce(function (_acc, i) {
|
|
58
|
+
if (previousRegisteredIndexes.has(i)) {
|
|
59
|
+
return R.over(R.lensProp('presentParentsIndexes'), function (p) {
|
|
60
|
+
return R.isNil(p) ? [i] : R.append(i, p);
|
|
61
|
+
}, _acc);
|
|
62
|
+
} else if (i > previousIndex && R.pathOr(false, [dimensionIndex, 'values', i, 'isSelected'], dimensions)) {
|
|
63
|
+
registeredIndexes.add(i);
|
|
64
|
+
return R.over(R.lensProp('missingParentsIndexes'), function (m) {
|
|
65
|
+
return R.isNil(m) ? [i] : R.append(i, m);
|
|
66
|
+
}, _acc);
|
|
55
67
|
}
|
|
56
68
|
return _acc;
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
missingParentsIndexes = _R$reduce2[1];
|
|
69
|
+
}, {}, parents),
|
|
70
|
+
presentParentsIndexes = _R$reduce.presentParentsIndexes,
|
|
71
|
+
missingParentsIndexes = _R$reduce.missingParentsIndexes;
|
|
61
72
|
|
|
62
73
|
registeredIndexes.add(valueIndex);
|
|
63
|
-
return {
|
|
64
|
-
|
|
65
|
-
missingIndexes: R.append(missingParentsIndexes, acc.missingIndexes),
|
|
66
|
-
registeredIndexes: R.append(registeredIndexes, acc.registeredIndexes),
|
|
67
|
-
isSameSerie: acc.isSameSerie && valueIndex === previousIndex
|
|
68
|
-
};
|
|
69
|
-
}, { parentsIndexes: [], missingIndexes: [], registeredIndexes: [], isSameSerie: isSameSerie }, serieIndexes);
|
|
74
|
+
return registerParsedIndexes({ parentsIndexes: presentParentsIndexes, missingIndexes: missingParentsIndexes, registeredIndexes: registeredIndexes, isSameSerie: acc.isSameSerie && valueIndex === previousIndex }, acc);
|
|
75
|
+
}, { parentsIndexes: [], missingIndexes: [], registeredIndexes: [], isSameSerie: defaultIsSameSerie }, serieIndexes);
|
|
70
76
|
};
|
|
71
77
|
|
|
72
|
-
var parseSeriesIndexesHierarchies =
|
|
78
|
+
var parseSeriesIndexesHierarchies = function parseSeriesIndexesHierarchies(seriesIndexes, dimensions) {
|
|
73
79
|
return R.reduce(function (acc, serieIndexes) {
|
|
74
80
|
var previousSerie = R.last(acc) || {};
|
|
75
81
|
|
|
76
82
|
var _parseSerieIndexesHie = parseSerieIndexesHierarchies(serieIndexes, previousSerie, dimensions),
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
registeredIndexes = _parseSerieIndexesHie.registeredIndexes;
|
|
83
|
+
isSameSerie = _parseSerieIndexesHie.isSameSerie,
|
|
84
|
+
parsed = (0, _objectWithoutProperties3.default)(_parseSerieIndexesHie, ['isSameSerie']);
|
|
80
85
|
|
|
81
|
-
return R.append(
|
|
86
|
+
return R.append(R.assoc('indexes', serieIndexes, parsed), acc);
|
|
82
87
|
}, [], seriesIndexes);
|
|
83
88
|
};
|
|
84
89
|
|
|
90
|
+
exports.parseSeriesIndexesHierarchies = parseSeriesIndexesHierarchies;
|
|
85
91
|
var parseLayoutIndexesHierarchies = exports.parseLayoutIndexesHierarchies = function parseLayoutIndexesHierarchies(layoutIndexes, layout) {
|
|
86
92
|
var header = parseSeriesIndexesHierarchies(layoutIndexes.header, layout.header);
|
|
87
|
-
var sections = R.
|
|
88
|
-
var
|
|
89
|
-
|
|
90
|
-
|
|
93
|
+
var sections = R.pipe(R.transpose, function (_ref2) {
|
|
94
|
+
var _ref3 = (0, _slicedToArray3.default)(_ref2, 2),
|
|
95
|
+
_sections = _ref3[0],
|
|
96
|
+
_sectionsRows = _ref3[1];
|
|
91
97
|
|
|
92
|
-
|
|
93
|
-
|
|
98
|
+
if (R.isNil(_sections)) {
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
var sections = parseSeriesIndexesHierarchies(_sections, layout.sections);
|
|
102
|
+
var sectionsRows = R.map(function (rows) {
|
|
103
|
+
return parseSeriesIndexesHierarchies(rows, layout.rows);
|
|
104
|
+
}, _sectionsRows);
|
|
105
|
+
return R.transpose([sections, sectionsRows]);
|
|
106
|
+
})(layoutIndexes.sections);
|
|
94
107
|
|
|
95
108
|
return { header: header, sections: sections };
|
|
96
109
|
};
|
|
@@ -17,6 +17,10 @@ var _extends3 = require('babel-runtime/helpers/extends');
|
|
|
17
17
|
|
|
18
18
|
var _extends4 = _interopRequireDefault(_extends3);
|
|
19
19
|
|
|
20
|
+
var _set = require('babel-runtime/core-js/set');
|
|
21
|
+
|
|
22
|
+
var _set2 = _interopRequireDefault(_set);
|
|
23
|
+
|
|
20
24
|
var _ramda = require('ramda');
|
|
21
25
|
|
|
22
26
|
var R = _interopRequireWildcard(_ramda);
|
|
@@ -27,8 +31,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
27
31
|
|
|
28
32
|
var toKey = function toKey(indexes) {
|
|
29
33
|
return R.reduce(function (acc, _ind) {
|
|
30
|
-
var ind = R.is(Array, _ind) ? toKey(_ind) : Math.abs(_ind);
|
|
31
|
-
|
|
34
|
+
var ind = R.is(Array, _ind) ? toKey(_ind) : String(Math.abs(_ind));
|
|
35
|
+
if (R.isEmpty(ind)) {
|
|
36
|
+
return acc;
|
|
37
|
+
}
|
|
38
|
+
return R.isEmpty(acc) ? ind : acc + ':' + ind;
|
|
32
39
|
}, '', indexes);
|
|
33
40
|
};
|
|
34
41
|
|
|
@@ -60,26 +67,70 @@ var getCuratedCells = exports.getCuratedCells = function getCuratedCells(_ref) {
|
|
|
60
67
|
return indexWithPivots(pivots, observations);
|
|
61
68
|
};
|
|
62
69
|
|
|
70
|
+
var filterSeries = function filterSeries(series, getHasStillData) {
|
|
71
|
+
var removedMissingIndexes = [];
|
|
72
|
+
return R.reduce(function (acc, serie) {
|
|
73
|
+
var hasStillData = getHasStillData(serie);
|
|
74
|
+
var serieParentsSets = R.map(function (p) {
|
|
75
|
+
return new _set2.default(p);
|
|
76
|
+
}, R.propOr([], 'parentsIndexes', serie));
|
|
77
|
+
if (!hasStillData) {
|
|
78
|
+
removedMissingIndexes = R.addIndex(R.map)(function (mIs, ind) {
|
|
79
|
+
var filtered = R.filter(function (i) {
|
|
80
|
+
return serieParentsSets[ind].has(i);
|
|
81
|
+
}, R.nth(ind, removedMissingIndexes) || []);
|
|
82
|
+
return R.concat(filtered, mIs);
|
|
83
|
+
}, serie.missingIndexes || []);
|
|
84
|
+
return acc;
|
|
85
|
+
}
|
|
86
|
+
var _serie = R.pipe(R.over(R.lensProp('missingIndexes'), function () {
|
|
87
|
+
var missingIndexes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
88
|
+
return R.addIndex(R.map)(function (mIs, ind) {
|
|
89
|
+
var removed = R.nth(ind, removedMissingIndexes) || [];
|
|
90
|
+
if (R.isEmpty(removed)) {
|
|
91
|
+
return mIs;
|
|
92
|
+
}
|
|
93
|
+
var filteredRemoved = R.filter(function (i) {
|
|
94
|
+
return serieParentsSets[ind].has(i);
|
|
95
|
+
}, removed);
|
|
96
|
+
return R.concat(filteredRemoved, mIs || []);
|
|
97
|
+
}, missingIndexes);
|
|
98
|
+
}), R.over(R.lensProp('parentsIndexes'), function () {
|
|
99
|
+
var parentsIndexes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
100
|
+
return R.addIndex(R.map)(function (p, ind) {
|
|
101
|
+
return R.reject(function (i) {
|
|
102
|
+
return R.includes(i, R.nth(ind, removedMissingIndexes) || []);
|
|
103
|
+
}, p || []);
|
|
104
|
+
}, parentsIndexes);
|
|
105
|
+
}))(serie);
|
|
106
|
+
removedMissingIndexes = [];
|
|
107
|
+
return R.append(_serie, acc);
|
|
108
|
+
}, [], series);
|
|
109
|
+
};
|
|
110
|
+
|
|
63
111
|
var refineSections = exports.refineSections = function refineSections(sections, extractedKeys, curatedObs) {
|
|
64
112
|
return R.pipe(R.map(function (section) {
|
|
65
113
|
var sectionKey = toKey(R.propOr([], 'indexes', R.head(section)));
|
|
66
|
-
|
|
114
|
+
var getHasRowStillData = function getHasRowStillData(row) {
|
|
67
115
|
var rowKey = toKey(R.prop('indexes', row));
|
|
68
116
|
return R.pipe(R.path([sectionKey, rowKey]), R.omit(extractedKeys), R.isEmpty, R.not)(curatedObs);
|
|
69
|
-
}
|
|
117
|
+
};
|
|
118
|
+
return R.over(R.lensIndex(1), function (rows) {
|
|
119
|
+
return filterSeries(rows, getHasRowStillData);
|
|
120
|
+
})(section);
|
|
70
121
|
}), R.filter(R.pipe(R.nth(1), R.isEmpty, R.not)))(sections);
|
|
71
122
|
};
|
|
72
123
|
|
|
73
|
-
var refineHeader = exports.refineHeader = function refineHeader(
|
|
74
|
-
|
|
75
|
-
function (header) {
|
|
124
|
+
var refineHeader = exports.refineHeader = function refineHeader(headers, extractedKeys, curatedObs) {
|
|
125
|
+
var getHasHeaderStillData = function getHasHeaderStillData(header) {
|
|
76
126
|
var headerKey = toKey(R.prop('indexes', header));
|
|
77
127
|
return R.pipe(R.prop(headerKey), function (sections) {
|
|
78
128
|
return R.pickBy(function (rows, section) {
|
|
79
129
|
return R.pipe(R.omit(R.propOr([], section, extractedKeys)), R.isEmpty, R.not)(rows);
|
|
80
130
|
}, sections);
|
|
81
131
|
}, R.isEmpty, R.not)(curatedObs);
|
|
82
|
-
}
|
|
132
|
+
};
|
|
133
|
+
return filterSeries(headers, getHasHeaderStillData);
|
|
83
134
|
};
|
|
84
135
|
|
|
85
136
|
var getSerieLinesCount = function getSerieLinesCount(serie) {
|
package/package.json
CHANGED
|
@@ -2,11 +2,12 @@ import * as R from 'ramda';
|
|
|
2
2
|
import { getFlagsAndNotes } from './getFlagsAndNotes';
|
|
3
3
|
import { getLayoutCoordinatesValidator } from '../utils';
|
|
4
4
|
|
|
5
|
-
const getValueData = (index, dimension, parentsIndexes) => ({
|
|
5
|
+
const getValueData = (index, dimension, parentsIndexes, missingParents = []) => ({
|
|
6
6
|
dimension: R.pick(['id', 'name', '__index'], dimension),
|
|
7
7
|
value: {
|
|
8
8
|
...R.pipe(R.pathOr({}, ['values', index]), R.pick(['id', 'name']))(dimension),
|
|
9
|
-
parents: parentsIndexes
|
|
9
|
+
parents: parentsIndexes,
|
|
10
|
+
missingParents
|
|
10
11
|
}
|
|
11
12
|
});
|
|
12
13
|
|
|
@@ -18,8 +19,8 @@ const simpleValueDataSetter = (valueData, datas = []) => R.append(valueData, dat
|
|
|
18
19
|
const combinedValueDataSetter = (valueData, datas = []) =>
|
|
19
20
|
R.over(R.lensIndex(-1), d => ({ ...d, values: R.append(R.prop('value', valueData), d.values) }), datas);
|
|
20
21
|
|
|
21
|
-
const addValueToSerieData = (dataSetter) => (index, parentsIndexes, dimension, serieData) => {
|
|
22
|
-
const valueData = getValueData(index, dimension, parentsIndexes);
|
|
22
|
+
const addValueToSerieData = (dataSetter) => (index, parentsIndexes, dimension, serieData, missingParents) => {
|
|
23
|
+
const valueData = getValueData(index, dimension, parentsIndexes, missingParents);
|
|
23
24
|
const valueId = R.path(['value', 'id'], valueData);
|
|
24
25
|
return ({
|
|
25
26
|
...serieData,
|
|
@@ -54,7 +55,7 @@ const getAttributesSeries = (validator, attributesSeries) => R.reduce((acc, attr
|
|
|
54
55
|
const attr = R.head(R.values(attrs));
|
|
55
56
|
const coordinates = R.propOr({}, 'coordinates', attr);
|
|
56
57
|
const isValid = validator(coordinates);
|
|
57
|
-
if (!isValid && !
|
|
58
|
+
if (!isValid && !R.prop('isObs', attr)) {
|
|
58
59
|
return acc;
|
|
59
60
|
}
|
|
60
61
|
return ({ ...acc, ...attrs });
|
|
@@ -89,81 +90,95 @@ const getSerieFlagsAndSideProps = (coordinates, validator, attributesValues, cus
|
|
|
89
90
|
return { flags, sideProps };
|
|
90
91
|
};
|
|
91
92
|
|
|
92
|
-
|
|
93
|
+
const getSerieDimensionsData = (serie, definition, attributesValues, missingParentsGetter) => R.addIndex(R.reduce)(
|
|
94
|
+
(onGoingSerie, entry, index) => {
|
|
95
|
+
if (R.has('dimensions', entry)) {
|
|
96
|
+
const combValuesIndexes = R.pathOr([], ['indexes', index], serie);
|
|
97
|
+
const combParentsIndexes = R.pathOr([], ['parentsIndexes', index], serie);
|
|
98
|
+
const combMissingParentsIndexes = R.pathOr([], ['missingIndexes', index], serie);
|
|
99
|
+
let combDimValues = {};
|
|
100
|
+
const res = R.addIndex(R.reduce)((combSerie, dimension, dimIndex) => {
|
|
101
|
+
const valueIndex = Math.abs(R.nth(dimIndex, combValuesIndexes));
|
|
102
|
+
const _parentsIndexes = R.nth(dimIndex, combParentsIndexes) || [];
|
|
103
|
+
const missingParentsIndexes = R.nth(dimIndex, combMissingParentsIndexes) || [];
|
|
104
|
+
const { parentsIndexes, missingParents } = missingParentsGetter(combinedValueDataSetter)(missingParentsIndexes, _parentsIndexes, dimension, combSerie);
|
|
105
|
+
const next = addCombinedValueToSerieData(valueIndex, parentsIndexes, dimension, combSerie, missingParents);
|
|
106
|
+
const value = R.pipe(R.prop('data'), R.last, R.prop('values'), R.last)(next);
|
|
107
|
+
combDimValues = R.assoc(dimension.id, value, combDimValues);
|
|
108
|
+
return next;
|
|
109
|
+
},
|
|
110
|
+
R.over(
|
|
111
|
+
R.lensProp('data'),
|
|
112
|
+
R.append({ dimension: R.pick(['id', 'name'], entry), values: [] })
|
|
113
|
+
)(onGoingSerie),
|
|
114
|
+
R.propOr([], 'dimensions', entry));
|
|
115
|
+
|
|
116
|
+
const combined = combineConcepts(combDimValues, entry, onGoingSerie.attributes)(res);
|
|
117
|
+
return R.over(R.lensProp('attributes'), R.omit(entry.concepts), combined);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const valueIndex = Math.abs(R.path(['indexes', index], serie));
|
|
121
|
+
const _parentsIndexes = R.pathOr([], ['parentsIndexes', index], serie);
|
|
122
|
+
const missingParentsIndexes = R.pathOr([], ['missingIndexes', index], serie);
|
|
123
|
+
const { parentsIndexes, missingParents } = missingParentsGetter(simpleValueDataSetter)(missingParentsIndexes, _parentsIndexes, entry, onGoingSerie);
|
|
124
|
+
return addSimpleValueToSerieData(valueIndex, parentsIndexes, entry, onGoingSerie, missingParents);
|
|
125
|
+
},
|
|
126
|
+
{ data: [], key: '', attributes: attributesValues },
|
|
127
|
+
definition,
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
export const getSerieDataWithMissingLines = (serie, definition, topCoordinates, attributesSeries, customAttributes, metadataCoordinates) => {
|
|
93
131
|
const lines = [];
|
|
94
132
|
|
|
95
133
|
const serieCoordinates = getCoordinates(serie.indexes, topCoordinates, definition);
|
|
96
134
|
const coordinatesValidator = getLayoutCoordinatesValidator(serieCoordinates, topCoordinates);
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const addMissingParentsLines = dataSetter => (missingParentsIndexes, parentsIndexes, dim, serieData) => R.reduce(
|
|
100
|
-
(parents, index) => {
|
|
101
|
-
const missingParentData = addValueToSerieData(dataSetter)(index, parents, dim, serieData);
|
|
102
|
-
lines.push(R.assoc('isEmpty', true, missingParentData));
|
|
103
|
-
return R.append(index, parents);
|
|
104
|
-
}, parentsIndexes, missingParentsIndexes
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
const addSimpleMissingParentsLines = addMissingParentsLines(simpleValueDataSetter);
|
|
108
|
-
const addCombinedMissingParentsLines = addMissingParentsLines(combinedValueDataSetter);
|
|
109
|
-
|
|
110
|
-
const serieData = R.addIndex(R.reduce)(
|
|
111
|
-
(onGoingSerie, entry, index) => {
|
|
112
|
-
if (R.has('dimensions', entry)) {
|
|
113
|
-
const combValuesIndexes = R.pathOr([], ['indexes', index], serie);
|
|
114
|
-
const combParentsIndexes = R.pathOr([], ['parentsIndexes', index], serie);
|
|
115
|
-
const combMissingParentsIndexes = R.pathOr([], ['missingIndexes', index], serie);
|
|
116
|
-
let combDimValues = {};
|
|
117
|
-
const res = R.addIndex(R.reduce)((combSerie, dimension, dimIndex) => {
|
|
118
|
-
const valueIndex = Math.abs(R.nth(dimIndex, combValuesIndexes));
|
|
119
|
-
const _parentsIndexes = R.nth(dimIndex, combParentsIndexes) || [];
|
|
120
|
-
const missingParentsIndexes = R.nth(dimIndex, combMissingParentsIndexes) || [];
|
|
121
|
-
const parentsIndexes = addCombinedMissingParentsLines(missingParentsIndexes, _parentsIndexes, dimension, combSerie);
|
|
122
|
-
const next = addCombinedValueToSerieData(valueIndex, parentsIndexes, dimension, combSerie);
|
|
123
|
-
const value = R.pipe(R.prop('data'), R.last, R.prop('values'), R.last)(next);
|
|
124
|
-
combDimValues = R.assoc(dimension.id, value, combDimValues);
|
|
125
|
-
return next;
|
|
126
|
-
},
|
|
127
|
-
R.over(
|
|
128
|
-
R.lensProp('data'),
|
|
129
|
-
R.append({ dimension: R.pick(['id', 'name'], entry), values: [] })
|
|
130
|
-
)(onGoingSerie),
|
|
131
|
-
R.propOr([], 'dimensions', entry));
|
|
132
|
-
|
|
133
|
-
const combined = combineConcepts(combDimValues, entry, attributesValues)(res);
|
|
134
|
-
attributesValues = R.omit(entry.concepts, attributesValues);
|
|
135
|
-
return combined;
|
|
136
|
-
}
|
|
135
|
+
const attributesValues = getAttributesSeries(coordinatesValidator, attributesSeries);
|
|
137
136
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
return
|
|
137
|
+
const getMissingParents = dataSetter => (missingParentsIndexes, _parentsIndexes, dim, serieData) => R.reduce(
|
|
138
|
+
(acc, index) => {
|
|
139
|
+
const missingParentData = addValueToSerieData(dataSetter)(index, acc.parentsIndexes, dim, serieData);
|
|
140
|
+
lines.push({ ...R.dissoc('attributes', missingParentData), sideProps: null, flags: [], isEmpty: true });
|
|
141
|
+
return R.over(R.lensProp('parentsIndexes'), R.append(index), acc);
|
|
143
142
|
},
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
);
|
|
147
|
-
const { flags, sideProps } = getSerieFlagsAndSideProps(serieCoordinates, coordinatesValidator,
|
|
148
|
-
|
|
149
|
-
|
|
143
|
+
{ parentsIndexes: _parentsIndexes, missingParents: [] }, missingParentsIndexes);
|
|
144
|
+
|
|
145
|
+
const { attributes, ...serieData } = getSerieDimensionsData(serie, definition, attributesValues, getMissingParents);
|
|
146
|
+
const { flags, sideProps } = getSerieFlagsAndSideProps(serieCoordinates, coordinatesValidator, attributes, customAttributes, metadataCoordinates);
|
|
147
|
+
return R.append({ ...serieData, flags, sideProps }, lines);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export const getSerieDataWithoutMissingLines = (serie, definition, topCoordinates, attributesSeries, customAttributes, metadataCoordinates) => {
|
|
151
|
+
const serieCoordinates = getCoordinates(serie.indexes, topCoordinates, definition);
|
|
152
|
+
const coordinatesValidator = getLayoutCoordinatesValidator(serieCoordinates, topCoordinates);
|
|
153
|
+
const attributesValues = getAttributesSeries(coordinatesValidator, attributesSeries);
|
|
154
|
+
|
|
155
|
+
const getMissingParents = () => (missingParentsIndexes, _parentsIndexes, dim) => R.reduce(
|
|
156
|
+
(acc, index) => ({
|
|
157
|
+
parentsIndexes: R.append(index, acc.parentsIndexes),
|
|
158
|
+
missingParents: R.append(R.prop('value', getValueData(index, dim, acc.parentsIndexes)), acc.missingParents)
|
|
159
|
+
}),
|
|
160
|
+
{ parentsIndexes: _parentsIndexes, missingParents: [] }, missingParentsIndexes);
|
|
161
|
+
|
|
162
|
+
const { attributes, ...serieData } = getSerieDimensionsData(serie, definition, attributesValues, getMissingParents);
|
|
163
|
+
const { flags, sideProps } = getSerieFlagsAndSideProps(serieCoordinates, coordinatesValidator, attributes, customAttributes, metadataCoordinates);
|
|
164
|
+
return ({ ...serieData, flags, sideProps });
|
|
150
165
|
};
|
|
151
166
|
|
|
152
167
|
export const getLayoutData = (layoutIndexes, layout, { metadataCoordinates, attributesSeries, customAttributes, topCoordinates={} }) => {
|
|
153
168
|
const { header, sections, ...rest } = layoutIndexes;
|
|
154
169
|
|
|
155
170
|
const headerData = R.reduce((acc, serie) => {
|
|
156
|
-
const datas =
|
|
171
|
+
const datas = getSerieDataWithMissingLines(serie, layout.header, topCoordinates, attributesSeries, customAttributes, metadataCoordinates);
|
|
157
172
|
return R.concat(acc, datas);
|
|
158
173
|
}, [], header);
|
|
159
174
|
|
|
160
175
|
const sectionsData = R.map(
|
|
161
176
|
([sectionSerie, rowsSeries]) => {
|
|
162
|
-
const sectionData =
|
|
177
|
+
const sectionData = getSerieDataWithoutMissingLines(sectionSerie, layout.sections, topCoordinates, attributesSeries, customAttributes, metadataCoordinates, false);
|
|
163
178
|
return [
|
|
164
|
-
|
|
179
|
+
sectionData,
|
|
165
180
|
R.reduce((acc, serie) => {
|
|
166
|
-
const datas =
|
|
181
|
+
const datas = getSerieDataWithMissingLines(serie, layout.rows, R.propOr(topCoordinates, 'coordinates', sectionData), attributesSeries, customAttributes, metadataCoordinates);
|
|
167
182
|
return R.concat(acc, datas);
|
|
168
183
|
}, [], rowsSeries)
|
|
169
184
|
];
|
|
@@ -1,62 +1,59 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const registerParsedIndexes = ({ isSameSerie, ...parsed }, register) => {
|
|
4
|
+
const merged = R.mergeWith((a, b) => R.append(a || [], b), parsed, register);
|
|
5
|
+
return ({ ...merged, isSameSerie });
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const parseSerieIndexesHierarchies = (serieIndexes, previousSerie, dimensions, defaultIsSameSerie = true) => {
|
|
4
9
|
return R.addIndex(R.reduce)((acc, _valueIndex, dimensionIndex) => {
|
|
5
10
|
if (R.is(Array, _valueIndex)) {
|
|
6
|
-
const previous = R.isEmpty(previousSerie) ? {} :
|
|
7
|
-
indexes: R.nth(dimensionIndex, previousSerie.indexes || []),
|
|
8
|
-
parentsIndexes: R.nth(dimensionIndex, previousSerie.parentsIndexes || []),
|
|
9
|
-
missingIndexes: R.nth(dimensionIndex, previousSerie.missingIndexes || []),
|
|
10
|
-
registeredIndexes: R.nth(dimensionIndex, previousSerie.registeredIndexes || []),
|
|
11
|
-
};
|
|
11
|
+
const previous = R.isEmpty(previousSerie) ? {} : R.map(R.nth(dimensionIndex), previousSerie);
|
|
12
12
|
const parsed = parseSerieIndexesHierarchies(_valueIndex, previous, R.pathOr([], [dimensionIndex, 'dimensions'], dimensions), acc.isSameSerie);
|
|
13
|
-
|
|
14
|
-
parentsIndexes: R.append(parsed.parentsIndexes, acc.parentsIndexes),
|
|
15
|
-
missingIndexes: R.append(parsed.missingIndexes, acc.missingIndexes),
|
|
16
|
-
registeredIndexes: R.append(parsed.registeredIndexes, acc.registeredIndexes),
|
|
17
|
-
isSameSerie: parsed.isSameSerie
|
|
18
|
-
});
|
|
13
|
+
return registerParsedIndexes(parsed, acc);
|
|
19
14
|
}
|
|
20
15
|
const valueIndex = Math.abs(_valueIndex);
|
|
21
|
-
const
|
|
16
|
+
const parents = R.pathOr([], [dimensionIndex, 'values', valueIndex, 'parents'], dimensions);
|
|
22
17
|
const previousIndex = acc.isSameSerie ? R.pathOr(-1, ['indexes', dimensionIndex], previousSerie) : -1;
|
|
23
18
|
const previousRegisteredIndexes = acc.isSameSerie ? R.pathOr(new Set(), ['registeredIndexes', dimensionIndex], previousSerie) : new Set();
|
|
24
19
|
const registeredIndexes = new Set(previousRegisteredIndexes);
|
|
25
|
-
const
|
|
26
|
-
if (previousRegisteredIndexes.has(
|
|
27
|
-
return R.over(R.
|
|
20
|
+
const { presentParentsIndexes, missingParentsIndexes } = R.reduce((_acc, i) => {
|
|
21
|
+
if (previousRegisteredIndexes.has(i)) {
|
|
22
|
+
return R.over(R.lensProp('presentParentsIndexes'), p => R.isNil(p) ? [i] : R.append(i, p), _acc);
|
|
28
23
|
}
|
|
29
|
-
else if
|
|
30
|
-
registeredIndexes.add(
|
|
31
|
-
return R.over(R.
|
|
24
|
+
else if (i > previousIndex && R.pathOr(false, [dimensionIndex, 'values', i, 'isSelected'], dimensions)) {
|
|
25
|
+
registeredIndexes.add(i);
|
|
26
|
+
return R.over(R.lensProp('missingParentsIndexes'), m => R.isNil(m) ? [i] : R.append(i, m), _acc);
|
|
32
27
|
}
|
|
33
28
|
return _acc;
|
|
34
|
-
},
|
|
29
|
+
}, {}, parents);
|
|
35
30
|
registeredIndexes.add(valueIndex);
|
|
36
|
-
return ({
|
|
37
|
-
|
|
38
|
-
missingIndexes: R.append(missingParentsIndexes, acc.missingIndexes),
|
|
39
|
-
registeredIndexes: R.append(registeredIndexes, acc.registeredIndexes),
|
|
40
|
-
isSameSerie: acc.isSameSerie && valueIndex === previousIndex
|
|
41
|
-
});
|
|
42
|
-
}, { parentsIndexes: [], missingIndexes: [], registeredIndexes: [], isSameSerie }, serieIndexes);
|
|
31
|
+
return registerParsedIndexes({ parentsIndexes: presentParentsIndexes, missingIndexes: missingParentsIndexes, registeredIndexes, isSameSerie: acc.isSameSerie && valueIndex === previousIndex }, acc);
|
|
32
|
+
}, { parentsIndexes: [], missingIndexes: [], registeredIndexes: [], isSameSerie: defaultIsSameSerie }, serieIndexes);
|
|
43
33
|
};
|
|
44
34
|
|
|
45
|
-
export const parseSeriesIndexesHierarchies = (seriesIndexes, dimensions) =>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
35
|
+
export const parseSeriesIndexesHierarchies = (seriesIndexes, dimensions) => {
|
|
36
|
+
return R.reduce((acc, serieIndexes) => {
|
|
37
|
+
const previousSerie = R.last(acc) || {};
|
|
38
|
+
const { isSameSerie, ...parsed } = parseSerieIndexesHierarchies(serieIndexes, previousSerie, dimensions);
|
|
39
|
+
return R.append(R.assoc('indexes', serieIndexes, parsed), acc);
|
|
40
|
+
}, [], seriesIndexes);
|
|
41
|
+
};
|
|
50
42
|
|
|
51
43
|
export const parseLayoutIndexesHierarchies = (layoutIndexes, layout) => {
|
|
52
44
|
const header = parseSeriesIndexesHierarchies(layoutIndexes.header, layout.header);
|
|
53
|
-
const sections = R.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
45
|
+
const sections = R.pipe(
|
|
46
|
+
R.transpose,
|
|
47
|
+
([_sections, _sectionsRows]) => {
|
|
48
|
+
if (R.isNil(_sections)) {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
const sections = parseSeriesIndexesHierarchies(_sections, layout.sections);
|
|
52
|
+
const sectionsRows = R.map(rows => parseSeriesIndexesHierarchies(rows, layout.rows), _sectionsRows);
|
|
53
|
+
return R.transpose([sections, sectionsRows]);
|
|
54
|
+
}
|
|
55
|
+
)(layoutIndexes.sections);
|
|
56
|
+
|
|
60
57
|
|
|
61
58
|
return ({ header, sections });
|
|
62
59
|
};
|
|
@@ -2,8 +2,11 @@ import * as R from 'ramda';
|
|
|
2
2
|
|
|
3
3
|
const toKey = indexes => R.reduce(
|
|
4
4
|
(acc, _ind) => {
|
|
5
|
-
const ind = R.is(Array, _ind) ? toKey(_ind) : Math.abs(_ind);
|
|
6
|
-
|
|
5
|
+
const ind = R.is(Array, _ind) ? toKey(_ind) : String(Math.abs(_ind));
|
|
6
|
+
if (R.isEmpty(ind)) {
|
|
7
|
+
return acc;
|
|
8
|
+
}
|
|
9
|
+
return R.isEmpty(acc) ? ind : `${acc}:${ind}`
|
|
7
10
|
},
|
|
8
11
|
'',
|
|
9
12
|
indexes
|
|
@@ -47,23 +50,58 @@ export const getCuratedCells = ({ layout, observations, shape }) => {
|
|
|
47
50
|
return indexWithPivots(pivots, observations);
|
|
48
51
|
};
|
|
49
52
|
|
|
53
|
+
const filterSeries = (series, getHasStillData) => {
|
|
54
|
+
let removedMissingIndexes = [];
|
|
55
|
+
return R.reduce((acc, serie) => {
|
|
56
|
+
const hasStillData = getHasStillData(serie);
|
|
57
|
+
const serieParentsSets = R.map(p => new Set(p), R.propOr([], 'parentsIndexes', serie));
|
|
58
|
+
if (!hasStillData) {
|
|
59
|
+
removedMissingIndexes = R.addIndex(R.map)((mIs, ind) => {
|
|
60
|
+
const filtered = R.filter(i => serieParentsSets[ind].has(i), R.nth(ind, removedMissingIndexes) || []);
|
|
61
|
+
return R.concat(filtered, mIs);
|
|
62
|
+
}, serie.missingIndexes || []);
|
|
63
|
+
return acc;
|
|
64
|
+
}
|
|
65
|
+
const _serie = R.pipe(
|
|
66
|
+
R.over(
|
|
67
|
+
R.lensProp('missingIndexes'),
|
|
68
|
+
(missingIndexes = []) => R.addIndex(R.map)((mIs, ind) => {
|
|
69
|
+
const removed = R.nth(ind, removedMissingIndexes) || [];
|
|
70
|
+
if (R.isEmpty(removed)) {
|
|
71
|
+
return mIs;
|
|
72
|
+
}
|
|
73
|
+
const filteredRemoved = R.filter(i => serieParentsSets[ind].has(i), removed);
|
|
74
|
+
return R.concat(filteredRemoved, mIs || []);
|
|
75
|
+
}, missingIndexes)
|
|
76
|
+
),
|
|
77
|
+
R.over(
|
|
78
|
+
R.lensProp('parentsIndexes'),
|
|
79
|
+
(parentsIndexes = []) => R.addIndex(R.map)((p, ind) => {
|
|
80
|
+
return R.reject(i => R.includes(i, R.nth(ind, removedMissingIndexes) || []), p || []);
|
|
81
|
+
}, parentsIndexes)
|
|
82
|
+
)
|
|
83
|
+
)(serie);
|
|
84
|
+
removedMissingIndexes = [];
|
|
85
|
+
return R.append(_serie, acc);
|
|
86
|
+
}, [], series);
|
|
87
|
+
};
|
|
88
|
+
|
|
50
89
|
export const refineSections = (sections, extractedKeys, curatedObs) => R.pipe(
|
|
51
90
|
R.map(
|
|
52
91
|
(section) => {
|
|
53
92
|
const sectionKey = toKey(R.propOr([], 'indexes', R.head(section)));
|
|
93
|
+
const getHasRowStillData = (row) => {
|
|
94
|
+
const rowKey = toKey(R.prop('indexes', row));
|
|
95
|
+
return R.pipe(
|
|
96
|
+
R.path([sectionKey, rowKey]),
|
|
97
|
+
R.omit(extractedKeys),
|
|
98
|
+
R.isEmpty,
|
|
99
|
+
R.not
|
|
100
|
+
)(curatedObs);
|
|
101
|
+
};
|
|
54
102
|
return R.over(
|
|
55
103
|
R.lensIndex(1),
|
|
56
|
-
|
|
57
|
-
row => {
|
|
58
|
-
const rowKey = toKey(R.prop('indexes', row));
|
|
59
|
-
return R.pipe(
|
|
60
|
-
R.path([sectionKey, rowKey]),
|
|
61
|
-
R.omit(extractedKeys),
|
|
62
|
-
R.isEmpty,
|
|
63
|
-
R.not
|
|
64
|
-
)(curatedObs);
|
|
65
|
-
}
|
|
66
|
-
)
|
|
104
|
+
rows => filterSeries(rows, getHasRowStillData)
|
|
67
105
|
)(section);
|
|
68
106
|
}
|
|
69
107
|
),
|
|
@@ -72,8 +110,8 @@ export const refineSections = (sections, extractedKeys, curatedObs) => R.pipe(
|
|
|
72
110
|
)
|
|
73
111
|
)(sections);
|
|
74
112
|
|
|
75
|
-
export const refineHeader = (
|
|
76
|
-
(header) => {
|
|
113
|
+
export const refineHeader = (headers, extractedKeys, curatedObs) => {
|
|
114
|
+
const getHasHeaderStillData = (header) => {
|
|
77
115
|
const headerKey = toKey(R.prop('indexes', header));
|
|
78
116
|
return R.pipe(
|
|
79
117
|
R.prop(headerKey),
|
|
@@ -90,8 +128,9 @@ export const refineHeader = (header, extractedKeys, curatedObs) => R.filter( //
|
|
|
90
128
|
R.isEmpty,
|
|
91
129
|
R.not
|
|
92
130
|
)(curatedObs);
|
|
93
|
-
}
|
|
94
|
-
|
|
131
|
+
};
|
|
132
|
+
return filterSeries(headers, getHasHeaderStillData);
|
|
133
|
+
};
|
|
95
134
|
|
|
96
135
|
const getSerieLinesCount = serie => {
|
|
97
136
|
const missingParents = R.propOr([], 'missingParents', serie);
|
|
@@ -245,7 +284,7 @@ export const refineLayoutSize = ({ layout, observations, limit }) => layoutIndex
|
|
|
245
284
|
// total of cells in one column
|
|
246
285
|
const columnCellsCount = headerDimCount + rowsCount;
|
|
247
286
|
|
|
248
|
-
const isVertical = columnCellsCount > rowCellsCount
|
|
287
|
+
const isVertical = columnCellsCount > rowCellsCount;
|
|
249
288
|
|
|
250
289
|
const [toTruncate, toRefine] = segregateLayout(isVertical)(layoutIndexes);
|
|
251
290
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { expect } from 'chai';
|
|
2
|
-
import {
|
|
2
|
+
import { getSerieDataWithMissingLines, getSerieDataWithoutMissingLines } from '../src/rules2/src/table/getLayoutData2';
|
|
3
3
|
|
|
4
4
|
describe('getLayoutData 2 tests', () => {
|
|
5
|
-
it('
|
|
5
|
+
it('getSerieDataWithMissingLines test 1', () => {
|
|
6
6
|
const dimensions = [
|
|
7
7
|
{
|
|
8
8
|
id: 'D0',
|
|
@@ -28,9 +28,9 @@ describe('getLayoutData 2 tests', () => {
|
|
|
28
28
|
];
|
|
29
29
|
|
|
30
30
|
const serie = { indexes: [0, 3], parentsIndexes: [[], []], missingIndexes: [[], [0, 2]] };
|
|
31
|
-
expect(
|
|
31
|
+
expect(getSerieDataWithMissingLines(serie, dimensions, {}, {}, {}, {})).to.deep.equal([
|
|
32
32
|
{
|
|
33
|
-
data: [{ dimension: { id: 'D0' }, value: { id: 'v0', parents: [] } }, { dimension: { id: 'D1' }, value: { id: 'W', parents: [] } }],
|
|
33
|
+
data: [{ dimension: { id: 'D0' }, value: { id: 'v0', parents: [], missingParents: [] } }, { dimension: { id: 'D1' }, value: { id: 'W', parents: [], missingParents: [] } }],
|
|
34
34
|
coordinates: { D0: 'v0', D1: 'W' },
|
|
35
35
|
key: 'D0=v0:D1=W',
|
|
36
36
|
flags: [],
|
|
@@ -38,7 +38,7 @@ describe('getLayoutData 2 tests', () => {
|
|
|
38
38
|
isEmpty: true,
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
|
-
data: [{ dimension: { id: 'D0' }, value: { id: 'v0', parents: [] } }, { dimension: { id: 'D1' }, value: { id: 'A', parents: [0] } }],
|
|
41
|
+
data: [{ dimension: { id: 'D0' }, value: { id: 'v0', parents: [], missingParents: [] } }, { dimension: { id: 'D1' }, value: { id: 'A', parents: [0], missingParents: [] } }],
|
|
42
42
|
coordinates: { D0: 'v0', D1: 'A' },
|
|
43
43
|
key: 'D0=v0:D1=A',
|
|
44
44
|
flags: [],
|
|
@@ -46,7 +46,7 @@ describe('getLayoutData 2 tests', () => {
|
|
|
46
46
|
isEmpty: true
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
|
-
data: [{ dimension: { id: 'D0' }, value: { id: 'v0', parents: [] } }, { dimension: { id: 'D1' }, value: { id: 'USA', parents: [0, 2] } }],
|
|
49
|
+
data: [{ dimension: { id: 'D0' }, value: { id: 'v0', parents: [], missingParents: [] } }, { dimension: { id: 'D1' }, value: { id: 'USA', parents: [0, 2], missingParents: [] } }],
|
|
50
50
|
coordinates: { D0: 'v0', D1: 'USA' },
|
|
51
51
|
key: 'D0=v0:D1=USA',
|
|
52
52
|
flags: [],
|
|
@@ -54,7 +54,7 @@ describe('getLayoutData 2 tests', () => {
|
|
|
54
54
|
}
|
|
55
55
|
]);
|
|
56
56
|
});
|
|
57
|
-
it('
|
|
57
|
+
it('getSerieDataWithMissingLines test 2', () => {
|
|
58
58
|
const dimensions = [
|
|
59
59
|
{
|
|
60
60
|
id: 'D0',
|
|
@@ -128,10 +128,10 @@ describe('getLayoutData 2 tests', () => {
|
|
|
128
128
|
missingIndexes: [[0, 2], [[0, 1], [0, 1]], [[0, 1], [0, 1]]],
|
|
129
129
|
};
|
|
130
130
|
|
|
131
|
-
expect(
|
|
131
|
+
expect(getSerieDataWithMissingLines(serie, dimensions, topCoordinates, attributesSeries, {}, {})).to.deep.equal([
|
|
132
132
|
{
|
|
133
133
|
data: [
|
|
134
|
-
{ dimension: { id: 'D0' }, value: { id: 'W', parents: [] } }
|
|
134
|
+
{ dimension: { id: 'D0' }, value: { id: 'W', parents: [], missingParents: [] } }
|
|
135
135
|
],
|
|
136
136
|
coordinates: { D0: 'W' },
|
|
137
137
|
key: 'D0=W',
|
|
@@ -141,7 +141,7 @@ describe('getLayoutData 2 tests', () => {
|
|
|
141
141
|
},
|
|
142
142
|
{
|
|
143
143
|
data: [
|
|
144
|
-
{ dimension: { id: 'D0' }, value: { id: 'A', parents: [0] } }
|
|
144
|
+
{ dimension: { id: 'D0' }, value: { id: 'A', parents: [0], missingParents: [] } }
|
|
145
145
|
],
|
|
146
146
|
coordinates: { D0: 'A' },
|
|
147
147
|
key: 'D0=A',
|
|
@@ -151,8 +151,8 @@ describe('getLayoutData 2 tests', () => {
|
|
|
151
151
|
},
|
|
152
152
|
{
|
|
153
153
|
data: [
|
|
154
|
-
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2] } },
|
|
155
|
-
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT', parents: [] }] }
|
|
154
|
+
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2], missingParents: [] } },
|
|
155
|
+
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT', parents: [], missingParents: [] }] }
|
|
156
156
|
],
|
|
157
157
|
coordinates: { D0: 'USA', D1: 'D1ROOT' },
|
|
158
158
|
key: 'D0=USA:D1=D1ROOT',
|
|
@@ -162,8 +162,8 @@ describe('getLayoutData 2 tests', () => {
|
|
|
162
162
|
},
|
|
163
163
|
{
|
|
164
164
|
data: [
|
|
165
|
-
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2] } },
|
|
166
|
-
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT>CHILD', parents: [0] }] }
|
|
165
|
+
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2], missingParents: [] } },
|
|
166
|
+
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT>CHILD', parents: [0], missingParents: [] }] }
|
|
167
167
|
],
|
|
168
168
|
coordinates: { D0: 'USA', D1: 'D1ROOT>CHILD' },
|
|
169
169
|
key: 'D0=USA:D1=D1ROOT>CHILD',
|
|
@@ -173,8 +173,8 @@ describe('getLayoutData 2 tests', () => {
|
|
|
173
173
|
},
|
|
174
174
|
{
|
|
175
175
|
data: [
|
|
176
|
-
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2] } },
|
|
177
|
-
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT>CHILD>CHILD', parents: [0, 1] }, { id: 'D2ROOT', parents: [] }] }
|
|
176
|
+
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2], missingParents: [] } },
|
|
177
|
+
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT>CHILD>CHILD', parents: [0, 1], missingParents: [] }, { id: 'D2ROOT', parents: [], missingParents: [] }] }
|
|
178
178
|
],
|
|
179
179
|
coordinates: { D0: 'USA', D1: 'D1ROOT>CHILD>CHILD', D2: 'D2ROOT' },
|
|
180
180
|
key: 'D0=USA:D1=D1ROOT>CHILD>CHILD:D2=D2ROOT',
|
|
@@ -184,8 +184,8 @@ describe('getLayoutData 2 tests', () => {
|
|
|
184
184
|
},
|
|
185
185
|
{
|
|
186
186
|
data: [
|
|
187
|
-
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2] } },
|
|
188
|
-
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT>CHILD>CHILD', parents: [0, 1] }, { id: 'D2ROOT>CHILD', parents: [0] }] }
|
|
187
|
+
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2], missingParents: [] } },
|
|
188
|
+
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT>CHILD>CHILD', parents: [0, 1], missingParents: [] }, { id: 'D2ROOT>CHILD', parents: [0], missingParents: [] }] }
|
|
189
189
|
],
|
|
190
190
|
coordinates: { D0: 'USA', D1: 'D1ROOT>CHILD>CHILD', D2: 'D2ROOT>CHILD' },
|
|
191
191
|
key: 'D0=USA:D1=D1ROOT>CHILD>CHILD:D2=D2ROOT>CHILD',
|
|
@@ -195,9 +195,9 @@ describe('getLayoutData 2 tests', () => {
|
|
|
195
195
|
},
|
|
196
196
|
{
|
|
197
197
|
data: [
|
|
198
|
-
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2] } },
|
|
199
|
-
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT>CHILD>CHILD', parents: [0, 1] }, { id: 'A0VAL' }, { id: 'D2ROOT>CHILD>CHILD', parents: [0, 1] }] },
|
|
200
|
-
{ dimension: { id: 'COMB1' }, values: [{ id: 'D3ROOT', parents: [] }] }
|
|
198
|
+
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2], missingParents: [] } },
|
|
199
|
+
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT>CHILD>CHILD', parents: [0, 1], missingParents: [] }, { id: 'A0VAL' }, { id: 'D2ROOT>CHILD>CHILD', parents: [0, 1], missingParents: [] }] },
|
|
200
|
+
{ dimension: { id: 'COMB1' }, values: [{ id: 'D3ROOT', parents: [], missingParents: [] }] }
|
|
201
201
|
],
|
|
202
202
|
coordinates: { D0: 'USA', D1: 'D1ROOT>CHILD>CHILD', D2: 'D2ROOT>CHILD>CHILD', D3: 'D3ROOT' },
|
|
203
203
|
key: 'D0=USA:D1=D1ROOT>CHILD>CHILD:D2=D2ROOT>CHILD>CHILD:D3=D3ROOT',
|
|
@@ -207,9 +207,9 @@ describe('getLayoutData 2 tests', () => {
|
|
|
207
207
|
},
|
|
208
208
|
{
|
|
209
209
|
data: [
|
|
210
|
-
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2] } },
|
|
211
|
-
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT>CHILD>CHILD', parents: [0, 1] }, { id: 'A0VAL' }, { id: 'D2ROOT>CHILD>CHILD', parents: [0, 1] }] },
|
|
212
|
-
{ dimension: { id: 'COMB1' }, values: [{ id: 'D3ROOT>CHILD', parents: [0] }] }
|
|
210
|
+
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2], missingParents: [] } },
|
|
211
|
+
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT>CHILD>CHILD', parents: [0, 1], missingParents: [] }, { id: 'A0VAL' }, { id: 'D2ROOT>CHILD>CHILD', parents: [0, 1], missingParents: [] }] },
|
|
212
|
+
{ dimension: { id: 'COMB1' }, values: [{ id: 'D3ROOT>CHILD', parents: [0], missingParents: [] }] }
|
|
213
213
|
],
|
|
214
214
|
coordinates: { D0: 'USA', D1: 'D1ROOT>CHILD>CHILD', D2: 'D2ROOT>CHILD>CHILD', D3: 'D3ROOT>CHILD' },
|
|
215
215
|
key: 'D0=USA:D1=D1ROOT>CHILD>CHILD:D2=D2ROOT>CHILD>CHILD:D3=D3ROOT>CHILD',
|
|
@@ -219,9 +219,9 @@ describe('getLayoutData 2 tests', () => {
|
|
|
219
219
|
},
|
|
220
220
|
{
|
|
221
221
|
data: [
|
|
222
|
-
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2] } },
|
|
223
|
-
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT>CHILD>CHILD', parents: [0, 1] }, { id: 'A0VAL' }, { id: 'D2ROOT>CHILD>CHILD', parents: [0, 1] }] },
|
|
224
|
-
{ dimension: { id: 'COMB1' }, values: [{ id: 'D3ROOT>CHILD>CHILD', parents: [0, 1] }, { id: 'D4ROOT', parents: [] }] }
|
|
222
|
+
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2], missingParents: [] } },
|
|
223
|
+
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT>CHILD>CHILD', parents: [0, 1], missingParents: [] }, { id: 'A0VAL' }, { id: 'D2ROOT>CHILD>CHILD', parents: [0, 1], missingParents: [] }] },
|
|
224
|
+
{ dimension: { id: 'COMB1' }, values: [{ id: 'D3ROOT>CHILD>CHILD', parents: [0, 1], missingParents: [] }, { id: 'D4ROOT', parents: [], missingParents: [] }] }
|
|
225
225
|
],
|
|
226
226
|
coordinates: { D0: 'USA', D1: 'D1ROOT>CHILD>CHILD', D2: 'D2ROOT>CHILD>CHILD', D3: 'D3ROOT>CHILD>CHILD', D4: 'D4ROOT' },
|
|
227
227
|
key: 'D0=USA:D1=D1ROOT>CHILD>CHILD:D2=D2ROOT>CHILD>CHILD:D3=D3ROOT>CHILD>CHILD:D4=D4ROOT',
|
|
@@ -232,9 +232,9 @@ describe('getLayoutData 2 tests', () => {
|
|
|
232
232
|
|
|
233
233
|
{
|
|
234
234
|
data: [
|
|
235
|
-
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2] } },
|
|
236
|
-
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT>CHILD>CHILD', parents: [0, 1] }, { id: 'A0VAL' }, { id: 'D2ROOT>CHILD>CHILD', parents: [0, 1] }] },
|
|
237
|
-
{ dimension: { id: 'COMB1' }, values: [{ id: 'D3ROOT>CHILD>CHILD', parents: [0, 1] }, { id: 'D4ROOT>CHILD', parents: [0] }] }
|
|
235
|
+
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2], missingParents: [] } },
|
|
236
|
+
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT>CHILD>CHILD', parents: [0, 1], missingParents: [] }, { id: 'A0VAL' }, { id: 'D2ROOT>CHILD>CHILD', parents: [0, 1], missingParents: [] }] },
|
|
237
|
+
{ dimension: { id: 'COMB1' }, values: [{ id: 'D3ROOT>CHILD>CHILD', parents: [0, 1], missingParents: [] }, { id: 'D4ROOT>CHILD', parents: [0], missingParents: [] }] }
|
|
238
238
|
],
|
|
239
239
|
coordinates: { D0: 'USA', D1: 'D1ROOT>CHILD>CHILD', D2: 'D2ROOT>CHILD>CHILD', D3: 'D3ROOT>CHILD>CHILD', D4: 'D4ROOT>CHILD' },
|
|
240
240
|
key: 'D0=USA:D1=D1ROOT>CHILD>CHILD:D2=D2ROOT>CHILD>CHILD:D3=D3ROOT>CHILD>CHILD:D4=D4ROOT>CHILD',
|
|
@@ -244,9 +244,9 @@ describe('getLayoutData 2 tests', () => {
|
|
|
244
244
|
},
|
|
245
245
|
{
|
|
246
246
|
data: [
|
|
247
|
-
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2] } },
|
|
248
|
-
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT>CHILD>CHILD', parents: [0, 1] }, { id: 'A0VAL' }, { id: 'D2ROOT>CHILD>CHILD', parents: [0, 1] }] },
|
|
249
|
-
{ dimension: { id: 'COMB1' }, values: [{ id: 'D3ROOT>CHILD>CHILD', parents: [0, 1] }, { id: 'D4ROOT>CHILD>CHILD', parents: [0, 1] }] }
|
|
247
|
+
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2], missingParents: [] } },
|
|
248
|
+
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT>CHILD>CHILD', parents: [0, 1], missingParents: [] }, { id: 'A0VAL' }, { id: 'D2ROOT>CHILD>CHILD', parents: [0, 1], missingParents: [] }] },
|
|
249
|
+
{ dimension: { id: 'COMB1' }, values: [{ id: 'D3ROOT>CHILD>CHILD', parents: [0, 1], missingParents: [] }, { id: 'D4ROOT>CHILD>CHILD', parents: [0, 1], missingParents: [] }] }
|
|
250
250
|
],
|
|
251
251
|
coordinates: { D0: 'USA', D1: 'D1ROOT>CHILD>CHILD', D2: 'D2ROOT>CHILD>CHILD', D3: 'D3ROOT>CHILD>CHILD', D4: 'D4ROOT>CHILD>CHILD' },
|
|
252
252
|
key: 'D0=USA:D1=D1ROOT>CHILD>CHILD:D2=D2ROOT>CHILD>CHILD:D3=D3ROOT>CHILD>CHILD:D4=D4ROOT>CHILD>CHILD',
|
|
@@ -264,5 +264,114 @@ describe('getLayoutData 2 tests', () => {
|
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
266
|
]);
|
|
267
|
+
});
|
|
268
|
+
it('getSerieDataWithMissingLines test 2', () => {
|
|
269
|
+
const dimensions = [
|
|
270
|
+
{
|
|
271
|
+
id: 'D0',
|
|
272
|
+
values: [
|
|
273
|
+
{ id: 'W' },
|
|
274
|
+
{ id: 'NA', parentsIndexes: [0] },
|
|
275
|
+
{ id: 'A', parentsIndexes: [0, 1] },
|
|
276
|
+
{ id: 'USA', parentsIndexes: [0, 1, 2] },
|
|
277
|
+
{ id: 'CAN', parentsIndexes: [0, 1, 2] },
|
|
278
|
+
{ id: 'MEX', parentsIndexes: [0, 1, 2] }
|
|
279
|
+
]
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
id: 'COMB0',
|
|
283
|
+
concepts: ['D1', 'A0', 'D2'],
|
|
284
|
+
dimensions: [
|
|
285
|
+
{
|
|
286
|
+
id: 'D1',
|
|
287
|
+
values: [
|
|
288
|
+
{ id: 'D1ROOT' },
|
|
289
|
+
{ id: 'D1ROOT>CHILD' },
|
|
290
|
+
{ id: 'D1ROOT>CHILD>CHILD' },
|
|
291
|
+
]
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
id: 'D2',
|
|
295
|
+
values: [
|
|
296
|
+
{ id: 'D2ROOT' },
|
|
297
|
+
{ id: 'D2ROOT>CHILD' },
|
|
298
|
+
{ id: 'D2ROOT>CHILD>CHILD' },
|
|
299
|
+
]
|
|
300
|
+
}
|
|
301
|
+
]
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
id: 'COMB1',
|
|
305
|
+
concepts: ['D3', 'D4'],
|
|
306
|
+
dimensions: [
|
|
307
|
+
{
|
|
308
|
+
id: 'D3',
|
|
309
|
+
values: [
|
|
310
|
+
{ id: 'D3ROOT' },
|
|
311
|
+
{ id: 'D3ROOT>CHILD' },
|
|
312
|
+
{ id: 'D3ROOT>CHILD>CHILD' },
|
|
313
|
+
]
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
id: 'D4',
|
|
317
|
+
values: [
|
|
318
|
+
{ id: 'D4ROOT' },
|
|
319
|
+
{ id: 'D4ROOT>CHILD' },
|
|
320
|
+
{ id: 'D4ROOT>CHILD>CHILD' },
|
|
321
|
+
]
|
|
322
|
+
}
|
|
323
|
+
]
|
|
324
|
+
},
|
|
325
|
+
];
|
|
326
|
+
|
|
327
|
+
const attributesSeries = {
|
|
328
|
+
'D1=D1ROOT>CHILD>CHILD:D2=D2ROOT>CHILD>CHILD': {
|
|
329
|
+
A0: { id: 'A0', value: { id: 'A0VAL' }, coordinates: { D1: 'D1ROOT>CHILD>CHILD', D2: 'D2ROOT>CHILD>CHILD' } },
|
|
330
|
+
A1: { id: 'A1', value: { id: 'A1VAL' }, coordinates: { D1: 'D1ROOT>CHILD>CHILD', D2: 'D2ROOT>CHILD>CHILD' } },
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
const topCoordinates = {};
|
|
335
|
+
|
|
336
|
+
const serie = {
|
|
337
|
+
indexes: [3, [2, 2], [2, 2]],
|
|
338
|
+
parentsIndexes: [[], [[], []], [[], []]],
|
|
339
|
+
missingIndexes: [[0, 2], [[0, 1], [0, 1]], [[0, 1], [0, 1]]],
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
expect(getSerieDataWithoutMissingLines(serie, dimensions, topCoordinates, attributesSeries, {}, {})).to.deep.equal({
|
|
343
|
+
data: [
|
|
344
|
+
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2], missingParents: [{ id: 'W', parents: [], missingParents: [] }, { id: 'A', parents: [0], missingParents: [] }] } },
|
|
345
|
+
{
|
|
346
|
+
dimension: { id: 'COMB0' },
|
|
347
|
+
values: [
|
|
348
|
+
{ id: 'D1ROOT>CHILD>CHILD', parents: [0, 1], missingParents: [{ id: 'D1ROOT', parents: [], missingParents: [] }, { id: 'D1ROOT>CHILD', parents: [0], missingParents: [] }] },
|
|
349
|
+
{ id: 'A0VAL' },
|
|
350
|
+
{ id: 'D2ROOT>CHILD>CHILD', parents: [0, 1], missingParents: [{ id: 'D2ROOT', parents: [], missingParents: [] }, { id: 'D2ROOT>CHILD', parents: [0], missingParents: [] }] }
|
|
351
|
+
]
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
dimension: { id: 'COMB1' },
|
|
355
|
+
values: [
|
|
356
|
+
{ id: 'D3ROOT>CHILD>CHILD', parents: [0, 1], missingParents: [{ id: 'D3ROOT', parents: [], missingParents: [] }, { id: 'D3ROOT>CHILD', parents: [0], missingParents: [] }] },
|
|
357
|
+
{ id: 'D4ROOT>CHILD>CHILD', parents: [0, 1], missingParents: [{ id: 'D4ROOT', parents: [], missingParents: [] }, { id: 'D4ROOT>CHILD', parents: [0], missingParents: [] }] }
|
|
358
|
+
]
|
|
359
|
+
}
|
|
360
|
+
],
|
|
361
|
+
coordinates: { D0: 'USA', D1: 'D1ROOT>CHILD>CHILD', D2: 'D2ROOT>CHILD>CHILD', D3: 'D3ROOT>CHILD>CHILD', D4: 'D4ROOT>CHILD>CHILD' },
|
|
362
|
+
key: 'D0=USA:D1=D1ROOT>CHILD>CHILD:D2=D2ROOT>CHILD>CHILD:D3=D3ROOT>CHILD>CHILD:D4=D4ROOT>CHILD>CHILD',
|
|
363
|
+
flags: [],
|
|
364
|
+
sideProps: {
|
|
365
|
+
coordinates: {
|
|
366
|
+
D0: 'USA',
|
|
367
|
+
D1: 'D1ROOT>CHILD>CHILD',
|
|
368
|
+
D2: 'D2ROOT>CHILD>CHILD',
|
|
369
|
+
D3: 'D3ROOT>CHILD>CHILD',
|
|
370
|
+
D4: 'D4ROOT>CHILD>CHILD',
|
|
371
|
+
},
|
|
372
|
+
hasAdvancedAttributes: true,
|
|
373
|
+
hasMetadata: false
|
|
374
|
+
}
|
|
375
|
+
});
|
|
267
376
|
});
|
|
268
377
|
});
|
|
@@ -182,7 +182,7 @@ describe('refineLayoutSize 2 tests', () => {
|
|
|
182
182
|
const expected = {
|
|
183
183
|
totalCells: 140,
|
|
184
184
|
truncated: true,
|
|
185
|
-
header: [{ indexes: [] }],
|
|
185
|
+
header: [{ indexes: [], missingIndexes: [], parentsIndexes: [] }],
|
|
186
186
|
sections: [
|
|
187
187
|
[
|
|
188
188
|
{ indexes: [] },
|
|
@@ -220,6 +220,122 @@ describe('refineLayoutSize 2 tests', () => {
|
|
|
220
220
|
})(layoutIndexes)
|
|
221
221
|
).to.deep.equal(expected);
|
|
222
222
|
});
|
|
223
|
+
it('truncated missing indexes', () => {
|
|
224
|
+
const layout = {
|
|
225
|
+
header: [{ __index: 0 }, { __index: 1 }],
|
|
226
|
+
rows: [{ __index: 2 }],
|
|
227
|
+
sections: [],
|
|
228
|
+
};
|
|
229
|
+
//102 cells
|
|
230
|
+
const layoutIndexes = {
|
|
231
|
+
header: [
|
|
232
|
+
{ indexes: [1, 1], parentsIndexes: [[], []], missingIndexes: [[0], [0]] },
|
|
233
|
+
{ indexes: [1, 2], parentsIndexes: [[0], [0]], missingIndexes: [[], []] },
|
|
234
|
+
{ indexes: [1, 3], parentsIndexes: [[0], [0]], missingIndexes: [[], []] },
|
|
235
|
+
{ indexes: [2, 1], parentsIndexes: [[0], [0]], missingIndexes: [[], []] },
|
|
236
|
+
{ indexes: [2, 2], parentsIndexes: [[0], [0]], missingIndexes: [[], []] },
|
|
237
|
+
{ indexes: [2, 3], parentsIndexes: [[0], [0]], missingIndexes: [[], []] },
|
|
238
|
+
],
|
|
239
|
+
sections: [
|
|
240
|
+
[
|
|
241
|
+
{ indexes: [] },
|
|
242
|
+
[
|
|
243
|
+
{ indexes: [0], parentsIndexes: [[]], missingIndexes: [[]] },
|
|
244
|
+
{ indexes: [1], parentsIndexes: [[]], missingIndexes: [[]] },
|
|
245
|
+
{ indexes: [2], parentsIndexes: [[]], missingIndexes: [[]] },
|
|
246
|
+
{ indexes: [3], parentsIndexes: [[]], missingIndexes: [[]] },
|
|
247
|
+
{ indexes: [4], parentsIndexes: [[]], missingIndexes: [[]] },
|
|
248
|
+
{ indexes: [5], parentsIndexes: [[]], missingIndexes: [[]] },
|
|
249
|
+
{ indexes: [6], parentsIndexes: [[]], missingIndexes: [[]] },
|
|
250
|
+
{ indexes: [7], parentsIndexes: [[]], missingIndexes: [[]] },
|
|
251
|
+
{ indexes: [8], parentsIndexes: [[]], missingIndexes: [[]] },
|
|
252
|
+
{ indexes: [9], parentsIndexes: [[]], missingIndexes: [[]] },
|
|
253
|
+
]
|
|
254
|
+
]
|
|
255
|
+
]
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
const observations = {
|
|
259
|
+
'1:1:8': { orderedDimIndexes: [1, 1, 8] },
|
|
260
|
+
'1:1:9': { orderedDimIndexes: [1, 1, 9] },
|
|
261
|
+
'1:2:8': { orderedDimIndexes: [1, 2, 8] },
|
|
262
|
+
'1:2:9': { orderedDimIndexes: [1, 2, 9] },
|
|
263
|
+
'1:3:0': { orderedDimIndexes: [1, 3, 0] },
|
|
264
|
+
'1:3:1': { orderedDimIndexes: [1, 3, 1] },
|
|
265
|
+
'1:3:2': { orderedDimIndexes: [1, 3, 2] },
|
|
266
|
+
'1:3:3': { orderedDimIndexes: [1, 3, 3] },
|
|
267
|
+
'1:3:4': { orderedDimIndexes: [1, 3, 4] },
|
|
268
|
+
'1:3:5': { orderedDimIndexes: [1, 3, 5] },
|
|
269
|
+
'1:3:6': { orderedDimIndexes: [1, 3, 6] },
|
|
270
|
+
'1:3:7': { orderedDimIndexes: [1, 3, 7] },
|
|
271
|
+
'1:3:8': { orderedDimIndexes: [1, 3, 8] },
|
|
272
|
+
'1:3:9': { orderedDimIndexes: [1, 3, 9] },
|
|
273
|
+
'2:1:0': { orderedDimIndexes: [2, 1, 0] },
|
|
274
|
+
'2:1:1': { orderedDimIndexes: [2, 1, 1] },
|
|
275
|
+
'2:1:2': { orderedDimIndexes: [2, 1, 2] },
|
|
276
|
+
'2:1:3': { orderedDimIndexes: [2, 1, 3] },
|
|
277
|
+
'2:1:4': { orderedDimIndexes: [2, 1, 4] },
|
|
278
|
+
'2:1:5': { orderedDimIndexes: [2, 1, 5] },
|
|
279
|
+
'2:1:6': { orderedDimIndexes: [2, 1, 6] },
|
|
280
|
+
'2:1:7': { orderedDimIndexes: [2, 1, 7] },
|
|
281
|
+
'2:1:8': { orderedDimIndexes: [2, 1, 8] },
|
|
282
|
+
'2:1:9': { orderedDimIndexes: [2, 1, 9] },
|
|
283
|
+
'2:2:0': { orderedDimIndexes: [2, 2, 0] },
|
|
284
|
+
'2:2:1': { orderedDimIndexes: [2, 2, 1] },
|
|
285
|
+
'2:2:2': { orderedDimIndexes: [2, 2, 2] },
|
|
286
|
+
'2:2:3': { orderedDimIndexes: [2, 2, 3] },
|
|
287
|
+
'2:2:4': { orderedDimIndexes: [2, 2, 4] },
|
|
288
|
+
'2:2:5': { orderedDimIndexes: [2, 2, 5] },
|
|
289
|
+
'2:2:6': { orderedDimIndexes: [2, 2, 6] },
|
|
290
|
+
'2:2:7': { orderedDimIndexes: [2, 2, 7] },
|
|
291
|
+
'2:2:8': { orderedDimIndexes: [2, 2, 8] },
|
|
292
|
+
'2:2:9': { orderedDimIndexes: [2, 2, 9] },
|
|
293
|
+
'2:3:0': { orderedDimIndexes: [2, 3, 0] },
|
|
294
|
+
'2:3:1': { orderedDimIndexes: [2, 3, 1] },
|
|
295
|
+
'2:3:2': { orderedDimIndexes: [2, 3, 2] },
|
|
296
|
+
'2:3:3': { orderedDimIndexes: [2, 3, 3] },
|
|
297
|
+
'2:3:4': { orderedDimIndexes: [2, 3, 4] },
|
|
298
|
+
'2:3:5': { orderedDimIndexes: [2, 3, 5] },
|
|
299
|
+
'2:3:6': { orderedDimIndexes: [2, 3, 6] },
|
|
300
|
+
'2:3:7': { orderedDimIndexes: [2, 3, 7] },
|
|
301
|
+
'2:3:8': { orderedDimIndexes: [2, 3, 8] },
|
|
302
|
+
'2:3:9': { orderedDimIndexes: [2, 3, 9] },
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
const expected = {
|
|
306
|
+
header: [
|
|
307
|
+
{ indexes: [1, 3], parentsIndexes: [[], []], missingIndexes: [[0], [0]] },
|
|
308
|
+
{ indexes: [2, 1], parentsIndexes: [[0], [0]], missingIndexes: [[], []] },
|
|
309
|
+
{ indexes: [2, 2], parentsIndexes: [[0], [0]], missingIndexes: [[], []] },
|
|
310
|
+
{ indexes: [2, 3], parentsIndexes: [[0], [0]], missingIndexes: [[], []] },
|
|
311
|
+
],
|
|
312
|
+
sections: [
|
|
313
|
+
[
|
|
314
|
+
{ indexes: [] },
|
|
315
|
+
[
|
|
316
|
+
{ indexes: [0], parentsIndexes: [[]], missingIndexes: [[]] },
|
|
317
|
+
{ indexes: [1], parentsIndexes: [[]], missingIndexes: [[]] },
|
|
318
|
+
{ indexes: [2], parentsIndexes: [[]], missingIndexes: [[]] },
|
|
319
|
+
{ indexes: [3], parentsIndexes: [[]], missingIndexes: [[]] },
|
|
320
|
+
{ indexes: [4], parentsIndexes: [[]], missingIndexes: [[]] },
|
|
321
|
+
{ indexes: [5], parentsIndexes: [[]], missingIndexes: [[]] },
|
|
322
|
+
{ indexes: [6], parentsIndexes: [[]], missingIndexes: [[]] },
|
|
323
|
+
{ indexes: [7], parentsIndexes: [[]], missingIndexes: [[]] },
|
|
324
|
+
]
|
|
325
|
+
]
|
|
326
|
+
],
|
|
327
|
+
truncated: true,
|
|
328
|
+
totalCells: 102
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
expect(
|
|
332
|
+
refineLayoutSize({
|
|
333
|
+
layout,
|
|
334
|
+
observations,
|
|
335
|
+
limit: 90
|
|
336
|
+
})(layoutIndexes)
|
|
337
|
+
).to.deep.equal(expected);
|
|
338
|
+
});
|
|
223
339
|
/*it('no rows', () => {
|
|
224
340
|
|
|
225
341
|
const layout = {
|