@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.
Files changed (234) hide show
  1. package/dist/dotstatsuite-components.js +38112 -0
  2. package/package.json +4 -1
  3. package/.editorconfig +0 -19
  4. package/.gitlab-ci.yml +0 -48
  5. package/prettier.config.js +0 -13
  6. package/src/app.js +0 -13
  7. package/src/bridge-d3-react/README.md +0 -42
  8. package/src/bridge-d3-react/src/app.js +0 -64
  9. package/src/bridge-d3-react/src/index.js +0 -17
  10. package/src/bridge-d3-react/src/mock-choro.js +0 -394
  11. package/src/bridge-d3-react/src/react-chart-factory.js +0 -65
  12. package/src/index.js +0 -12
  13. package/src/rules/README.md +0 -23
  14. package/src/rules/src/chart/getAxisOptions.js +0 -258
  15. package/src/rules/src/chart/getBaseOptions.js +0 -84
  16. package/src/rules/src/chart/getChartOptions.js +0 -118
  17. package/src/rules/src/chart/getGridOptions.js +0 -52
  18. package/src/rules/src/chart/getTooltipOptions.js +0 -230
  19. package/src/rules/src/constants.js +0 -64
  20. package/src/rules/src/date.js +0 -118
  21. package/src/rules/src/dimension-utils.js +0 -54
  22. package/src/rules/src/factories/choro-series.js +0 -65
  23. package/src/rules/src/factories/sample-focus.js +0 -22
  24. package/src/rules/src/factories/sample-series.js +0 -51
  25. package/src/rules/src/factories/scatter-dimension.js +0 -31
  26. package/src/rules/src/factories/scatter-focus.js +0 -39
  27. package/src/rules/src/factories/scatter-series.js +0 -94
  28. package/src/rules/src/factories/stacked-dimension.js +0 -29
  29. package/src/rules/src/factories/stacked-series.js +0 -185
  30. package/src/rules/src/factories/symbol-dimension.js +0 -29
  31. package/src/rules/src/factories/symbol-series.js +0 -62
  32. package/src/rules/src/factories/timeline-focus.js +0 -18
  33. package/src/rules/src/factories/timeline-series.js +0 -91
  34. package/src/rules/src/get-values-enhanced.js +0 -134
  35. package/src/rules/src/header/getDefaultSubtitle.js +0 -40
  36. package/src/rules/src/header/getHeaderUnits.js +0 -17
  37. package/src/rules/src/header/getSubtitleFlags.js +0 -43
  38. package/src/rules/src/header/getTitleFlags.js +0 -8
  39. package/src/rules/src/header/index.js +0 -4
  40. package/src/rules/src/index.js +0 -398
  41. package/src/rules/src/layout.js +0 -113
  42. package/src/rules/src/observation-formater.js +0 -83
  43. package/src/rules/src/preparators/enhanceObservations.js +0 -152
  44. package/src/rules/src/preparators/formatValue.js +0 -84
  45. package/src/rules/src/preparators/getObservations.js +0 -19
  46. package/src/rules/src/preparators/getReportingYearStart.js +0 -16
  47. package/src/rules/src/properties/errors.js +0 -19
  48. package/src/rules/src/properties/focus.js +0 -69
  49. package/src/rules/src/properties/getAvailableChartTypes.js +0 -34
  50. package/src/rules/src/properties/getHeaderProps.js +0 -74
  51. package/src/rules/src/properties/getInformationsStateFromNewProps.js +0 -47
  52. package/src/rules/src/properties/getObservationsType.js +0 -29
  53. package/src/rules/src/properties/getStringifiedSubtitle.js +0 -6
  54. package/src/rules/src/properties/index.js +0 -424
  55. package/src/rules/src/properties/information.js +0 -84
  56. package/src/rules/src/properties/linear.js +0 -129
  57. package/src/rules/src/properties/scatter.js +0 -158
  58. package/src/rules/src/properties/stacked.js +0 -98
  59. package/src/rules/src/properties/symbol.js +0 -79
  60. package/src/rules/src/properties/utils.js +0 -110
  61. package/src/rules/src/sdmx-data/index.js +0 -39
  62. package/src/rules/src/table/factories/getCellValue.js +0 -50
  63. package/src/rules/src/table/index.js +0 -1
  64. package/src/rules/src/v8-transformer.js +0 -176
  65. package/src/rules/test/extractSdmxArtefacts.js +0 -26
  66. package/src/rules/test/get-values-enhanced.test.js +0 -127
  67. package/src/rules/test/oecd-HEALTH_PROT-no-freq.json +0 -2903
  68. package/src/rules/test/oecd-HEALTH_PROT-parsed.js +0 -398
  69. package/src/rules/test/oecd-HEALTH_PROT-wrong-freq.json +0 -2913
  70. package/src/rules/test/oecd-HEALTH_PROT.json +0 -2913
  71. package/src/rules/test/oecd-KEI.json +0 -372
  72. package/src/rules/test/scatter-property.js +0 -455
  73. package/src/rules/test/stacked-property.js +0 -273
  74. package/src/rules/test/symbol-property.js +0 -262
  75. package/src/rules/test/v8-transformer.test.js +0 -90
  76. package/src/rules2/src/applyHierarchicalCodesToDim.js +0 -149
  77. package/src/rules2/src/combinedValuesDisplay.js +0 -74
  78. package/src/rules2/src/constants.js +0 -6
  79. package/src/rules2/src/duplicateObservations.js +0 -35
  80. package/src/rules2/src/enhanceObservations.js +0 -95
  81. package/src/rules2/src/getAdvAttrSeriesAtCoordinates.js +0 -29
  82. package/src/rules2/src/getAttributesSeries.js +0 -36
  83. package/src/rules2/src/getCombinationDefinitions.js +0 -47
  84. package/src/rules2/src/getDataflowAttributes.js +0 -23
  85. package/src/rules2/src/getDataflowTooltipAttributesIds.js +0 -31
  86. package/src/rules2/src/getDimensionValuesIndexes.js +0 -13
  87. package/src/rules2/src/getHCodelistsRefsInData.js +0 -32
  88. package/src/rules2/src/getHeaderCombinations.js +0 -48
  89. package/src/rules2/src/getHeaderCoordinates.js +0 -7
  90. package/src/rules2/src/getHeaderSubtitle.js +0 -34
  91. package/src/rules2/src/getHeaderTitle.js +0 -15
  92. package/src/rules2/src/getMSDInformations.js +0 -23
  93. package/src/rules2/src/getManyValuesDimensions.js +0 -34
  94. package/src/rules2/src/getMetadataCoordinates.js +0 -37
  95. package/src/rules2/src/getMetadataStructureFromData.js +0 -17
  96. package/src/rules2/src/getNotDisplayedIds.js +0 -53
  97. package/src/rules2/src/getOneValueDimensions.js +0 -34
  98. package/src/rules2/src/getSeriesCombinations.js +0 -24
  99. package/src/rules2/src/hasCellMetadata.js +0 -14
  100. package/src/rules2/src/hierarchiseDimensionWithAdvancedHierarchy2.js +0 -57
  101. package/src/rules2/src/hierarchiseDimensionWithNativeHierarchy2.js +0 -35
  102. package/src/rules2/src/index.js +0 -50
  103. package/src/rules2/src/parseAttributes.js +0 -41
  104. package/src/rules2/src/parseCombinations.js +0 -102
  105. package/src/rules2/src/parseHierarchicalCodelist.js +0 -48
  106. package/src/rules2/src/parseMetadataSeries.js +0 -117
  107. package/src/rules2/src/prepareData.js +0 -73
  108. package/src/rules2/src/refineAttributes.js +0 -16
  109. package/src/rules2/src/refineDimensions.js +0 -18
  110. package/src/rules2/src/refineMetadataCoordinates.js +0 -28
  111. package/src/rules2/src/refineTimePeriod.js +0 -127
  112. package/src/rules2/src/sdmx3.0DataFormatPatch.js +0 -9
  113. package/src/rules2/src/table/declineObservationsOverAttributes.js +0 -32
  114. package/src/rules2/src/table/getCells.js +0 -93
  115. package/src/rules2/src/table/getCellsAttributesIds.js +0 -38
  116. package/src/rules2/src/table/getCellsMetadataCoordinates.js +0 -13
  117. package/src/rules2/src/table/getCombinationDimensionsData.js +0 -39
  118. package/src/rules2/src/table/getCuratedCells.js +0 -33
  119. package/src/rules2/src/table/getFlagsAndNotes.js +0 -23
  120. package/src/rules2/src/table/getIndexedCombinationsByDisplay.js +0 -16
  121. package/src/rules2/src/table/getLayout.js +0 -84
  122. package/src/rules2/src/table/getLayoutData2.js +0 -198
  123. package/src/rules2/src/table/getSortedLayoutIndexes.js +0 -124
  124. package/src/rules2/src/table/getTableLabelAccessor.js +0 -9
  125. package/src/rules2/src/table/getTableLayoutIds.js +0 -314
  126. package/src/rules2/src/table/getTableProps.js +0 -75
  127. package/src/rules2/src/table/parseSeriesIndexesHierarchies.js +0 -79
  128. package/src/rules2/src/table/parseValueHierarchy.js +0 -33
  129. package/src/rules2/src/table/refineLayoutSize2.js +0 -321
  130. package/src/rules2/src/utils.js +0 -37
  131. package/src/viewer/mocks/bar.js +0 -33
  132. package/src/viewer/mocks/gpp-symbol.js +0 -93
  133. package/src/viewer/mocks/gpp-time.js +0 -1103
  134. package/src/viewer/mocks/row.js +0 -39
  135. package/src/viewer/mocks/scatter.js +0 -93
  136. package/src/viewer/mocks/stack.js +0 -161
  137. package/src/viewer/src/app/leg.js +0 -36
  138. package/src/viewer/src/app/nodata-res.js +0 -22
  139. package/src/viewer/src/app/nodata-sized.js +0 -23
  140. package/src/viewer/src/app/one-table-cell.js +0 -70
  141. package/src/viewer/src/app/table.js +0 -423
  142. package/src/viewer/src/app/use-case-1.js +0 -33
  143. package/src/viewer/src/app/use-case-2.js +0 -38
  144. package/src/viewer/src/app/use-case-3.js +0 -18
  145. package/src/viewer/src/app.js +0 -116
  146. package/src/viewer/src/chart.js +0 -52
  147. package/src/viewer/src/chartUtils/options.js +0 -30
  148. package/src/viewer/src/chartUtils/series.js +0 -51
  149. package/src/viewer/src/footer.js +0 -24
  150. package/src/viewer/src/header.js +0 -10
  151. package/src/viewer/src/index.js +0 -158
  152. package/src/viewer/src/legends/AxisLegend.js +0 -41
  153. package/src/viewer/src/legends/ChartLegends.js +0 -66
  154. package/src/viewer/src/legends/FocusLegend.js +0 -63
  155. package/src/viewer/src/legends/Legend.js +0 -46
  156. package/src/viewer/src/legends/SeriesLegend.js +0 -78
  157. package/src/viewer/src/utils.js +0 -21
  158. package/test/applyHierarchicalCodesToDim.test.js +0 -160
  159. package/test/combinedValuesDisplay.test.js +0 -66
  160. package/test/duplicateObs.test.js +0 -118
  161. package/test/enhanceObservations2.test.js +0 -257
  162. package/test/getAttributesSeries.test.js +0 -66
  163. package/test/getAxisOptions.test.js +0 -309
  164. package/test/getBaseOptions.test.js +0 -77
  165. package/test/getCellValue.test.js +0 -32
  166. package/test/getCells.test.js +0 -178
  167. package/test/getCellsMetadataCoordinates.test.js +0 -40
  168. package/test/getCombinationDefinitions.test.js +0 -104
  169. package/test/getCombinationDimensionsData.test.js +0 -99
  170. package/test/getDataflowAttributes.test.js +0 -23
  171. package/test/getDataflowTooltipAttributesIds.test.js +0 -146
  172. package/test/getDimensionValuesIndexes.test.js +0 -33
  173. package/test/getGridOptions.test.js +0 -65
  174. package/test/getHCodelistsRefs.test.js +0 -23
  175. package/test/getHeaderCombinations.test.js +0 -62
  176. package/test/getHeaderTitle.test.js +0 -25
  177. package/test/getLayout.test.js +0 -54
  178. package/test/getLayoutData2.test.js +0 -535
  179. package/test/getMSDInformations.test.js +0 -35
  180. package/test/getMetadataCoordinates.test.js +0 -0
  181. package/test/getNotDisplayedIds.test.js +0 -47
  182. package/test/getObservationsType.test.js +0 -55
  183. package/test/getOneValueDimensions.test.js +0 -35
  184. package/test/getReportingYearStart.test.js +0 -59
  185. package/test/getSeriesCombinations.test.js +0 -29
  186. package/test/getSortedLayoutIndexes.test.js +0 -1138
  187. package/test/getTableLabelAccessor.test.js +0 -50
  188. package/test/getTableLayoutIds.test.js +0 -356
  189. package/test/hierarchiseDimensionWithNativeHierarchy2.test.js +0 -109
  190. package/test/isTableLayoutCompatible.test.js +0 -102
  191. package/test/metadata-parsing-perf.test.js +0 -509
  192. package/test/mocks/MSD_TEST.json +0 -490
  193. package/test/mocks/OECD_SNA_TABLE1_1.0_-_AUS_V_metadata.json +0 -152
  194. package/test/mocks/h-codelist.json +0 -2095
  195. package/test/mocks/large_metadata_series.json +0 -701
  196. package/test/mocks/observations-advanced-attributes.json +0 -55382
  197. package/test/mocks/table-invert-time--data.json +0 -80211
  198. package/test/mocks/table-invert-time--inverted.json +0 -80076
  199. package/test/mocks/table-layout-multi-hierarchies--layout.json +0 -621
  200. package/test/mocks/table-layout-multi-hierarchies--layoutData.json +0 -32411
  201. package/test/mocks/table-layout-multi-hierarchies--layoutIndexes.json +0 -2760
  202. package/test/mocks/table-layout-multi-hierarchies--observations.json +0 -30688
  203. package/test/mocks/table-layout-multi-hierarchies--sizedIndexes.json +0 -2762
  204. package/test/mocks/table-layout-truncation1--layout.json +0 -27469
  205. package/test/mocks/table-layout-truncation1--layoutData.json +0 -20358
  206. package/test/mocks/table-layout-truncation1--layoutIndexes.json +0 -7512
  207. package/test/mocks/table-layout-truncation1--observations.json +0 -70002
  208. package/test/mocks/table-layout-truncation1--sizedIndexes.json +0 -3011
  209. package/test/mocks/table-prep-multi-hierarchies--attributes.json +0 -46
  210. package/test/mocks/table-prep-multi-hierarchies--dimensions.json +0 -688
  211. package/test/mocks/table-prep-multi-hierarchies--enhancedObservations.json +0 -19696
  212. package/test/mocks/table-prep-multi-hierarchies--observations.json +0 -8246
  213. package/test/mocks/table-prep-multi-hierarchies--sdmxJson.json +0 -2985
  214. package/test/mocks/table-prep-simple-duplicate--dimensions2.json +0 -858
  215. package/test/mocks/table-prep-simple-duplicate--duplicated2.json +0 -77502
  216. package/test/mocks/table-prep-simple-duplicate--observations2.json +0 -60002
  217. package/test/mocks/table-prep-truncation1--dimensions.json +0 -35057
  218. package/test/mocks/table-prep-truncation1--enhancedObservations.json +0 -70002
  219. package/test/mocks/table-prep-truncation1--observations.json +0 -27502
  220. package/test/mocks/table-prep-truncation1--sdmxJson.json +0 -55103
  221. package/test/mocks/table-prep-units--observations.json +0 -284286
  222. package/test/mocks/table-prep-units--unitsSeries.json +0 -41042
  223. package/test/parseAttributes.test.js +0 -36
  224. package/test/parseCombinations.test.js +0 -172
  225. package/test/parseHierarchicalCodelist.test.js +0 -140
  226. package/test/parseMetadataSeries.test.js +0 -128
  227. package/test/parseSeriesIndexesHierarchies.test.js +0 -345
  228. package/test/parseValueHierarchy.test.js +0 -138
  229. package/test/refineAttributes.test.js +0 -29
  230. package/test/refineLayoutSize2.test.js +0 -3410
  231. package/test/refineMetadataCoordinates.test.js +0 -86
  232. package/test/refineTimePeriod.test.js +0 -580
  233. package/test/refinedDimensions.test.js +0 -35
  234. package/vite.config.mjs +0 -51
@@ -1,16 +0,0 @@
1
- import * as R from 'ramda';
2
-
3
- export const getIndexedCombinationsByDisplay = (layout, combinations) => {
4
- const layoutIds = R.pipe(
5
- R.map(R.pluck('id')),
6
- R.values,
7
- R.unnest,
8
- R.indexBy(R.identity),
9
- )(layout);
10
-
11
- const [combsInLayout, combsInCells] = R.partition(
12
- comb => R.has(comb.id, layoutIds),
13
- combinations,
14
- );
15
- return { cells: combsInCells, layout: combsInLayout };
16
- };
@@ -1,84 +0,0 @@
1
- import * as R from 'ramda';
2
- import { isTimePeriodDimension } from '@sis-cc/dotstatsuite-sdmxjs';
3
-
4
- export const getConceptsSet = (ids, indexedCombinations, _upper) => {
5
- const upper = R.isNil(_upper) ? new Set([]) : _upper;
6
- const res = new Set([]);
7
- R.forEach(id => {
8
- if (!R.has(id, indexedCombinations)) {
9
- res.add(id);
10
- }
11
- else {
12
- const comb = R.prop(id, indexedCombinations);
13
- R.forEach(c => {
14
- if (!upper.has(c)) {
15
- res.add(c);
16
- }
17
- }, comb.concepts);
18
- }
19
- }, ids);
20
- return res;
21
- };
22
-
23
- export const parseCombination = (_upperIds, _excludedIds) => (comb, indexedDimensions) => {
24
- const upperIds = R.isNil(_upperIds) ? new Set([]) : _upperIds;
25
- const excludedIds = R.isNil(_excludedIds) ? new Set([]) : _excludedIds;
26
-
27
- const { concepts, relationship } = comb;
28
- const dimensions = R.reduce((acc, id) => {
29
- if (upperIds.has(id) || !R.has(id, indexedDimensions)) {
30
- return acc
31
- }
32
- const dim = R.prop(id, indexedDimensions);
33
- return R.append(dim, acc);
34
- }, [], concepts);
35
- const excludedDep = R.find(i => excludedIds.has(i), relationship);
36
- if (excludedDep) {
37
- return dimensions;
38
- }
39
- return R.assoc('dimensions', dimensions, comb);
40
- };
41
-
42
- export const getLayout = (_layoutIds, dimensions, combinations, isTimeInverted) => {
43
- const layoutIds = R.mergeRight(
44
- { header: [], sections: [], rows: [] },
45
- _layoutIds,
46
- );
47
- const applyInversionOnTimeDim = dim =>
48
- isTimePeriodDimension(dim) && isTimeInverted
49
- ? R.assoc('isInverted', true, dim)
50
- : dim;
51
-
52
- const indexedDimensions = R.reduce(
53
- (acc, dim) => R.assoc(dim.id, applyInversionOnTimeDim(dim), acc),
54
- {},
55
- dimensions,
56
- );
57
-
58
- const indexedCombinations = R.indexBy(R.prop('id'), combinations);
59
- const headerConceptsSet = getConceptsSet(layoutIds.header, indexedCombinations);
60
- const sectionsConceptsSet = getConceptsSet(layoutIds.sections, indexedCombinations);
61
- const rowsConceptsSet = getConceptsSet(R.concat(layoutIds.sections, layoutIds.rows), indexedCombinations);
62
-
63
- const getLayoutLevel = (_upperIds, _excludedIds) => ids => R.reduce((acc, id) => {
64
- if (R.has(id, indexedDimensions)) {
65
- const dim = R.prop(id, indexedDimensions);
66
- return R.append(dim, acc);
67
- }
68
- if (!R.has(id, indexedCombinations)) {
69
- return acc;
70
- }
71
- const comb = R.prop(id, indexedCombinations);
72
- const parsedCombination = parseCombination(_upperIds, _excludedIds)(comb, indexedDimensions);
73
- if (R.is(Array, parsedCombination)) {
74
- return R.concat(acc, parsedCombination);
75
- }
76
- return R.append(parsedCombination, acc);
77
- }, [], ids);
78
-
79
- const header = getLayoutLevel(null, rowsConceptsSet)(layoutIds.header);
80
- const sections = getLayoutLevel(null, headerConceptsSet)(layoutIds.sections);
81
- const rows = getLayoutLevel(sectionsConceptsSet, headerConceptsSet)(layoutIds.rows);
82
-
83
- return ({ header, sections, rows });
84
- };
@@ -1,198 +0,0 @@
1
- import * as R from 'ramda';
2
- import { getFlagsAndNotes } from './getFlagsAndNotes';
3
- import { getLayoutCoordinatesValidator } from '../utils';
4
-
5
- const getValueData = (index, dimension, parentsIndexes, missingParents = []) => ({
6
- dimension: R.pick(['id', 'name', '__index'], dimension),
7
- value: {
8
- ...R.pipe(
9
- R.pathOr({}, ['values', index]),
10
- R.pick(['id', 'name', 'isNonCoded', 'flags', 'hasAdvancedAttributes', 'display'])
11
- )(dimension),
12
- parents: parentsIndexes,
13
- missingParents
14
- }
15
- });
16
-
17
- const addCoordinatesToKey = (key, dimensionId, valueId) =>
18
- `${key}${R.isEmpty(key) ? '' : ':'}${dimensionId}=${valueId}`;
19
-
20
- const simpleValueDataSetter = (valueData, datas = []) => R.append(valueData, datas);
21
-
22
- const combinedValueDataSetter = (valueData, datas = []) =>
23
- R.over(R.lensIndex(-1), d => ({ ...d, values: R.append(R.prop('value', valueData), d.values) }), datas);
24
-
25
- const addValueToSerieData = (dataSetter) => (index, parentsIndexes, dimension, serieData, missingParents) => {
26
- const valueData = getValueData(index, dimension, parentsIndexes, missingParents);
27
- const valueId = R.path(['value', 'id'], valueData);
28
- return ({
29
- ...serieData,
30
- data: dataSetter(valueData, R.prop('data', serieData)),
31
- key: addCoordinatesToKey(R.prop('key', serieData), R.prop('id', dimension), valueId)
32
- });
33
- };
34
-
35
- const addSimpleValueToSerieData = addValueToSerieData(simpleValueDataSetter);
36
-
37
- const addCombinedValueToSerieData = addValueToSerieData(combinedValueDataSetter);
38
-
39
- const getHasAdvancedAttributes = (attrValues, customAttributes) => R.pipe(
40
- R.omit(R.concat(customAttributes.flags || [], customAttributes.notes || [])),
41
- R.isEmpty,
42
- R.not
43
- )(attrValues);
44
-
45
- const getCoordinates = (indexes, topCoordinates, definition) => R.addIndex(R.reduce)((acc, entry, index) => {
46
- if (R.has('dimensions', entry)) {
47
- return R.addIndex(R.reduce)((_acc, dim, _index) => {
48
- const valInd = R.path([index, _index], indexes);
49
- return R.assoc(dim.id, R.path(['values', Math.abs(valInd), 'id'], dim), _acc)
50
- }, acc, entry.dimensions);
51
- }
52
- const valInd = R.nth(index, indexes);
53
- return R.assoc(entry.id, R.path(['values', Math.abs(valInd), 'id'], entry), acc);
54
- }, topCoordinates, definition);
55
-
56
- const getAttributesSeries = (validator, attributesSeries) => R.reduce((acc, attrs) => {
57
- const attr = R.head(R.values(attrs)) || {};
58
- if (R.length(attr.relationship || []) === 1 && !attr.combined) {
59
- return acc;
60
- }
61
- const coordinates = R.propOr({}, 'coordinates', attr);
62
- const isValid = validator(coordinates);
63
- if (!isValid && !R.prop('isObs', attr)) {
64
- return acc;
65
- }
66
- return ({ ...acc, ...attrs });
67
- }, {}, R.values(attributesSeries));
68
-
69
- const combineConcepts = (combDimValues, definition, attrValues) => R.over(
70
- R.lensProp('data'),
71
- R.over(R.lensIndex(-1), data => ({
72
- ...data,
73
- values: R.reduce((acc, conceptId) => {
74
- if (R.has(conceptId, combDimValues)) {
75
- return R.append(R.prop(conceptId, combDimValues), acc);
76
- }
77
- if (R.has(conceptId, definition.fixedDimValues || {})) {
78
- return R.append(R.prop(conceptId, definition.fixedDimValues), acc);
79
- }
80
- if (R.has(conceptId, attrValues)) {
81
- const value = R.path([conceptId, 'value'], attrValues);
82
- return R.append(value, acc);
83
- }
84
- return acc;
85
- }, [], definition.concepts)
86
- })));
87
-
88
- const getSerieFlagsAndSideProps = (coordinates, validator, attributesValues, customAttributes, metadataCoordinates, data) => {
89
- const layoutAttrValues = R.reject(attr => R.prop('isObs', attr) && !validator(attr.coordinates), attributesValues);
90
- const flags = getFlagsAndNotes(layoutAttrValues, customAttributes);
91
- const hasMetadata = !R.isNil(R.find(validator, metadataCoordinates));
92
- const hasDataAdvancedAttributes = R.any(
93
- d => R.has('value', d) ? R.prop('hasAdvancedAttributes', d.value) : R.any(R.prop('hasAdvancedAttributes'), d.values)
94
- , data);
95
- const hasAdvancedAttributes = hasDataAdvancedAttributes || getHasAdvancedAttributes(layoutAttrValues, customAttributes);
96
- const sideProps = hasMetadata || hasAdvancedAttributes
97
- ? { hasMetadata, hasAdvancedAttributes, coordinates } : null;
98
- return { flags, sideProps };
99
- };
100
-
101
- const getSerieDimensionsData = (serie, definition, attributesValues, missingParentsGetter) => R.addIndex(R.reduce)(
102
- (onGoingSerie, entry, index) => {
103
- if (R.has('dimensions', entry)) {
104
- const combValuesIndexes = R.pathOr([], ['indexes', index], serie);
105
- const combParentsIndexes = R.pathOr([], ['parentsIndexes', index], serie);
106
- const combMissingParentsIndexes = R.pathOr([], ['missingIndexes', index], serie);
107
- let combDimValues = {};
108
- const res = R.addIndex(R.reduce)((combSerie, dimension, dimIndex) => {
109
- const valueIndex = Math.abs(R.nth(dimIndex, combValuesIndexes));
110
- const _parentsIndexes = R.nth(dimIndex, combParentsIndexes) || [];
111
- const missingParentsIndexes = R.nth(dimIndex, combMissingParentsIndexes) || [];
112
- const { parentsIndexes, missingParents } = missingParentsGetter(combinedValueDataSetter)(missingParentsIndexes, _parentsIndexes, dimension, combSerie);
113
- const next = addCombinedValueToSerieData(valueIndex, parentsIndexes, dimension, combSerie, missingParents);
114
- const value = R.pipe(R.prop('data'), R.last, R.prop('values'), R.last)(next);
115
- combDimValues = R.assoc(dimension.id, value, combDimValues);
116
- return next;
117
- },
118
- R.over(
119
- R.lensProp('data'),
120
- R.append({ dimension: R.pick(['id', 'name'], entry), values: [] })
121
- )(onGoingSerie),
122
- R.propOr([], 'dimensions', entry));
123
-
124
- const combined = combineConcepts(combDimValues, entry, onGoingSerie.attributes)(res);
125
- return R.over(R.lensProp('attributes'), R.omit(entry.concepts), combined);
126
- }
127
-
128
- const valueIndex = Math.abs(R.path(['indexes', index], serie));
129
- const _parentsIndexes = R.pathOr([], ['parentsIndexes', index], serie);
130
- const missingParentsIndexes = R.pathOr([], ['missingIndexes', index], serie);
131
- const { parentsIndexes, missingParents } = missingParentsGetter(simpleValueDataSetter)(missingParentsIndexes, _parentsIndexes, entry, onGoingSerie);
132
- return addSimpleValueToSerieData(valueIndex, parentsIndexes, entry, onGoingSerie, missingParents);
133
- },
134
- { data: [], key: '', attributes: attributesValues },
135
- definition,
136
- );
137
-
138
- export const getSerieDataWithMissingLines = (serie, definition, topCoordinates, attributesSeries, customAttributes, metadataCoordinates) => {
139
- const lines = [];
140
-
141
- const serieCoordinates = getCoordinates(serie.indexes, topCoordinates, definition);
142
- const coordinatesValidator = getLayoutCoordinatesValidator(serieCoordinates, topCoordinates);
143
- const attributesValues = getAttributesSeries(coordinatesValidator, attributesSeries);
144
-
145
- const getMissingParents = dataSetter => (missingParentsIndexes, _parentsIndexes, dim, serieData) => R.reduce(
146
- (acc, index) => {
147
- const missingParentData = addValueToSerieData(dataSetter)(index, acc.parentsIndexes, dim, serieData);
148
- lines.push({ ...R.dissoc('attributes', missingParentData), sideProps: null, flags: [], isEmpty: true });
149
- return R.over(R.lensProp('parentsIndexes'), R.append(index), acc);
150
- },
151
- { parentsIndexes: _parentsIndexes, missingParents: [] }, missingParentsIndexes);
152
- const { attributes, ...serieData } = getSerieDimensionsData(serie, definition, attributesValues, getMissingParents);
153
- const topCoordinatesValidator = getLayoutCoordinatesValidator(topCoordinates);
154
- const flagsValidator = coordinates => coordinatesValidator(coordinates) && !topCoordinatesValidator(coordinates);
155
- const { flags, sideProps } = getSerieFlagsAndSideProps(serieCoordinates, flagsValidator, attributes, customAttributes, metadataCoordinates, serieData.data);
156
- return R.append({ ...serieData, flags, sideProps, coordinates: serieCoordinates }, lines);
157
- };
158
-
159
- export const getSerieDataWithoutMissingLines = (serie, definition, topCoordinates, attributesSeries, customAttributes, metadataCoordinates) => {
160
- const serieCoordinates = getCoordinates(serie.indexes, topCoordinates, definition);
161
- const coordinatesValidator = getLayoutCoordinatesValidator(serieCoordinates, topCoordinates);
162
- const attributesValues = getAttributesSeries(coordinatesValidator, attributesSeries);
163
-
164
- const getMissingParents = () => (missingParentsIndexes, _parentsIndexes, dim) => R.reduce(
165
- (acc, index) => ({
166
- parentsIndexes: R.append(index, acc.parentsIndexes),
167
- missingParents: R.append(R.prop('value', getValueData(index, dim, acc.parentsIndexes)), acc.missingParents)
168
- }),
169
- { parentsIndexes: _parentsIndexes, missingParents: [] }, missingParentsIndexes);
170
-
171
- const { attributes, ...serieData } = getSerieDimensionsData(serie, definition, attributesValues, getMissingParents);
172
- const { flags, sideProps } = getSerieFlagsAndSideProps(serieCoordinates, coordinatesValidator, attributes, customAttributes, metadataCoordinates, serieData.data);
173
- return ({ ...serieData, flags, sideProps, coordinates: serieCoordinates });
174
- };
175
-
176
- export const getLayoutData = (layoutIndexes, layout, { metadataCoordinates, attributesSeries, customAttributes, topCoordinates={} }) => {
177
- const { header, sections, ...rest } = layoutIndexes;
178
- const headerData = R.reduce((acc, serie) => {
179
- const datas = getSerieDataWithMissingLines(serie, layout.header, topCoordinates, attributesSeries, customAttributes, metadataCoordinates);
180
- return R.concat(acc, datas);
181
- }, [], header);
182
-
183
- const sectionsData = R.map(
184
- ([sectionSerie, rowsSeries]) => {
185
- const sectionData = getSerieDataWithoutMissingLines(sectionSerie, layout.sections, topCoordinates, attributesSeries, customAttributes, metadataCoordinates, false);
186
- return [
187
- sectionData,
188
- R.reduce((acc, serie) => {
189
- const datas = getSerieDataWithMissingLines(serie, layout.rows, R.propOr(topCoordinates, 'coordinates', sectionData), attributesSeries, customAttributes, metadataCoordinates);
190
- return R.concat(acc, datas);
191
- }, [], rowsSeries)
192
- ];
193
- },
194
- sections
195
- );
196
-
197
- return ({ headerData, sectionsData, ...rest });
198
- };
@@ -1,124 +0,0 @@
1
- import * as R from 'ramda';
2
-
3
- /*
4
- const layout = {
5
- header: [
6
- { id, __index },
7
- { id: COMB, dimensions: [{ id, __index }] }
8
- ],
9
- sections: [],
10
- rows: []
11
- }
12
-
13
- */
14
-
15
- const getLayoutPivots = layoutEntry => {
16
- const valIndexGetter = d => R.pipe(
17
- R.nth(R.prop('__index', d)),
18
- ind => d.isInverted ? R.negate(ind) : ind
19
- );
20
- return indexes => R.map(
21
- R.ifElse(
22
- R.has('dimensions'),
23
- c => R.map(d => valIndexGetter(d)(indexes), R.prop('dimensions', c)),
24
- d => {
25
- if (d.id === 'OBS_ATTRIBUTES') {
26
- return R.last(indexes);
27
- }
28
- return valIndexGetter(d)(indexes);
29
- }
30
- ),
31
- layoutEntry
32
- );
33
- };
34
-
35
- const comparator = (a, b) => {
36
- const size = R.length(a);
37
- let i = 0;
38
- while (i < size) {
39
- if (R.is(Array, a[i])) {
40
- const _a = a[i];
41
- const _b = b[i];
42
- const _size = R.length(_a);
43
- let j = 0;
44
- while (_a[j] === _b[j] && j < _size) {
45
- j++;
46
- }
47
- if (_a[j] !== _b[j]) {
48
- return _a[j] - _b[j];
49
- }
50
- }
51
- else if (a[i] !== b[i]) {
52
- return a[i] - b[i];
53
- }
54
- i++;
55
- }
56
- return a[i] - b[i];
57
- };
58
-
59
- // simple call to ramda uniq method is very slow regarding performance
60
- const uniqIndexes = (indexes) => R.pipe(
61
- R.reduce(
62
- (acc, i) => {
63
- const key = R.join(':', R.unnest(i));
64
- if (R.has(key, acc.keys)) {
65
- return acc;
66
- }
67
- return ({
68
- indexes: R.append(i, acc.indexes),
69
- keys: R.assoc(key, key, acc.keys)
70
- });
71
- },
72
- { indexes: [], keys: {} },
73
- ),
74
- R.prop('indexes')
75
- )(indexes);
76
-
77
- export const getSortedLayoutIndexes = (layout, observations) => {
78
- const dimIndexes = R.pipe(R.values, R.map(R.propOr([], 'orderedDimIndexes')))(observations);
79
-
80
- const headerPivots = getLayoutPivots(layout.header);
81
- const sectionsPivots = getLayoutPivots(R.concat(layout.sections, layout.rows));
82
-
83
- const sectionLength = R.length(layout.sections);
84
- const { header, sections } = R.pipe(
85
- R.reduce(
86
- (acc, indexes) => {
87
- const headerIndexes = headerPivots(indexes);
88
- const sectionsIndexes = sectionsPivots(indexes);
89
-
90
- return ({
91
- header: R.append(headerIndexes, acc.header),
92
- sections: R.append(sectionsIndexes, acc.sections)
93
- });
94
- },
95
- { header: [], sections: [] },
96
- ),
97
- R.mapObjIndexed(uniqIndexes),
98
- R.evolve({
99
- header: R.sort(comparator),
100
- sections: R.sort(comparator)
101
- }),
102
- indexes => ({
103
- ...indexes,
104
- sections: R.reduce(
105
- (acc, i) => {
106
- const [sectionIndexes, rowIndexes] = R.splitAt(sectionLength, i);
107
- const previousSecIndexes = R.pipe(R.nth(-1), i => R.isNil(i) ? null : R.head(i))(acc);
108
- if (R.equals(R.unnest(sectionIndexes), previousSecIndexes ? R.unnest(previousSecIndexes) : null)) { //perhaps a bit dirty ...
109
- return R.over(
110
- R.lensIndex(-1),
111
- R.over(R.lensIndex(1), R.append(rowIndexes))
112
- )(acc);
113
- }
114
-
115
- return R.append([sectionIndexes, [rowIndexes]], acc);
116
- },
117
- [],
118
- indexes.sections
119
- )
120
- })
121
- )(dimIndexes);
122
-
123
- return ({ header, sections });
124
- };
@@ -1,9 +0,0 @@
1
- import * as R from 'ramda';
2
- import { combinedValuesDisplay, singleValueDisplay } from '../combinedValuesDisplay'
3
-
4
-
5
- export const getTableLabelAccessor = display => content => {
6
- return R.is(Array, content)
7
- ? combinedValuesDisplay(display, content)
8
- : singleValueDisplay(display, content);
9
- };