@sis-cc/dotstatsuite-components 20.4.0 → 20.5.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.
|
@@ -39,49 +39,61 @@ var registerParsedIndexes = function registerParsedIndexes(_ref, register) {
|
|
|
39
39
|
return (0, _extends3.default)({}, merged, { isSameSerie: isSameSerie });
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
var
|
|
43
|
-
var
|
|
42
|
+
var parseParentsIndexesWithPrevious = function parseParentsIndexesWithPrevious(parentsIndexes, previousParentsIndexes) {
|
|
43
|
+
var previousParentsSet = new _set2.default(previousParentsIndexes);
|
|
44
|
+
var lastParentIndexInPrevious = R.findLastIndex(function (i) {
|
|
45
|
+
return previousParentsSet.has(i);
|
|
46
|
+
}, parentsIndexes);
|
|
47
|
+
|
|
48
|
+
var _ref2 = lastParentIndexInPrevious !== -1 ? R.splitAt(lastParentIndexInPrevious + 1, parentsIndexes) : [[], parentsIndexes],
|
|
49
|
+
_ref3 = (0, _slicedToArray3.default)(_ref2, 2),
|
|
50
|
+
rawPresentParentsIndexes = _ref3[0],
|
|
51
|
+
missingParentsIndexes = _ref3[1];
|
|
52
|
+
|
|
53
|
+
var presentParentsIndexes = R.filter(function (i) {
|
|
54
|
+
return previousParentsSet.has(i);
|
|
55
|
+
}, rawPresentParentsIndexes);
|
|
56
|
+
return { presentParentsIndexes: presentParentsIndexes, missingParentsIndexes: missingParentsIndexes };
|
|
57
|
+
};
|
|
44
58
|
|
|
59
|
+
var parseSerieIndexesHierarchies = function parseSerieIndexesHierarchies(serieIndexes, previousSerie, dimensions, isSameSerie, replicate) {
|
|
45
60
|
return R.addIndex(R.reduce)(function (acc, _valueIndex, dimensionIndex) {
|
|
46
61
|
if (R.is(Array, _valueIndex)) {
|
|
47
62
|
var previous = R.isEmpty(previousSerie) ? {} : R.map(R.nth(dimensionIndex), previousSerie);
|
|
48
|
-
var parsed = parseSerieIndexesHierarchies(_valueIndex, previous, R.pathOr([], [dimensionIndex, 'dimensions'], dimensions), acc.isSameSerie);
|
|
63
|
+
var parsed = parseSerieIndexesHierarchies(_valueIndex, previous, R.pathOr([], [dimensionIndex, 'dimensions'], dimensions), acc.isSameSerie, replicate);
|
|
49
64
|
return registerParsedIndexes(parsed, acc);
|
|
50
65
|
}
|
|
51
66
|
var valueIndex = Math.abs(_valueIndex);
|
|
52
67
|
var parents = R.pathOr([], [dimensionIndex, 'values', valueIndex, 'parents'], dimensions);
|
|
53
|
-
var previousIndex =
|
|
68
|
+
var previousIndex = R.pipe(R.path(['indexes', dimensionIndex]), function (i) {
|
|
54
69
|
return R.isNil(i) ? -1 : Math.abs(i);
|
|
55
|
-
})(previousSerie)
|
|
56
|
-
var
|
|
57
|
-
var
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
missingParentsIndexes = _R$reduce.missingParentsIndexes;
|
|
74
|
-
|
|
75
|
-
registeredIndexes.add(valueIndex);
|
|
76
|
-
return registerParsedIndexes({ parentsIndexes: presentParentsIndexes, missingIndexes: missingParentsIndexes, registeredIndexes: registeredIndexes, isSameSerie: acc.isSameSerie && valueIndex === previousIndex }, acc);
|
|
77
|
-
}, { parentsIndexes: [], missingIndexes: [], registeredIndexes: [], isSameSerie: defaultIsSameSerie }, serieIndexes);
|
|
70
|
+
})(previousSerie);
|
|
71
|
+
var previousParentsIndexes = acc.isSameSerie ? R.pipe(R.pathOr([], ['parentsIndexes', dimensionIndex]), R.append(previousIndex))(previousSerie) : [];
|
|
72
|
+
var previousMissingIndexes = acc.isSameSerie ? R.pathOr([], ['missingIndexes', dimensionIndex], previousSerie) : [];
|
|
73
|
+
/*
|
|
74
|
+
if replicate = true (sections), missing parents insdexes are replicated on each brother nodes not just the first (as empty lines)
|
|
75
|
+
thats why passing previous missing as previous parents in case replicate = false
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
var _parseParentsIndexesW = parseParentsIndexesWithPrevious(parents, replicate ? previousParentsIndexes : R.concat(previousParentsIndexes, previousMissingIndexes)),
|
|
79
|
+
presentParentsIndexes = _parseParentsIndexesW.presentParentsIndexes,
|
|
80
|
+
missingParentsIndexes = _parseParentsIndexesW.missingParentsIndexes;
|
|
81
|
+
|
|
82
|
+
return registerParsedIndexes({
|
|
83
|
+
parentsIndexes: presentParentsIndexes,
|
|
84
|
+
missingIndexes: missingParentsIndexes,
|
|
85
|
+
isSameSerie: acc.isSameSerie && valueIndex === previousIndex
|
|
86
|
+
}, acc);
|
|
87
|
+
}, { parentsIndexes: [], missingIndexes: [], isSameSerie: isSameSerie }, serieIndexes);
|
|
78
88
|
};
|
|
79
89
|
|
|
80
90
|
var parseSeriesIndexesHierarchies = function parseSeriesIndexesHierarchies(seriesIndexes, dimensions) {
|
|
91
|
+
var replicateMissing = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
92
|
+
|
|
81
93
|
return R.reduce(function (acc, serieIndexes) {
|
|
82
94
|
var previousSerie = R.last(acc) || {};
|
|
83
95
|
|
|
84
|
-
var _parseSerieIndexesHie = parseSerieIndexesHierarchies(serieIndexes, previousSerie, dimensions),
|
|
96
|
+
var _parseSerieIndexesHie = parseSerieIndexesHierarchies(serieIndexes, previousSerie, dimensions, true, replicateMissing),
|
|
85
97
|
isSameSerie = _parseSerieIndexesHie.isSameSerie,
|
|
86
98
|
parsed = (0, _objectWithoutProperties3.default)(_parseSerieIndexesHie, ['isSameSerie']);
|
|
87
99
|
|
|
@@ -92,15 +104,16 @@ var parseSeriesIndexesHierarchies = function parseSeriesIndexesHierarchies(serie
|
|
|
92
104
|
exports.parseSeriesIndexesHierarchies = parseSeriesIndexesHierarchies;
|
|
93
105
|
var parseLayoutIndexesHierarchies = exports.parseLayoutIndexesHierarchies = function parseLayoutIndexesHierarchies(layoutIndexes, layout) {
|
|
94
106
|
var header = parseSeriesIndexesHierarchies(layoutIndexes.header, layout.header);
|
|
95
|
-
var sections = R.pipe(R.transpose, function (
|
|
96
|
-
var
|
|
97
|
-
_sections =
|
|
98
|
-
_sectionsRows =
|
|
107
|
+
var sections = R.pipe(R.transpose, function (_ref4) {
|
|
108
|
+
var _ref5 = (0, _slicedToArray3.default)(_ref4, 2),
|
|
109
|
+
_sections = _ref5[0],
|
|
110
|
+
_sectionsRows = _ref5[1];
|
|
99
111
|
|
|
100
112
|
if (R.isNil(_sections)) {
|
|
101
113
|
return [];
|
|
102
114
|
}
|
|
103
|
-
|
|
115
|
+
// replicate = true on sections
|
|
116
|
+
var sections = parseSeriesIndexesHierarchies(_sections, layout.sections, true);
|
|
104
117
|
var sectionsRows = R.map(function (rows) {
|
|
105
118
|
return parseSeriesIndexesHierarchies(rows, layout.rows);
|
|
106
119
|
}, _sectionsRows);
|
package/package.json
CHANGED
|
@@ -5,39 +5,56 @@ const registerParsedIndexes = ({ isSameSerie, ...parsed }, register) => {
|
|
|
5
5
|
return ({ ...merged, isSameSerie });
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const parseParentsIndexesWithPrevious = (parentsIndexes, previousParentsIndexes) => {
|
|
9
|
+
const previousParentsSet = new Set(previousParentsIndexes);
|
|
10
|
+
const lastParentIndexInPrevious = R.findLastIndex(i => previousParentsSet.has(i), parentsIndexes);
|
|
11
|
+
const [rawPresentParentsIndexes, missingParentsIndexes] = lastParentIndexInPrevious !== -1
|
|
12
|
+
? R.splitAt(lastParentIndexInPrevious + 1, parentsIndexes)
|
|
13
|
+
: [[], parentsIndexes];
|
|
14
|
+
const presentParentsIndexes = R.filter(i => previousParentsSet.has(i), rawPresentParentsIndexes);
|
|
15
|
+
return ({ presentParentsIndexes, missingParentsIndexes });
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const parseSerieIndexesHierarchies = (serieIndexes, previousSerie, dimensions, isSameSerie, replicate) => {
|
|
9
19
|
return R.addIndex(R.reduce)((acc, _valueIndex, dimensionIndex) => {
|
|
10
20
|
if (R.is(Array, _valueIndex)) {
|
|
11
21
|
const previous = R.isEmpty(previousSerie) ? {} : R.map(R.nth(dimensionIndex), previousSerie);
|
|
12
|
-
const parsed = parseSerieIndexesHierarchies(
|
|
22
|
+
const parsed = parseSerieIndexesHierarchies(
|
|
23
|
+
_valueIndex,
|
|
24
|
+
previous,
|
|
25
|
+
R.pathOr([], [dimensionIndex, 'dimensions'], dimensions),
|
|
26
|
+
acc.isSameSerie,
|
|
27
|
+
replicate
|
|
28
|
+
);
|
|
13
29
|
return registerParsedIndexes(parsed, acc);
|
|
14
30
|
}
|
|
15
31
|
const valueIndex = Math.abs(_valueIndex);
|
|
16
32
|
const parents = R.pathOr([], [dimensionIndex, 'values', valueIndex, 'parents'], dimensions);
|
|
17
|
-
const previousIndex =
|
|
18
|
-
|
|
19
|
-
:
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const previousIndex = R.pipe(R.path(['indexes', dimensionIndex]), i => R.isNil(i) ? -1 : Math.abs(i))(previousSerie)
|
|
34
|
+
const previousParentsIndexes = acc.isSameSerie
|
|
35
|
+
? R.pipe(R.pathOr([], ['parentsIndexes', dimensionIndex]), R.append(previousIndex))(previousSerie) : [];
|
|
36
|
+
const previousMissingIndexes = acc.isSameSerie
|
|
37
|
+
? R.pathOr([], ['missingIndexes', dimensionIndex], previousSerie) : [];
|
|
38
|
+
/*
|
|
39
|
+
if replicate = true (sections), missing parents insdexes are replicated on each brother nodes not just the first (as empty lines)
|
|
40
|
+
thats why passing previous missing as previous parents in case replicate = false
|
|
41
|
+
*/
|
|
42
|
+
const { presentParentsIndexes, missingParentsIndexes } = parseParentsIndexesWithPrevious(
|
|
43
|
+
parents,
|
|
44
|
+
replicate ? previousParentsIndexes : R.concat(previousParentsIndexes, previousMissingIndexes),
|
|
45
|
+
);
|
|
46
|
+
return registerParsedIndexes({
|
|
47
|
+
parentsIndexes: presentParentsIndexes,
|
|
48
|
+
missingIndexes: missingParentsIndexes,
|
|
49
|
+
isSameSerie: acc.isSameSerie && valueIndex === previousIndex
|
|
50
|
+
}, acc);
|
|
51
|
+
}, { parentsIndexes: [], missingIndexes: [], isSameSerie }, serieIndexes);
|
|
35
52
|
};
|
|
36
53
|
|
|
37
|
-
export const parseSeriesIndexesHierarchies = (seriesIndexes, dimensions) => {
|
|
54
|
+
export const parseSeriesIndexesHierarchies = (seriesIndexes, dimensions, replicateMissing = false) => {
|
|
38
55
|
return R.reduce((acc, serieIndexes) => {
|
|
39
56
|
const previousSerie = R.last(acc) || {};
|
|
40
|
-
const { isSameSerie, ...parsed } = parseSerieIndexesHierarchies(serieIndexes, previousSerie, dimensions);
|
|
57
|
+
const { isSameSerie, ...parsed } = parseSerieIndexesHierarchies(serieIndexes, previousSerie, dimensions, true, replicateMissing);
|
|
41
58
|
return R.append(R.assoc('indexes', serieIndexes, parsed), acc);
|
|
42
59
|
}, [], seriesIndexes);
|
|
43
60
|
};
|
|
@@ -50,7 +67,8 @@ export const parseLayoutIndexesHierarchies = (layoutIndexes, layout) => {
|
|
|
50
67
|
if (R.isNil(_sections)) {
|
|
51
68
|
return [];
|
|
52
69
|
}
|
|
53
|
-
|
|
70
|
+
// replicate = true on sections
|
|
71
|
+
const sections = parseSeriesIndexesHierarchies(_sections, layout.sections, true);
|
|
54
72
|
const sectionsRows = R.map(rows => parseSeriesIndexesHierarchies(rows, layout.rows), _sectionsRows);
|
|
55
73
|
return R.transpose([sections, sectionsRows]);
|
|
56
74
|
}
|
|
@@ -23,45 +23,323 @@ describe('parseSeriesIndexesHierarchies tests', () => {
|
|
|
23
23
|
];
|
|
24
24
|
|
|
25
25
|
expect(parseSeriesIndexesHierarchies(seriesIndexes, dimensions)).to.deep.equal([
|
|
26
|
-
{ indexes: [2], parentsIndexes: [[]], missingIndexes: [[]]
|
|
27
|
-
{ indexes: [3], parentsIndexes: [[]], missingIndexes: [[]]
|
|
28
|
-
{ indexes: [4], parentsIndexes: [[]], missingIndexes: [[]]
|
|
26
|
+
{ indexes: [2], parentsIndexes: [[]], missingIndexes: [[]] },
|
|
27
|
+
{ indexes: [3], parentsIndexes: [[]], missingIndexes: [[]] },
|
|
28
|
+
{ indexes: [4], parentsIndexes: [[]], missingIndexes: [[]] },
|
|
29
29
|
])
|
|
30
30
|
});
|
|
31
|
-
it('
|
|
31
|
+
it('hierarchical in second dimension, no replicate missing parents', () => {
|
|
32
32
|
const dimensions = [
|
|
33
|
+
{
|
|
34
|
+
id: 'D0',
|
|
35
|
+
values: [
|
|
36
|
+
{ id: 'v0' },
|
|
37
|
+
{ id: 'v1' },
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'D1',
|
|
42
|
+
values: [
|
|
43
|
+
{ id: 'v0' },
|
|
44
|
+
{ id: 'v1', parents: [0] },
|
|
45
|
+
{ id: 'v2', parents: [0, 1] },
|
|
46
|
+
{ id: 'v3', parents: [0, 1] },
|
|
47
|
+
{ id: 'v4', parents: [0, 1] },
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
const seriesIndexes = [
|
|
53
|
+
[0, 0],
|
|
54
|
+
[0, 1],
|
|
55
|
+
[0, 2],
|
|
56
|
+
[0, 3],
|
|
57
|
+
[0, 4],
|
|
58
|
+
[1, 2],
|
|
59
|
+
[1, 3],
|
|
60
|
+
[1, 4],
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
expect(parseSeriesIndexesHierarchies(seriesIndexes, dimensions)).to.deep.equal([
|
|
64
|
+
{ indexes: [0, 0], parentsIndexes: [[], []], missingIndexes: [[], []] },
|
|
65
|
+
{ indexes: [0, 1], parentsIndexes: [[], [0]], missingIndexes: [[], []] },
|
|
66
|
+
{ indexes: [0, 2], parentsIndexes: [[], [0, 1]], missingIndexes: [[], []] },
|
|
67
|
+
{ indexes: [0, 3], parentsIndexes: [[], [0, 1]], missingIndexes: [[], []] },
|
|
68
|
+
{ indexes: [0, 4], parentsIndexes: [[], [0, 1]], missingIndexes: [[], []] },
|
|
69
|
+
{ indexes: [1, 2], parentsIndexes: [[], []], missingIndexes: [[], [0, 1]] },
|
|
70
|
+
{ indexes: [1, 3], parentsIndexes: [[], [0, 1]], missingIndexes: [[], []] },
|
|
71
|
+
{ indexes: [1, 4], parentsIndexes: [[], [0, 1]], missingIndexes: [[], []] },
|
|
72
|
+
])
|
|
73
|
+
});
|
|
74
|
+
it('hierarchical in second dimension, replicate missing parents', () => {
|
|
75
|
+
const dimensions = [
|
|
76
|
+
{
|
|
77
|
+
id: 'D0',
|
|
78
|
+
values: [
|
|
79
|
+
{ id: 'v0' },
|
|
80
|
+
{ id: 'v1' },
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
id: 'D1',
|
|
85
|
+
values: [
|
|
86
|
+
{ id: 'v0' },
|
|
87
|
+
{ id: 'v1', parents: [0] },
|
|
88
|
+
{ id: 'v2', parents: [0, 1] },
|
|
89
|
+
{ id: 'v3', parents: [0, 1] },
|
|
90
|
+
{ id: 'v4', parents: [0, 1] },
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
const seriesIndexes = [
|
|
96
|
+
[0, 0],
|
|
97
|
+
[0, 1],
|
|
98
|
+
[0, 2],
|
|
99
|
+
[0, 3],
|
|
100
|
+
[0, 4],
|
|
101
|
+
[1, 2],
|
|
102
|
+
[1, 3],
|
|
103
|
+
[1, 4],
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
expect(parseSeriesIndexesHierarchies(seriesIndexes, dimensions, true)).to.deep.equal([
|
|
107
|
+
{ indexes: [0, 0], parentsIndexes: [[], []], missingIndexes: [[], []] },
|
|
108
|
+
{ indexes: [0, 1], parentsIndexes: [[], [0]], missingIndexes: [[], []] },
|
|
109
|
+
{ indexes: [0, 2], parentsIndexes: [[], [0, 1]], missingIndexes: [[], []] },
|
|
110
|
+
{ indexes: [0, 3], parentsIndexes: [[], [0, 1]], missingIndexes: [[], []] },
|
|
111
|
+
{ indexes: [0, 4], parentsIndexes: [[], [0, 1]], missingIndexes: [[], []] },
|
|
112
|
+
{ indexes: [1, 2], parentsIndexes: [[], []], missingIndexes: [[], [0, 1]] },
|
|
113
|
+
{ indexes: [1, 3], parentsIndexes: [[], []], missingIndexes: [[], [0, 1]] },
|
|
114
|
+
{ indexes: [1, 4], parentsIndexes: [[], []], missingIndexes: [[], [0, 1]] },
|
|
115
|
+
])
|
|
116
|
+
});
|
|
117
|
+
it('two hierarchical dimensions, no replicate missing parents', () => {
|
|
118
|
+
const dimensions = [
|
|
119
|
+
{
|
|
120
|
+
id: 'D0',
|
|
121
|
+
values: [
|
|
122
|
+
{ id: 'v0' },
|
|
123
|
+
{ id: 'v1', parents: [0] },
|
|
124
|
+
{ id: 'v2', parents: [0, 1] },
|
|
125
|
+
{ id: 'v3', parents: [0, 1] },
|
|
126
|
+
]
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
id: 'D1',
|
|
130
|
+
values: [
|
|
131
|
+
{ id: 'v0' },
|
|
132
|
+
{ id: 'v1', parents: [0] },
|
|
133
|
+
{ id: 'v2', parents: [0, 1] },
|
|
134
|
+
{ id: 'v3', parents: [0, 1] },
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
];
|
|
138
|
+
|
|
139
|
+
const seriesIndexes = [
|
|
140
|
+
[0, 0],
|
|
141
|
+
[0, 1],
|
|
142
|
+
[0, 2],
|
|
143
|
+
[0, 3],
|
|
144
|
+
[2, 2],
|
|
145
|
+
[2, 3],
|
|
146
|
+
[3, 2],
|
|
147
|
+
[3, 3],
|
|
148
|
+
];
|
|
149
|
+
|
|
150
|
+
expect(parseSeriesIndexesHierarchies(seriesIndexes, dimensions)).to.deep.equal([
|
|
151
|
+
{ indexes: [0, 0], parentsIndexes: [[], []], missingIndexes: [[], []] },
|
|
152
|
+
{ indexes: [0, 1], parentsIndexes: [[], [0]], missingIndexes: [[], []] },
|
|
153
|
+
{ indexes: [0, 2], parentsIndexes: [[], [0, 1]], missingIndexes: [[], []] },
|
|
154
|
+
{ indexes: [0, 3], parentsIndexes: [[], [0, 1]], missingIndexes: [[], []] },
|
|
155
|
+
{ indexes: [2, 2], parentsIndexes: [[0], []], missingIndexes: [[1], [0, 1]] },
|
|
156
|
+
{ indexes: [2, 3], parentsIndexes: [[0, 1], [0, 1]], missingIndexes: [[], []] },
|
|
157
|
+
{ indexes: [3, 2], parentsIndexes: [[0, 1], []], missingIndexes: [[], [0, 1]] },
|
|
158
|
+
{ indexes: [3, 3], parentsIndexes: [[0, 1], [0, 1]], missingIndexes: [[], []] },
|
|
159
|
+
])
|
|
160
|
+
});
|
|
161
|
+
it('two hierarchical dimensions, replicate missing parents', () => {
|
|
162
|
+
const dimensions = [
|
|
163
|
+
{
|
|
164
|
+
id: 'D0',
|
|
165
|
+
values: [
|
|
166
|
+
{ id: 'v0' },
|
|
167
|
+
{ id: 'v1', parents: [0] },
|
|
168
|
+
{ id: 'v2', parents: [0, 1] },
|
|
169
|
+
{ id: 'v3', parents: [0, 1] },
|
|
170
|
+
]
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
id: 'D1',
|
|
174
|
+
values: [
|
|
175
|
+
{ id: 'v0' },
|
|
176
|
+
{ id: 'v1', parents: [0] },
|
|
177
|
+
{ id: 'v2', parents: [0, 1] },
|
|
178
|
+
{ id: 'v3', parents: [0, 1] },
|
|
179
|
+
]
|
|
180
|
+
},
|
|
181
|
+
];
|
|
182
|
+
|
|
183
|
+
const seriesIndexes = [
|
|
184
|
+
[0, 0],
|
|
185
|
+
[0, 1],
|
|
186
|
+
[0, 2],
|
|
187
|
+
[0, 3],
|
|
188
|
+
[2, 2],
|
|
189
|
+
[2, 3],
|
|
190
|
+
[3, 2],
|
|
191
|
+
[3, 3],
|
|
192
|
+
];
|
|
193
|
+
|
|
194
|
+
expect(parseSeriesIndexesHierarchies(seriesIndexes, dimensions, true)).to.deep.equal([
|
|
195
|
+
{ indexes: [0, 0], parentsIndexes: [[], []], missingIndexes: [[], []] },
|
|
196
|
+
{ indexes: [0, 1], parentsIndexes: [[], [0]], missingIndexes: [[], []] },
|
|
197
|
+
{ indexes: [0, 2], parentsIndexes: [[], [0, 1]], missingIndexes: [[], []] },
|
|
198
|
+
{ indexes: [0, 3], parentsIndexes: [[], [0, 1]], missingIndexes: [[], []] },
|
|
199
|
+
{ indexes: [2, 2], parentsIndexes: [[0], []], missingIndexes: [[1], [0, 1]] },
|
|
200
|
+
{ indexes: [2, 3], parentsIndexes: [[0], []], missingIndexes: [[1], [0, 1]] },
|
|
201
|
+
{ indexes: [3, 2], parentsIndexes: [[0], []], missingIndexes: [[1], [0, 1]] },
|
|
202
|
+
{ indexes: [3, 3], parentsIndexes: [[0], []], missingIndexes: [[1], [0, 1]] },
|
|
203
|
+
])
|
|
204
|
+
});
|
|
205
|
+
it('two hierarchical dimensions in combination, no replicate missing parents', () => {
|
|
206
|
+
const dimensions = [
|
|
207
|
+
{
|
|
208
|
+
id: 'D0',
|
|
209
|
+
values: [
|
|
210
|
+
{ id: 'v0' },
|
|
211
|
+
{ id: 'v1', parents: [0] },
|
|
212
|
+
{ id: 'v2', parents: [0, 1] },
|
|
213
|
+
]
|
|
214
|
+
},
|
|
33
215
|
{
|
|
34
216
|
id: 'COMB',
|
|
35
217
|
dimensions: [{
|
|
218
|
+
id: 'D1',
|
|
36
219
|
values: [
|
|
37
220
|
{ id: 'v0' },
|
|
38
|
-
{ id: 'v1' },
|
|
39
|
-
{ id: 'v2' },
|
|
40
|
-
{ id: 'v3' },
|
|
41
|
-
{ id: 'v4' },
|
|
221
|
+
{ id: 'v1', parents: [0] },
|
|
222
|
+
{ id: 'v2', parents: [0, 1] },
|
|
223
|
+
{ id: 'v3', parents: [0, 1] },
|
|
42
224
|
]
|
|
43
|
-
},
|
|
44
|
-
|
|
225
|
+
},{
|
|
226
|
+
id: 'D2',
|
|
45
227
|
values: [
|
|
46
|
-
{ id: '
|
|
47
|
-
{ id: '
|
|
48
|
-
{ id: '
|
|
49
|
-
{ id: '
|
|
50
|
-
{ id: 'CAN', parents: [0, 1, 2], isSelected: true },
|
|
51
|
-
{ id: 'MEX', parents: [0, 1, 2], isSelected: true }
|
|
228
|
+
{ id: 'v0' },
|
|
229
|
+
{ id: 'v1', parents: [0] },
|
|
230
|
+
{ id: 'v2', parents: [0, 1] },
|
|
231
|
+
{ id: 'v3', parents: [0, 1] },
|
|
52
232
|
]
|
|
53
233
|
}]
|
|
54
|
-
}
|
|
234
|
+
}
|
|
55
235
|
];
|
|
56
236
|
|
|
57
237
|
const seriesIndexes = [
|
|
58
|
-
[[0, 0]],
|
|
59
|
-
[[0, 1]],
|
|
238
|
+
[0, [0, 0]],
|
|
239
|
+
[0, [0, 1]],
|
|
240
|
+
[0, [0, 2]],
|
|
241
|
+
[0, [0, 3]],
|
|
242
|
+
[0, [2, 2]],
|
|
243
|
+
[0, [2, 3]],
|
|
244
|
+
[0, [3, 2]],
|
|
245
|
+
[0, [3, 3]],
|
|
246
|
+
[2, [0, 0]],
|
|
247
|
+
[2, [0, 1]],
|
|
248
|
+
[2, [0, 2]],
|
|
249
|
+
[2, [0, 3]],
|
|
250
|
+
[2, [2, 2]],
|
|
251
|
+
[2, [2, 3]],
|
|
252
|
+
[2, [3, 2]],
|
|
253
|
+
[2, [3, 3]],
|
|
60
254
|
];
|
|
61
255
|
|
|
62
256
|
expect(parseSeriesIndexesHierarchies(seriesIndexes, dimensions)).to.deep.equal([
|
|
63
|
-
{ indexes: [[0, 0]], parentsIndexes: [[[], []]], missingIndexes: [[
|
|
64
|
-
{ indexes: [[0, 1]], parentsIndexes: [[[], [0]]], missingIndexes: [[
|
|
257
|
+
{ indexes: [0, [0, 0]], parentsIndexes: [[], [[], []]], missingIndexes: [[], [[], []]] },
|
|
258
|
+
{ indexes: [0, [0, 1]], parentsIndexes: [[], [[], [0]]], missingIndexes: [[], [[], []]] },
|
|
259
|
+
{ indexes: [0, [0, 2]], parentsIndexes: [[], [[], [0, 1]]], missingIndexes: [[], [[], []]] },
|
|
260
|
+
{ indexes: [0, [0, 3]], parentsIndexes: [[], [[], [0, 1]]], missingIndexes: [[], [[], []]] },
|
|
261
|
+
{ indexes: [0, [2, 2]], parentsIndexes: [[], [[0], []]], missingIndexes: [[], [[1], [0, 1]]] },
|
|
262
|
+
{ indexes: [0, [2, 3]], parentsIndexes: [[], [[0, 1], [0, 1]]], missingIndexes: [[], [[], []]] },
|
|
263
|
+
{ indexes: [0, [3, 2]], parentsIndexes: [[], [[0, 1], []]], missingIndexes: [[], [[], [0, 1]]] },
|
|
264
|
+
{ indexes: [0, [3, 3]], parentsIndexes: [[], [[0, 1], [0, 1]]], missingIndexes: [[], [[], []]] },
|
|
265
|
+
{ indexes: [2, [0, 0]], parentsIndexes: [[0], [[], []]], missingIndexes: [[1], [[], []]] },
|
|
266
|
+
{ indexes: [2, [0, 1]], parentsIndexes: [[0, 1], [[], [0]]], missingIndexes: [[], [[], []]] },
|
|
267
|
+
{ indexes: [2, [0, 2]], parentsIndexes: [[0, 1], [[], [0, 1]]], missingIndexes: [[], [[], []]] },
|
|
268
|
+
{ indexes: [2, [0, 3]], parentsIndexes: [[0, 1], [[], [0, 1]]], missingIndexes: [[], [[], []]] },
|
|
269
|
+
{ indexes: [2, [2, 2]], parentsIndexes: [[0, 1], [[0], []]], missingIndexes: [[], [[1], [0, 1]]] },
|
|
270
|
+
{ indexes: [2, [2, 3]], parentsIndexes: [[0, 1], [[0, 1], [0, 1]]], missingIndexes: [[], [[], []]] },
|
|
271
|
+
{ indexes: [2, [3, 2]], parentsIndexes: [[0, 1], [[0, 1], []]], missingIndexes: [[], [[], [0, 1]]] },
|
|
272
|
+
{ indexes: [2, [3, 3]], parentsIndexes: [[0, 1], [[0, 1], [0, 1]]], missingIndexes: [[], [[], []]] },
|
|
273
|
+
])
|
|
274
|
+
});
|
|
275
|
+
it('two hierarchical dimensions in combination, replicate missing parents', () => {
|
|
276
|
+
const dimensions = [
|
|
277
|
+
{
|
|
278
|
+
id: 'D0',
|
|
279
|
+
values: [
|
|
280
|
+
{ id: 'v0' },
|
|
281
|
+
{ id: 'v1', parents: [0] },
|
|
282
|
+
{ id: 'v2', parents: [0, 1] },
|
|
283
|
+
]
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
id: 'COMB',
|
|
287
|
+
dimensions: [{
|
|
288
|
+
id: 'D1',
|
|
289
|
+
values: [
|
|
290
|
+
{ id: 'v0' },
|
|
291
|
+
{ id: 'v1', parents: [0] },
|
|
292
|
+
{ id: 'v2', parents: [0, 1] },
|
|
293
|
+
{ id: 'v3', parents: [0, 1] },
|
|
294
|
+
]
|
|
295
|
+
},{
|
|
296
|
+
id: 'D2',
|
|
297
|
+
values: [
|
|
298
|
+
{ id: 'v0' },
|
|
299
|
+
{ id: 'v1', parents: [0] },
|
|
300
|
+
{ id: 'v2', parents: [0, 1] },
|
|
301
|
+
{ id: 'v3', parents: [0, 1] },
|
|
302
|
+
]
|
|
303
|
+
}]
|
|
304
|
+
}
|
|
305
|
+
];
|
|
306
|
+
|
|
307
|
+
const seriesIndexes = [
|
|
308
|
+
[0, [0, 0]],
|
|
309
|
+
[0, [0, 1]],
|
|
310
|
+
[0, [0, 2]],
|
|
311
|
+
[0, [0, 3]],
|
|
312
|
+
[0, [2, 2]],
|
|
313
|
+
[0, [2, 3]],
|
|
314
|
+
[0, [3, 2]],
|
|
315
|
+
[0, [3, 3]],
|
|
316
|
+
[2, [0, 0]],
|
|
317
|
+
[2, [0, 1]],
|
|
318
|
+
[2, [0, 2]],
|
|
319
|
+
[2, [0, 3]],
|
|
320
|
+
[2, [2, 2]],
|
|
321
|
+
[2, [2, 3]],
|
|
322
|
+
[2, [3, 2]],
|
|
323
|
+
[2, [3, 3]],
|
|
324
|
+
];
|
|
325
|
+
|
|
326
|
+
expect(parseSeriesIndexesHierarchies(seriesIndexes, dimensions, true)).to.deep.equal([
|
|
327
|
+
{ indexes: [0, [0, 0]], parentsIndexes: [[], [[], []]], missingIndexes: [[], [[], []]] },
|
|
328
|
+
{ indexes: [0, [0, 1]], parentsIndexes: [[], [[], [0]]], missingIndexes: [[], [[], []]] },
|
|
329
|
+
{ indexes: [0, [0, 2]], parentsIndexes: [[], [[], [0, 1]]], missingIndexes: [[], [[], []]] },
|
|
330
|
+
{ indexes: [0, [0, 3]], parentsIndexes: [[], [[], [0, 1]]], missingIndexes: [[], [[], []]] },
|
|
331
|
+
{ indexes: [0, [2, 2]], parentsIndexes: [[], [[0], []]], missingIndexes: [[], [[1], [0, 1]]] },
|
|
332
|
+
{ indexes: [0, [2, 3]], parentsIndexes: [[], [[0], []]], missingIndexes: [[], [[1], [0, 1]]] },
|
|
333
|
+
{ indexes: [0, [3, 2]], parentsIndexes: [[], [[0], []]], missingIndexes: [[], [[1], [0, 1]]] },
|
|
334
|
+
{ indexes: [0, [3, 3]], parentsIndexes: [[], [[0], []]], missingIndexes: [[], [[1], [0, 1]]] },
|
|
335
|
+
{ indexes: [2, [0, 0]], parentsIndexes: [[0], [[], []]], missingIndexes: [[1], [[], []]] },
|
|
336
|
+
{ indexes: [2, [0, 1]], parentsIndexes: [[0], [[], [0]]], missingIndexes: [[1], [[], []]] },
|
|
337
|
+
{ indexes: [2, [0, 2]], parentsIndexes: [[0], [[], [0, 1]]], missingIndexes: [[1], [[], []]] },
|
|
338
|
+
{ indexes: [2, [0, 3]], parentsIndexes: [[0], [[], [0, 1]]], missingIndexes: [[1], [[], []]] },
|
|
339
|
+
{ indexes: [2, [2, 2]], parentsIndexes: [[0], [[0], []]], missingIndexes: [[1], [[1], [0, 1]]] },
|
|
340
|
+
{ indexes: [2, [2, 3]], parentsIndexes: [[0], [[0], []]], missingIndexes: [[1], [[1], [0, 1]]] },
|
|
341
|
+
{ indexes: [2, [3, 2]], parentsIndexes: [[0], [[0], []]], missingIndexes: [[1], [[1], [0, 1]]] },
|
|
342
|
+
{ indexes: [2, [3, 3]], parentsIndexes: [[0], [[0], []]], missingIndexes: [[1], [[1], [0, 1]]] },
|
|
65
343
|
])
|
|
66
344
|
});
|
|
67
345
|
});
|