@sis-cc/dotstatsuite-components 21.0.1 → 21.1.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/dist/dotstatsuite-components.js +38112 -0
- package/package.json +4 -1
- package/.editorconfig +0 -19
- package/.gitlab-ci.yml +0 -48
- package/prettier.config.js +0 -13
- package/src/app.js +0 -13
- package/src/bridge-d3-react/README.md +0 -42
- package/src/bridge-d3-react/src/app.js +0 -64
- package/src/bridge-d3-react/src/index.js +0 -17
- package/src/bridge-d3-react/src/mock-choro.js +0 -394
- package/src/bridge-d3-react/src/react-chart-factory.js +0 -65
- package/src/index.js +0 -12
- package/src/rules/README.md +0 -23
- package/src/rules/src/chart/getAxisOptions.js +0 -258
- package/src/rules/src/chart/getBaseOptions.js +0 -84
- package/src/rules/src/chart/getChartOptions.js +0 -118
- package/src/rules/src/chart/getGridOptions.js +0 -52
- package/src/rules/src/chart/getTooltipOptions.js +0 -230
- package/src/rules/src/constants.js +0 -64
- package/src/rules/src/date.js +0 -118
- package/src/rules/src/dimension-utils.js +0 -54
- package/src/rules/src/factories/choro-series.js +0 -65
- package/src/rules/src/factories/sample-focus.js +0 -22
- package/src/rules/src/factories/sample-series.js +0 -51
- package/src/rules/src/factories/scatter-dimension.js +0 -31
- package/src/rules/src/factories/scatter-focus.js +0 -39
- package/src/rules/src/factories/scatter-series.js +0 -94
- package/src/rules/src/factories/stacked-dimension.js +0 -29
- package/src/rules/src/factories/stacked-series.js +0 -185
- package/src/rules/src/factories/symbol-dimension.js +0 -29
- package/src/rules/src/factories/symbol-series.js +0 -62
- package/src/rules/src/factories/timeline-focus.js +0 -18
- package/src/rules/src/factories/timeline-series.js +0 -91
- package/src/rules/src/get-values-enhanced.js +0 -134
- package/src/rules/src/header/getDefaultSubtitle.js +0 -40
- package/src/rules/src/header/getHeaderUnits.js +0 -17
- package/src/rules/src/header/getSubtitleFlags.js +0 -43
- package/src/rules/src/header/getTitleFlags.js +0 -8
- package/src/rules/src/header/index.js +0 -4
- package/src/rules/src/index.js +0 -398
- package/src/rules/src/layout.js +0 -113
- package/src/rules/src/observation-formater.js +0 -83
- package/src/rules/src/preparators/enhanceObservations.js +0 -152
- package/src/rules/src/preparators/formatValue.js +0 -84
- package/src/rules/src/preparators/getObservations.js +0 -19
- package/src/rules/src/preparators/getReportingYearStart.js +0 -16
- package/src/rules/src/properties/errors.js +0 -19
- package/src/rules/src/properties/focus.js +0 -69
- package/src/rules/src/properties/getAvailableChartTypes.js +0 -34
- package/src/rules/src/properties/getHeaderProps.js +0 -74
- package/src/rules/src/properties/getInformationsStateFromNewProps.js +0 -47
- package/src/rules/src/properties/getObservationsType.js +0 -29
- package/src/rules/src/properties/getStringifiedSubtitle.js +0 -6
- package/src/rules/src/properties/index.js +0 -424
- package/src/rules/src/properties/information.js +0 -84
- package/src/rules/src/properties/linear.js +0 -129
- package/src/rules/src/properties/scatter.js +0 -158
- package/src/rules/src/properties/stacked.js +0 -98
- package/src/rules/src/properties/symbol.js +0 -79
- package/src/rules/src/properties/utils.js +0 -110
- package/src/rules/src/sdmx-data/index.js +0 -39
- package/src/rules/src/table/factories/getCellValue.js +0 -50
- package/src/rules/src/table/index.js +0 -1
- package/src/rules/src/v8-transformer.js +0 -176
- package/src/rules/test/extractSdmxArtefacts.js +0 -26
- package/src/rules/test/get-values-enhanced.test.js +0 -127
- package/src/rules/test/oecd-HEALTH_PROT-no-freq.json +0 -2903
- package/src/rules/test/oecd-HEALTH_PROT-parsed.js +0 -398
- package/src/rules/test/oecd-HEALTH_PROT-wrong-freq.json +0 -2913
- package/src/rules/test/oecd-HEALTH_PROT.json +0 -2913
- package/src/rules/test/oecd-KEI.json +0 -372
- package/src/rules/test/scatter-property.js +0 -455
- package/src/rules/test/stacked-property.js +0 -273
- package/src/rules/test/symbol-property.js +0 -262
- package/src/rules/test/v8-transformer.test.js +0 -90
- package/src/rules2/src/applyHierarchicalCodesToDim.js +0 -149
- package/src/rules2/src/combinedValuesDisplay.js +0 -74
- package/src/rules2/src/constants.js +0 -6
- package/src/rules2/src/duplicateObservations.js +0 -35
- package/src/rules2/src/enhanceObservations.js +0 -95
- package/src/rules2/src/getAdvAttrSeriesAtCoordinates.js +0 -29
- package/src/rules2/src/getAttributesSeries.js +0 -36
- package/src/rules2/src/getCombinationDefinitions.js +0 -47
- package/src/rules2/src/getDataflowAttributes.js +0 -23
- package/src/rules2/src/getDataflowTooltipAttributesIds.js +0 -31
- package/src/rules2/src/getDimensionValuesIndexes.js +0 -13
- package/src/rules2/src/getHCodelistsRefsInData.js +0 -32
- package/src/rules2/src/getHeaderCombinations.js +0 -48
- package/src/rules2/src/getHeaderCoordinates.js +0 -7
- package/src/rules2/src/getHeaderSubtitle.js +0 -34
- package/src/rules2/src/getHeaderTitle.js +0 -15
- package/src/rules2/src/getMSDInformations.js +0 -23
- package/src/rules2/src/getManyValuesDimensions.js +0 -34
- package/src/rules2/src/getMetadataCoordinates.js +0 -37
- package/src/rules2/src/getMetadataStructureFromData.js +0 -17
- package/src/rules2/src/getNotDisplayedIds.js +0 -53
- package/src/rules2/src/getOneValueDimensions.js +0 -34
- package/src/rules2/src/getSeriesCombinations.js +0 -24
- package/src/rules2/src/hasCellMetadata.js +0 -14
- package/src/rules2/src/hierarchiseDimensionWithAdvancedHierarchy2.js +0 -57
- package/src/rules2/src/hierarchiseDimensionWithNativeHierarchy2.js +0 -35
- package/src/rules2/src/index.js +0 -50
- package/src/rules2/src/parseAttributes.js +0 -41
- package/src/rules2/src/parseCombinations.js +0 -102
- package/src/rules2/src/parseHierarchicalCodelist.js +0 -48
- package/src/rules2/src/parseMetadataSeries.js +0 -117
- package/src/rules2/src/prepareData.js +0 -73
- package/src/rules2/src/refineAttributes.js +0 -16
- package/src/rules2/src/refineDimensions.js +0 -18
- package/src/rules2/src/refineMetadataCoordinates.js +0 -28
- package/src/rules2/src/refineTimePeriod.js +0 -127
- package/src/rules2/src/sdmx3.0DataFormatPatch.js +0 -9
- package/src/rules2/src/table/declineObservationsOverAttributes.js +0 -32
- package/src/rules2/src/table/getCells.js +0 -93
- package/src/rules2/src/table/getCellsAttributesIds.js +0 -38
- package/src/rules2/src/table/getCellsMetadataCoordinates.js +0 -13
- package/src/rules2/src/table/getCombinationDimensionsData.js +0 -39
- package/src/rules2/src/table/getCuratedCells.js +0 -33
- package/src/rules2/src/table/getFlagsAndNotes.js +0 -23
- package/src/rules2/src/table/getIndexedCombinationsByDisplay.js +0 -16
- package/src/rules2/src/table/getLayout.js +0 -84
- package/src/rules2/src/table/getLayoutData2.js +0 -198
- package/src/rules2/src/table/getSortedLayoutIndexes.js +0 -124
- package/src/rules2/src/table/getTableLabelAccessor.js +0 -9
- package/src/rules2/src/table/getTableLayoutIds.js +0 -314
- package/src/rules2/src/table/getTableProps.js +0 -75
- package/src/rules2/src/table/parseSeriesIndexesHierarchies.js +0 -79
- package/src/rules2/src/table/parseValueHierarchy.js +0 -33
- package/src/rules2/src/table/refineLayoutSize2.js +0 -321
- package/src/rules2/src/utils.js +0 -37
- package/src/viewer/mocks/bar.js +0 -33
- package/src/viewer/mocks/gpp-symbol.js +0 -93
- package/src/viewer/mocks/gpp-time.js +0 -1103
- package/src/viewer/mocks/row.js +0 -39
- package/src/viewer/mocks/scatter.js +0 -93
- package/src/viewer/mocks/stack.js +0 -161
- package/src/viewer/src/app/leg.js +0 -36
- package/src/viewer/src/app/nodata-res.js +0 -22
- package/src/viewer/src/app/nodata-sized.js +0 -23
- package/src/viewer/src/app/one-table-cell.js +0 -70
- package/src/viewer/src/app/table.js +0 -423
- package/src/viewer/src/app/use-case-1.js +0 -33
- package/src/viewer/src/app/use-case-2.js +0 -38
- package/src/viewer/src/app/use-case-3.js +0 -18
- package/src/viewer/src/app.js +0 -116
- package/src/viewer/src/chart.js +0 -52
- package/src/viewer/src/chartUtils/options.js +0 -30
- package/src/viewer/src/chartUtils/series.js +0 -51
- package/src/viewer/src/footer.js +0 -24
- package/src/viewer/src/header.js +0 -10
- package/src/viewer/src/index.js +0 -158
- package/src/viewer/src/legends/AxisLegend.js +0 -41
- package/src/viewer/src/legends/ChartLegends.js +0 -66
- package/src/viewer/src/legends/FocusLegend.js +0 -63
- package/src/viewer/src/legends/Legend.js +0 -46
- package/src/viewer/src/legends/SeriesLegend.js +0 -78
- package/src/viewer/src/utils.js +0 -21
- package/test/applyHierarchicalCodesToDim.test.js +0 -160
- package/test/combinedValuesDisplay.test.js +0 -66
- package/test/duplicateObs.test.js +0 -118
- package/test/enhanceObservations2.test.js +0 -257
- package/test/getAttributesSeries.test.js +0 -66
- package/test/getAxisOptions.test.js +0 -309
- package/test/getBaseOptions.test.js +0 -77
- package/test/getCellValue.test.js +0 -32
- package/test/getCells.test.js +0 -178
- package/test/getCellsMetadataCoordinates.test.js +0 -40
- package/test/getCombinationDefinitions.test.js +0 -104
- package/test/getCombinationDimensionsData.test.js +0 -99
- package/test/getDataflowAttributes.test.js +0 -23
- package/test/getDataflowTooltipAttributesIds.test.js +0 -146
- package/test/getDimensionValuesIndexes.test.js +0 -33
- package/test/getGridOptions.test.js +0 -65
- package/test/getHCodelistsRefs.test.js +0 -23
- package/test/getHeaderCombinations.test.js +0 -62
- package/test/getHeaderTitle.test.js +0 -25
- package/test/getLayout.test.js +0 -54
- package/test/getLayoutData2.test.js +0 -535
- package/test/getMSDInformations.test.js +0 -35
- package/test/getMetadataCoordinates.test.js +0 -0
- package/test/getNotDisplayedIds.test.js +0 -47
- package/test/getObservationsType.test.js +0 -55
- package/test/getOneValueDimensions.test.js +0 -35
- package/test/getReportingYearStart.test.js +0 -59
- package/test/getSeriesCombinations.test.js +0 -29
- package/test/getSortedLayoutIndexes.test.js +0 -1138
- package/test/getTableLabelAccessor.test.js +0 -50
- package/test/getTableLayoutIds.test.js +0 -356
- package/test/hierarchiseDimensionWithNativeHierarchy2.test.js +0 -109
- package/test/isTableLayoutCompatible.test.js +0 -102
- package/test/metadata-parsing-perf.test.js +0 -509
- package/test/mocks/MSD_TEST.json +0 -490
- package/test/mocks/OECD_SNA_TABLE1_1.0_-_AUS_V_metadata.json +0 -152
- package/test/mocks/h-codelist.json +0 -2095
- package/test/mocks/large_metadata_series.json +0 -701
- package/test/mocks/observations-advanced-attributes.json +0 -55382
- package/test/mocks/table-invert-time--data.json +0 -80211
- package/test/mocks/table-invert-time--inverted.json +0 -80076
- package/test/mocks/table-layout-multi-hierarchies--layout.json +0 -621
- package/test/mocks/table-layout-multi-hierarchies--layoutData.json +0 -32411
- package/test/mocks/table-layout-multi-hierarchies--layoutIndexes.json +0 -2760
- package/test/mocks/table-layout-multi-hierarchies--observations.json +0 -30688
- package/test/mocks/table-layout-multi-hierarchies--sizedIndexes.json +0 -2762
- package/test/mocks/table-layout-truncation1--layout.json +0 -27469
- package/test/mocks/table-layout-truncation1--layoutData.json +0 -20358
- package/test/mocks/table-layout-truncation1--layoutIndexes.json +0 -7512
- package/test/mocks/table-layout-truncation1--observations.json +0 -70002
- package/test/mocks/table-layout-truncation1--sizedIndexes.json +0 -3011
- package/test/mocks/table-prep-multi-hierarchies--attributes.json +0 -46
- package/test/mocks/table-prep-multi-hierarchies--dimensions.json +0 -688
- package/test/mocks/table-prep-multi-hierarchies--enhancedObservations.json +0 -19696
- package/test/mocks/table-prep-multi-hierarchies--observations.json +0 -8246
- package/test/mocks/table-prep-multi-hierarchies--sdmxJson.json +0 -2985
- package/test/mocks/table-prep-simple-duplicate--dimensions2.json +0 -858
- package/test/mocks/table-prep-simple-duplicate--duplicated2.json +0 -77502
- package/test/mocks/table-prep-simple-duplicate--observations2.json +0 -60002
- package/test/mocks/table-prep-truncation1--dimensions.json +0 -35057
- package/test/mocks/table-prep-truncation1--enhancedObservations.json +0 -70002
- package/test/mocks/table-prep-truncation1--observations.json +0 -27502
- package/test/mocks/table-prep-truncation1--sdmxJson.json +0 -55103
- package/test/mocks/table-prep-units--observations.json +0 -284286
- package/test/mocks/table-prep-units--unitsSeries.json +0 -41042
- package/test/parseAttributes.test.js +0 -36
- package/test/parseCombinations.test.js +0 -172
- package/test/parseHierarchicalCodelist.test.js +0 -140
- package/test/parseMetadataSeries.test.js +0 -128
- package/test/parseSeriesIndexesHierarchies.test.js +0 -345
- package/test/parseValueHierarchy.test.js +0 -138
- package/test/refineAttributes.test.js +0 -29
- package/test/refineLayoutSize2.test.js +0 -3410
- package/test/refineMetadataCoordinates.test.js +0 -86
- package/test/refineTimePeriod.test.js +0 -580
- package/test/refinedDimensions.test.js +0 -35
- package/vite.config.mjs +0 -51
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
import { isTimePeriodDimension, isRefAreaDimension } from '@sis-cc/dotstatsuite-sdmxjs';
|
|
3
|
-
|
|
4
|
-
export const getCombinationsNotInLayout = (combinations, layoutIds) => {
|
|
5
|
-
const { header=[], sections=[], rows=[] } = layoutIds;
|
|
6
|
-
const idsInLayout = new Set([...header, ...sections, ...rows]);
|
|
7
|
-
return R.reject(comb => idsInLayout.has(comb.id), combinations);
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const indexCombsRelationships = (combinations) => R.reduce((acc, comb) => {
|
|
11
|
-
const { id, relationship=[] } = comb;
|
|
12
|
-
return R.assoc(id, relationship, acc);
|
|
13
|
-
}, {}, combinations);
|
|
14
|
-
|
|
15
|
-
export const getLayoutLevelRelationship = indexedRelationships => ids => R.reduce((acc, id) => {
|
|
16
|
-
if (R.has(id, indexedRelationships)) {
|
|
17
|
-
return R.concat(acc, R.prop(id, indexedRelationships));
|
|
18
|
-
}
|
|
19
|
-
return R.append(id, acc);
|
|
20
|
-
}, [], ids);
|
|
21
|
-
|
|
22
|
-
export const getLayoutRelationships = (indexedRelationships, layoutIds) => R.map(
|
|
23
|
-
getLayoutLevelRelationship(indexedRelationships),
|
|
24
|
-
layoutIds
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
export const injectCombination = combination => ids => {
|
|
28
|
-
const { id, concepts=[] } = combination;
|
|
29
|
-
const conceptsSet = new Set(concepts);
|
|
30
|
-
let inject = true;
|
|
31
|
-
const refined = R.reduce((acc, i) => {
|
|
32
|
-
if (!conceptsSet.has(i)) {
|
|
33
|
-
return R.append(i, acc);
|
|
34
|
-
}
|
|
35
|
-
if (inject) {
|
|
36
|
-
inject = false;
|
|
37
|
-
return R.append(id, acc);
|
|
38
|
-
}
|
|
39
|
-
return acc;
|
|
40
|
-
}, [], ids);
|
|
41
|
-
return inject ? R.append(id, refined) : refined;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export const getCombinationLevelCompatibility = (layoutRelationships, combination) => {
|
|
45
|
-
const { relationship=[] } = combination;
|
|
46
|
-
const idsInHeaderSet = new Set(layoutRelationships.header);
|
|
47
|
-
const idsInSectionsSet = new Set(layoutRelationships.sections);
|
|
48
|
-
const idsInRowsSet = new Set(layoutRelationships.rows);
|
|
49
|
-
const [idsInHeader, rest] = R.partition(
|
|
50
|
-
i => idsInHeaderSet.has(i),
|
|
51
|
-
relationship
|
|
52
|
-
);
|
|
53
|
-
const [idsInSections, idsInRows] = R.reduce((_acc, id) => {
|
|
54
|
-
if (idsInSectionsSet.has(id))
|
|
55
|
-
return R.over(R.lensIndex(0), R.append(id), _acc);
|
|
56
|
-
if (idsInRowsSet.has(id))
|
|
57
|
-
return R.over(R.lensIndex(1), R.append(id), _acc);
|
|
58
|
-
return R.over(R.lensIndex(2), R.append(id), _acc);
|
|
59
|
-
}, [[], [], []], rest);
|
|
60
|
-
if (!R.isEmpty(idsInHeader) && R.isEmpty(idsInSections) && R.isEmpty(idsInRows)) {
|
|
61
|
-
return 'header';
|
|
62
|
-
}
|
|
63
|
-
if (!R.isEmpty(idsInHeader)) {
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
if (!R.isEmpty(idsInSections) && R.isEmpty(idsInRows)) {
|
|
67
|
-
return 'sections';
|
|
68
|
-
}
|
|
69
|
-
if (!R.isEmpty(idsInRows)) {
|
|
70
|
-
return 'rows';
|
|
71
|
-
}
|
|
72
|
-
return 'blank';
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const filterLayoutIds = (indexedCombinations, layoutDimsIds, obsAttributes) => (layoutIds) => {
|
|
76
|
-
const layoutConcepts = R.map(
|
|
77
|
-
R.reduce((acc, id) => {
|
|
78
|
-
if (R.has(id, indexedCombinations)) {
|
|
79
|
-
return R.concat(acc, R.path([id, 'concepts'], indexedCombinations));
|
|
80
|
-
}
|
|
81
|
-
return R.append(id, acc);
|
|
82
|
-
}, []),
|
|
83
|
-
layoutIds
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
return R.mapObjIndexed(
|
|
87
|
-
(ids, level) => R.filter(id => {
|
|
88
|
-
if (id === 'OBS_ATTRIBUTES') {
|
|
89
|
-
return !R.isEmpty(obsAttributes);
|
|
90
|
-
}
|
|
91
|
-
if (R.has(id, indexedCombinations)) {
|
|
92
|
-
const comb = R.prop(id, indexedCombinations);
|
|
93
|
-
const dims = R.filter(i => layoutDimsIds.has(i), comb.concepts);
|
|
94
|
-
if (!R.isEmpty(dims)) {
|
|
95
|
-
return true;
|
|
96
|
-
}
|
|
97
|
-
const oppositeIds = level === 'header'
|
|
98
|
-
? R.concat(R.prop('sections', layoutConcepts), R.prop('rows', layoutConcepts))
|
|
99
|
-
: R.prop('header', layoutConcepts);
|
|
100
|
-
return R.isEmpty(R.intersection(comb.relationship, oppositeIds));
|
|
101
|
-
}
|
|
102
|
-
return layoutDimsIds.has(id);
|
|
103
|
-
}, ids),
|
|
104
|
-
layoutIds
|
|
105
|
-
);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
export const injectCombinationsInLayout = (combinations, layoutIds, defaultLayoutIds = {}) => {
|
|
109
|
-
const notInLayoutCombs = getCombinationsNotInLayout(combinations, layoutIds);
|
|
110
|
-
if (R.isEmpty(notInLayoutCombs)) {
|
|
111
|
-
return layoutIds;
|
|
112
|
-
}
|
|
113
|
-
const indexedCombsRelationships = indexCombsRelationships(combinations);
|
|
114
|
-
let layoutRelationships = getLayoutRelationships(indexedCombsRelationships, layoutIds);
|
|
115
|
-
const defaultLayoutRelationships = getLayoutRelationships(indexedCombsRelationships, defaultLayoutIds);
|
|
116
|
-
return R.reduce((acc, comb) => {
|
|
117
|
-
let levelCompatibility = getCombinationLevelCompatibility(layoutRelationships, comb);
|
|
118
|
-
if (R.isNil(levelCompatibility)) {
|
|
119
|
-
return acc;
|
|
120
|
-
}
|
|
121
|
-
if (R.equals('blank', levelCompatibility)) {
|
|
122
|
-
levelCompatibility = getCombinationLevelCompatibility(defaultLayoutRelationships, comb);
|
|
123
|
-
if (R.isNil(levelCompatibility)) {
|
|
124
|
-
return acc;
|
|
125
|
-
}
|
|
126
|
-
levelCompatibility = R.equals('blank', levelCompatibility) ? 'rows' : levelCompatibility;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
layoutRelationships[levelCompatibility] = R.concat(layoutRelationships[levelCompatibility], comb.relationship);
|
|
130
|
-
const ids = injectCombination(comb)(acc[levelCompatibility]);
|
|
131
|
-
return R.assoc(levelCompatibility, ids)(acc);
|
|
132
|
-
}, layoutIds, notInLayoutCombs);
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
export const getLayoutDimsIds = dimensions => R.reduce(
|
|
136
|
-
(acc, d) => (d.header ? acc : acc.add(d.id)),
|
|
137
|
-
new Set([]),
|
|
138
|
-
dimensions,
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
export const getLayoutCombinations = (combinations, layoutDimsIds, attributes) => {
|
|
142
|
-
const indexedAttributes = R.indexBy(R.prop('id'), attributes);
|
|
143
|
-
return R.reduce(
|
|
144
|
-
(acc, comb) => {
|
|
145
|
-
const { layoutConcepts, relationship } = R.reduce(
|
|
146
|
-
(_acc, concept) => {
|
|
147
|
-
if (layoutDimsIds.has(concept)) {
|
|
148
|
-
return R.map(R.append(concept), _acc);
|
|
149
|
-
}
|
|
150
|
-
if (R.has(concept, indexedAttributes)) {
|
|
151
|
-
const attr = R.prop(concept, indexedAttributes);
|
|
152
|
-
return attr.series
|
|
153
|
-
? {
|
|
154
|
-
..._acc,
|
|
155
|
-
relationship: R.concat(_acc.relationship, attr.relationship),
|
|
156
|
-
}
|
|
157
|
-
: _acc;
|
|
158
|
-
}
|
|
159
|
-
return _acc;
|
|
160
|
-
},
|
|
161
|
-
{ layoutConcepts: [], relationship: [] },
|
|
162
|
-
comb.concepts || [],
|
|
163
|
-
);
|
|
164
|
-
if (R.isEmpty(relationship)) {
|
|
165
|
-
return acc;
|
|
166
|
-
}
|
|
167
|
-
return R.append({ ...comb, relationship, concepts: layoutConcepts }, acc);
|
|
168
|
-
},
|
|
169
|
-
[],
|
|
170
|
-
combinations,
|
|
171
|
-
);
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
const extractConcepts = (ids, indexedCombinations, layoutDimsIds) => {
|
|
175
|
-
const entry = R.find(id => {
|
|
176
|
-
if (R.has(id, indexedCombinations)) {
|
|
177
|
-
const dimId = R.find(i => layoutDimsIds.has(i), R.pathOr([], [id, 'concepts'], indexedCombinations));
|
|
178
|
-
return !R.isNil(dimId);
|
|
179
|
-
}
|
|
180
|
-
return true;
|
|
181
|
-
}, ids);
|
|
182
|
-
|
|
183
|
-
const getRelationship = id => {
|
|
184
|
-
if (R.has(id, indexedCombinations)) {
|
|
185
|
-
return R.append(id, R.path([id, 'relationship'], indexedCombinations));
|
|
186
|
-
}
|
|
187
|
-
return [id];
|
|
188
|
-
};
|
|
189
|
-
let indexedRels = R.reduce((acc, id) =>
|
|
190
|
-
R.assoc(id, getRelationship(id), acc)
|
|
191
|
-
, {}, ids);
|
|
192
|
-
|
|
193
|
-
let relationship = [entry];
|
|
194
|
-
while (!R.isEmpty(indexedRels)) {
|
|
195
|
-
const related = R.pickBy(rels => !R.isEmpty(R.intersection(relationship, rels)), indexedRels);
|
|
196
|
-
if (R.isEmpty(related)) {
|
|
197
|
-
break;
|
|
198
|
-
}
|
|
199
|
-
indexedRels = R.omit(R.keys(related), indexedRels);
|
|
200
|
-
relationship = R.concat(relationship, R.unnest(R.values(related)));
|
|
201
|
-
}
|
|
202
|
-
const set = new Set(relationship);
|
|
203
|
-
return R.partition(id => set.has(id), ids);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
export const injectRemainingDimensionsInLayout = (layoutIds, remainingDims, indexedCombinations, layoutDimsIds) => {
|
|
207
|
-
let _layout = layoutIds;
|
|
208
|
-
let _remaining = remainingDims;
|
|
209
|
-
|
|
210
|
-
const dimInRows = R.find(id => {
|
|
211
|
-
if (layoutDimsIds.has(id)) {
|
|
212
|
-
return true;
|
|
213
|
-
}
|
|
214
|
-
const dimId = R.find(i => layoutDimsIds.has(i), R.pathOr([], [id, 'concepts'], indexedCombinations));
|
|
215
|
-
return !R.isNil(dimId);
|
|
216
|
-
}, _layout.rows);
|
|
217
|
-
|
|
218
|
-
if (R.isNil(dimInRows)) {
|
|
219
|
-
if (R.isEmpty(_remaining)) {
|
|
220
|
-
const toTakeIn = R.isEmpty(_layout.sections) ? 'header' : 'sections';
|
|
221
|
-
const [extracted, remains] = extractConcepts(R.prop(toTakeIn, _layout), indexedCombinations, layoutDimsIds);
|
|
222
|
-
_layout = ({ ..._layout, rows: R.concat(_layout.rows, extracted), [toTakeIn]: remains });
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
_layout = R.over(R.lensProp('rows'), R.append(R.head(_remaining)))(_layout);
|
|
226
|
-
_remaining = R.tail(_remaining)
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
if (!R.isEmpty(_remaining)) {
|
|
230
|
-
const hasNoHeader = R.isEmpty(_layout.header);
|
|
231
|
-
const firstRemaining = R.head(_remaining);
|
|
232
|
-
_remaining = hasNoHeader ? R.tail(_remaining) : _remaining;
|
|
233
|
-
_layout = {
|
|
234
|
-
..._layout,
|
|
235
|
-
sections: R.concat(_layout.sections, _remaining),
|
|
236
|
-
header: hasNoHeader ? [firstRemaining] : _layout.header,
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
return _layout;
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
export const getTableLayoutIds = (
|
|
243
|
-
defaultLayoutIds,
|
|
244
|
-
currentLayoutIds,
|
|
245
|
-
dimensions,
|
|
246
|
-
attributes,
|
|
247
|
-
combinations
|
|
248
|
-
) => {
|
|
249
|
-
const layoutDimsIds = getLayoutDimsIds(dimensions);
|
|
250
|
-
const layoutCombinations = getLayoutCombinations(
|
|
251
|
-
combinations,
|
|
252
|
-
layoutDimsIds,
|
|
253
|
-
attributes,
|
|
254
|
-
);
|
|
255
|
-
const isBlank = R.pipe(R.values, R.all(R.isEmpty))(currentLayoutIds);
|
|
256
|
-
|
|
257
|
-
const combinationsConcepts = R.pipe(R.pluck('_concepts'), R.unnest, ids => new Set(ids))(combinations);
|
|
258
|
-
const obsAttributes = R.filter(a =>
|
|
259
|
-
a.series && R.isEmpty(a.relationship || []) && a.display && !combinationsConcepts.has(a)
|
|
260
|
-
, attributes);
|
|
261
|
-
const indexedCombinations = R.indexBy(R.prop('id'), layoutCombinations);
|
|
262
|
-
const filteredLayoutIds = filterLayoutIds(indexedCombinations, layoutDimsIds, obsAttributes)
|
|
263
|
-
(isBlank ? defaultLayoutIds : currentLayoutIds);
|
|
264
|
-
|
|
265
|
-
const layoutWithCombs = injectCombinationsInLayout(layoutCombinations, filteredLayoutIds, defaultLayoutIds);
|
|
266
|
-
const layoutRelationshipsSets = R.map(R.pipe(
|
|
267
|
-
ids => R.pick(ids, indexedCombinations),
|
|
268
|
-
R.values,
|
|
269
|
-
R.pluck('relationship'),
|
|
270
|
-
R.unnest,
|
|
271
|
-
i => new Set(i)
|
|
272
|
-
), layoutWithCombs);
|
|
273
|
-
const layoutConceptsSets = R.pipe(
|
|
274
|
-
R.map(
|
|
275
|
-
R.reduce((acc, id) => {
|
|
276
|
-
if (R.has(id, indexedCombinations)) {
|
|
277
|
-
return R.concat(acc, R.path([id, 'concepts'], indexedCombinations));
|
|
278
|
-
}
|
|
279
|
-
return R.append(id, acc);
|
|
280
|
-
}, []),
|
|
281
|
-
),
|
|
282
|
-
R.values,
|
|
283
|
-
R.unnest,
|
|
284
|
-
ids => new Set(ids)
|
|
285
|
-
)(layoutWithCombs);
|
|
286
|
-
const defaultLayoutConceptsSets = R.map(
|
|
287
|
-
ids => new Set(ids),
|
|
288
|
-
defaultLayoutIds
|
|
289
|
-
);
|
|
290
|
-
|
|
291
|
-
const { nextLayout, remaining } = R.reduce((acc, dim) => {
|
|
292
|
-
if (layoutConceptsSets.has(dim.id) || dim.header) {
|
|
293
|
-
return acc;
|
|
294
|
-
}
|
|
295
|
-
if (layoutRelationshipsSets.header.has(dim.id) || defaultLayoutConceptsSets.header.has(dim.id)) {
|
|
296
|
-
return R.over(R.lensPath(['nextLayout', 'header']), R.append(dim.id))(acc);
|
|
297
|
-
}
|
|
298
|
-
if (layoutRelationshipsSets.sections.has(dim.id) || defaultLayoutConceptsSets.sections.has(dim.id)) {
|
|
299
|
-
return R.over(R.lensPath(['nextLayout', 'sections']), R.append(dim.id))(acc);
|
|
300
|
-
}
|
|
301
|
-
if (layoutRelationshipsSets.rows.has(dim.id) || defaultLayoutConceptsSets.rows.has(dim.id)) {
|
|
302
|
-
return R.over(R.lensPath(['nextLayout','rows']), R.append(dim.id))(acc);
|
|
303
|
-
}
|
|
304
|
-
if (isTimePeriodDimension(dim)) {
|
|
305
|
-
return R.over(R.lensPath(['nextLayout','header']), R.append(dim.id))(acc);
|
|
306
|
-
}
|
|
307
|
-
if (isRefAreaDimension(dim)) {
|
|
308
|
-
return R.over(R.lensPath(['nextLayout','rows']), R.append(dim.id))(acc);
|
|
309
|
-
}
|
|
310
|
-
return R.over(R.lensProp('remaining'), R.append(dim.id))(acc);
|
|
311
|
-
}, { nextLayout: layoutWithCombs, remaining: [] }, dimensions);
|
|
312
|
-
|
|
313
|
-
return injectRemainingDimensionsInLayout(nextLayout, remaining, indexedCombinations, layoutDimsIds);
|
|
314
|
-
};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
import { declineObservationsOverAttributes } from './declineObservationsOverAttributes';
|
|
3
|
-
import { getLayout } from './getLayout';
|
|
4
|
-
import { getSortedLayoutIndexes } from './getSortedLayoutIndexes';
|
|
5
|
-
import { parseLayoutIndexesHierarchies } from './parseSeriesIndexesHierarchies';
|
|
6
|
-
import { refineLayoutSize } from './refineLayoutSize2';
|
|
7
|
-
import { getLayoutData } from './getLayoutData2';
|
|
8
|
-
import { getCellsAttributesIds } from './getCellsAttributesIds';
|
|
9
|
-
import { getIndexedCombinationsByDisplay } from './getIndexedCombinationsByDisplay';
|
|
10
|
-
import { getCells } from './getCells';
|
|
11
|
-
import { getCuratedCells } from './getCuratedCells';
|
|
12
|
-
import { getSeriesCombinations } from '../getSeriesCombinations';
|
|
13
|
-
import { getCellsMetadataCoordinates } from './getCellsMetadataCoordinates';
|
|
14
|
-
|
|
15
|
-
export const getTableProps = ({ data, layoutIds, customAttributes, limit, isTimeInverted }) => {
|
|
16
|
-
const {
|
|
17
|
-
observations,
|
|
18
|
-
dimensions,
|
|
19
|
-
combinations,
|
|
20
|
-
oneValueDimensions,
|
|
21
|
-
attributesSeries,
|
|
22
|
-
metadataCoordinates,
|
|
23
|
-
attributes,
|
|
24
|
-
header
|
|
25
|
-
} = data;
|
|
26
|
-
|
|
27
|
-
const obsAttributes = R.filter(
|
|
28
|
-
a => a.series && R.isEmpty(a.relationship) && a.display && !a.combined,
|
|
29
|
-
attributes
|
|
30
|
-
);
|
|
31
|
-
let dupObs = observations;
|
|
32
|
-
const hasDuplicatedCells = R.pipe(
|
|
33
|
-
R.values,
|
|
34
|
-
R.unnest,
|
|
35
|
-
R.find(R.equals('OBS_ATTRIBUTES')),
|
|
36
|
-
)(layoutIds);
|
|
37
|
-
if (hasDuplicatedCells) {
|
|
38
|
-
const attrsIds = R.pluck('id', obsAttributes);
|
|
39
|
-
dupObs = declineObservationsOverAttributes(attrsIds, observations);
|
|
40
|
-
}
|
|
41
|
-
const seriesCombinations = getSeriesCombinations(combinations, oneValueDimensions);
|
|
42
|
-
const _dims = R.append(
|
|
43
|
-
{
|
|
44
|
-
id: 'OBS_ATTRIBUTES',
|
|
45
|
-
values: R.prepend({ id: 'OBS_VALUE' }, obsAttributes),
|
|
46
|
-
},
|
|
47
|
-
dimensions,
|
|
48
|
-
);
|
|
49
|
-
const layout = getLayout(layoutIds, _dims, seriesCombinations, isTimeInverted);
|
|
50
|
-
const layoutDimsIds = R.map(R.reduce((acc, entry) => {
|
|
51
|
-
if (R.has('dimensions', entry)) {
|
|
52
|
-
return R.concat(acc, R.pluck('id', entry.dimensions));
|
|
53
|
-
}
|
|
54
|
-
return R.append(entry.id, acc);
|
|
55
|
-
}, []), layout);
|
|
56
|
-
const layoutIndexes = getSortedLayoutIndexes(layout, dupObs);
|
|
57
|
-
const enhancedLayoutIndexes = parseLayoutIndexesHierarchies(
|
|
58
|
-
layoutIndexes,
|
|
59
|
-
layout,
|
|
60
|
-
);
|
|
61
|
-
const refinedLayoutIndexes = refineLayoutSize({ layout, observations: dupObs, limit })(enhancedLayoutIndexes);
|
|
62
|
-
const layoutData = getLayoutData(refinedLayoutIndexes, layout, { metadataCoordinates, attributesSeries, customAttributes, topCoordinates: header.coordinates });
|
|
63
|
-
|
|
64
|
-
const cellsAttributesIds = getCellsAttributesIds(layoutDimsIds, attributes);
|
|
65
|
-
const indexedCombinations = getIndexedCombinationsByDisplay(layout, seriesCombinations);
|
|
66
|
-
const cellsMetadataCoordinates = getCellsMetadataCoordinates(metadataCoordinates, oneValueDimensions, layoutDimsIds);
|
|
67
|
-
const cells = getCells(customAttributes, cellsAttributesIds, indexedCombinations, attributesSeries, cellsMetadataCoordinates)(dupObs);
|
|
68
|
-
|
|
69
|
-
return ({
|
|
70
|
-
...layoutData,
|
|
71
|
-
cells: getCuratedCells(cells, layout),
|
|
72
|
-
layout,
|
|
73
|
-
combinations: seriesCombinations
|
|
74
|
-
});
|
|
75
|
-
};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
|
|
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 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) => {
|
|
19
|
-
return R.addIndex(R.reduce)((acc, _valueIndex, dimensionIndex) => {
|
|
20
|
-
if (R.is(Array, _valueIndex)) {
|
|
21
|
-
const previous = R.isEmpty(previousSerie) ? {} : R.map(R.nth(dimensionIndex), previousSerie);
|
|
22
|
-
const parsed = parseSerieIndexesHierarchies(
|
|
23
|
-
_valueIndex,
|
|
24
|
-
previous,
|
|
25
|
-
R.pathOr([], [dimensionIndex, 'dimensions'], dimensions),
|
|
26
|
-
acc.isSameSerie,
|
|
27
|
-
replicate
|
|
28
|
-
);
|
|
29
|
-
return registerParsedIndexes(parsed, acc);
|
|
30
|
-
}
|
|
31
|
-
const valueIndex = Math.abs(_valueIndex);
|
|
32
|
-
const parents = R.pathOr([], [dimensionIndex, 'values', valueIndex, 'parents'], dimensions);
|
|
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);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export const parseSeriesIndexesHierarchies = (seriesIndexes, dimensions, replicateMissing = false) => {
|
|
55
|
-
return R.reduce((acc, serieIndexes) => {
|
|
56
|
-
const previousSerie = R.last(acc) || {};
|
|
57
|
-
const { isSameSerie, ...parsed } = parseSerieIndexesHierarchies(serieIndexes, previousSerie, dimensions, true, replicateMissing);
|
|
58
|
-
return R.append(R.assoc('indexes', serieIndexes, parsed), acc);
|
|
59
|
-
}, [], seriesIndexes);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export const parseLayoutIndexesHierarchies = (layoutIndexes, layout) => {
|
|
63
|
-
const header = parseSeriesIndexesHierarchies(layoutIndexes.header, layout.header);
|
|
64
|
-
const sections = R.pipe(
|
|
65
|
-
R.transpose,
|
|
66
|
-
([_sections, _sectionsRows]) => {
|
|
67
|
-
if (R.isNil(_sections)) {
|
|
68
|
-
return [];
|
|
69
|
-
}
|
|
70
|
-
// replicate = true on sections
|
|
71
|
-
const sections = parseSeriesIndexesHierarchies(_sections, layout.sections, true);
|
|
72
|
-
const sectionsRows = R.map(rows => parseSeriesIndexesHierarchies(rows, layout.rows), _sectionsRows);
|
|
73
|
-
return R.transpose([sections, sectionsRows]);
|
|
74
|
-
}
|
|
75
|
-
)(layoutIndexes.sections);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return ({ header, sections });
|
|
79
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
|
|
3
|
-
export const isSameValueAsPrevious = (value, previousValue) => {
|
|
4
|
-
const valueHierarchicalPath = R.append(value.id, R.propOr([], 'parents', value));
|
|
5
|
-
const previousValueHierarchicalPath = R.append(previousValue.id, R.propOr([], 'parents', previousValue));
|
|
6
|
-
|
|
7
|
-
return R.equals(valueHierarchicalPath, previousValueHierarchicalPath);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const parseValueHierarchy = (value, previousValue, indexedValues) => {
|
|
11
|
-
const parentsIds = R.propOr([], 'parents', value);
|
|
12
|
-
if (R.isEmpty(parentsIds)) {
|
|
13
|
-
return value;
|
|
14
|
-
}
|
|
15
|
-
const _previousParentsIds = R.propOr([], 'parentsIds', previousValue);
|
|
16
|
-
const previousParentsIds = R.isNil(previousValue) ? [] : R.append(R.prop('id', previousValue), _previousParentsIds);
|
|
17
|
-
const [presentIds, _missingIds] = R.addIndex(R.splitWhen)((val, ind) => R.nth(ind, previousParentsIds) !== val, parentsIds);
|
|
18
|
-
const __previousParentsIds = R.pipe(R.propOr([], 'parents'), R.pluck('id'))(previousValue);
|
|
19
|
-
const missingIds = R.pipe(
|
|
20
|
-
R.takeLastWhile(id => !R.includes(id, __previousParentsIds) && id !== R.prop('id', previousValue)),
|
|
21
|
-
ids => R.concat(ids, _missingIds)
|
|
22
|
-
)(presentIds);
|
|
23
|
-
const _previousParents = R.propOr([], 'parents', previousValue);
|
|
24
|
-
const previousParents = R.isNil(previousValue) ? [] : R.append(R.pick(['id', 'name'], previousValue), _previousParents);
|
|
25
|
-
const parents = R.takeWhile(p => R.includes(p.id, presentIds), previousParents);
|
|
26
|
-
const missingParents = R.props(missingIds, indexedValues);
|
|
27
|
-
return ({
|
|
28
|
-
...value,
|
|
29
|
-
parents,
|
|
30
|
-
parentsIds,
|
|
31
|
-
missingParents
|
|
32
|
-
});
|
|
33
|
-
};
|