@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,50 +0,0 @@
1
- import { expect } from 'chai';
2
- import { getTableLabelAccessor } from '../src/rules2/src/table/getTableLabelAccessor';
3
-
4
- describe('getTableLabelAccessor tests', () => {
5
- const values = [
6
- { id: 'V0', name: 'Value 0', display: false },
7
- { id: 'V1', name: 'Value 1', missingParents: [{ id: 'P0', name: 'Parent 0' }, { id: 'P1', name: 'Parent 1', display: false }] },
8
- { id: '_T', name: 'Value 2' },
9
- ];
10
- it('combination label display', () => {
11
- expect(getTableLabelAccessor('label')(values)).to.deep.equal('Parent 0 > Value 1');
12
- });
13
- it('combination code display', () => {
14
- expect(getTableLabelAccessor('code')(values)).to.deep.equal('V0, V1, _T');
15
- });
16
- it('combination both display', () => {
17
- expect(getTableLabelAccessor('both')(values)).to.deep.equal('(V0, V1, _T) Parent 0 > Value 1');
18
- });
19
- it('single value witrh missingParents', () => {
20
- expect(getTableLabelAccessor('label')(values[1])).to.deep.equal('Parent 0 > Value 1');
21
- });
22
- it('not displayed single value', () => {
23
- expect(getTableLabelAccessor('both')(values[0])).to.deep.equal('(V0) Value 0');
24
- });
25
- it('display _T label if all hidden', () => {
26
- const _values = [
27
- { id: 'v0', name: 'value 0', display: false },
28
- { id: 'v1', name: 'value 1', display: false },
29
- { id: '_T', name: 'Total' },
30
- { id: 'v3', name: 'value 3', display: false },
31
- ];
32
- expect(getTableLabelAccessor('label')(_values)).to.deep.equal('Total');
33
- expect(getTableLabelAccessor('both')(_values)).to.deep.equal('(v0, v1, _T, v3) Total');
34
- });
35
- it('display label first value if all hidden and no _T', () => {
36
- const _values = [
37
- { id: 'v0', name: 'value 0', display: false },
38
- { id: 'v1', name: 'value 1', display: false },
39
- { id: 'v2', name: 'value 2', display: false },
40
- { id: 'v3', name: 'value 3', display: false },
41
- ];
42
- expect(getTableLabelAccessor('label')(_values)).to.deep.equal('value 0');
43
- expect(getTableLabelAccessor('both')(_values)).to.deep.equal('(v0, v1, v2, v3) value 0');
44
- });
45
- it('empty case', () => {
46
- expect(getTableLabelAccessor('label')([])).to.deep.equal('');
47
- expect(getTableLabelAccessor('code')([])).to.deep.equal('');
48
- expect(getTableLabelAccessor('both')([])).to.deep.equal('');
49
- });
50
- });
@@ -1,356 +0,0 @@
1
- import { expect } from 'chai';
2
- import { injectCombinationsInLayout, getTableLayoutIds } from '../src/rules2/src/table/getTableLayoutIds';
3
-
4
- describe('injectCombinationsInLayout', () => {
5
- it('no combinations', () => {
6
- const layoutIds = {
7
- header: ['D1'],
8
- sections: ['D2'],
9
- rows: ['D3']
10
- };
11
- const combinations = [];
12
- expect(injectCombinationsInLayout(combinations, layoutIds)).to.deep.equal({
13
- header: ['D1'],
14
- sections: ['D2'],
15
- rows: ['D3']
16
- });
17
- });
18
- it('partial start', () => {
19
- const layoutIds = {
20
- header: ['D1', 'C1', 'D2'],
21
- sections: ['C5', 'D5', 'D3'],
22
- rows: ['D4']
23
- };
24
-
25
- const combinations = [
26
- { id: 'C1', concepts: ['D0', 'A2'], relationship: ['D0'] }, // already in header
27
- { id: 'C2', concepts: ['D1', 'D2', 'A1'], relationship: ['D1', 'D2', 'D0'] }, // concepts are in header and relate to one of C1 concepts
28
- { id: 'C3', concepts: ['D1', 'D2', 'D3'], relationship: ['D1', 'D2', 'D3'] }, // concepts both in header & sections -> rejected
29
- { id: 'C4', concepts: ['D1', 'D2', 'D4'], relationship: ['D1', 'D2', 'D4'] }, // concepts both in header & rows -> rejected
30
- { id: 'C5', concepts: ['D6', 'D7'], relationship: ['D6', 'D7', 'D5'] }, // already in sections
31
- { id: 'C6', concepts: ['D3', 'D5'], relationship: ['D3', 'D5', 'D7'] }, // concepts in sections and relate to one C5 concept
32
- { id: 'C7', concepts: ['D3', 'D8'], relationship: ['D3', 'D8'] }, // partial concepts in sections, none in rows
33
- { id: 'C8', concepts: ['A1', 'A2', 'D9'], relationship: ['D0', 'D9'] }, // partial concepts in header nothing elsewhere
34
- { id: 'C9', concepts: ['A3', 'D10', 'D11', 'D12'], relationship: ['D10', 'D11', 'D12'] }, // all new concepts
35
- { id: 'C10', concepts: ['D10', 'D8'], relationship: ['D10', 'D8'] }, // relates to one concept of C7 and to one of C9
36
- ];
37
-
38
- expect(injectCombinationsInLayout(combinations, layoutIds)).to.deep.equal({
39
- header: ['C2', 'C1', 'C8'],
40
- sections: ['C5', 'C6', 'C7'],
41
- rows: ['D4', 'C9', 'C10']
42
- });
43
- });
44
- });
45
-
46
- describe('getTableLayoutIds tests', () => {
47
- it('simple case blank start', () => {
48
- const defaultLayoutIds = {
49
- header: [],
50
- sections: [],
51
- rows: []
52
- };
53
- const layoutIds = {
54
- header: [],
55
- sections: [],
56
- rows: []
57
- };
58
- const combinations = [];
59
- const attributes = [];
60
- const dimensions = [
61
- { id: 'REF_AREA' },
62
- { id: 'MEASURE' },
63
- { id: 'REF_SECTOR' },
64
- { id: 'TIME_PERIOD' },
65
- ];
66
-
67
- expect(getTableLayoutIds(defaultLayoutIds, layoutIds, dimensions, attributes, combinations)).to.deep.equal({
68
- header: ['TIME_PERIOD'],
69
- sections: ['MEASURE', 'REF_SECTOR'],
70
- rows: ['REF_AREA']
71
- });
72
- });
73
- it('blank start with combinations', () => {
74
- const defaultLayoutIds = {
75
- header: [],
76
- sections: [],
77
- rows: []
78
- };
79
- const layoutIds = {
80
- header: [],
81
- sections: ['COMB1'],
82
- rows: []
83
- };
84
- const combinations = [
85
- {
86
- id: 'COMB1',
87
- concepts: ['REF_SECTOR', 'MEASURE'],
88
- },
89
- {
90
- id: 'COMB2',
91
- concepts: ['UNIT_MEASURE', 'CURRENCY'],
92
- },
93
- {
94
- id: 'COMB3',
95
- concepts: ['ATTR1', 'ATTR2'],
96
- },
97
- {
98
- id: 'COMB4',
99
- concepts: ['ATTR3', 'ATTR4']
100
- }
101
- ];
102
- const dimensions = [
103
- { id: 'REF_AREA' },
104
- { id: 'REF_SECTOR' },
105
- { id: 'TRANSACTION' },
106
- { id: 'MEASURE' },
107
- { id: 'UNIT_MEASURE' },
108
- { id: 'CURRENCY' }
109
- ];
110
- const attributes = [
111
- { id: 'ATTR1', relationship: ['MEASURE'], series: true },
112
- { id: 'ATTR2', relationship: ['MEASURE'], series: true },
113
- { id: 'ATTR3', relationship: [], series: true },
114
- { id: 'ATTR4', relationship: [], series: true },
115
- ];
116
-
117
- expect(getTableLayoutIds(defaultLayoutIds, layoutIds, dimensions, attributes, combinations)).to.deep.equal({
118
- header: ['TRANSACTION'],
119
- sections: ['COMB1', 'COMB3'],
120
- rows: ['COMB2', 'REF_AREA']
121
- });
122
- });
123
- it('nothing in rows 2', () => {
124
- const combinations = [];
125
- const attributes = [];
126
- const dimensions = [
127
- { id: 'D1', header: true },
128
- { id: 'D2' },
129
- { id: 'D3', header: true }
130
- ];
131
- const layoutIds = {
132
- sections: ['D1'],
133
- header: ['D2'],
134
- rows: ['D3']
135
- };
136
- const defaultLayoutIds = {
137
- header: [],
138
- sections: [],
139
- rows: []
140
- };
141
-
142
- expect(getTableLayoutIds(defaultLayoutIds, layoutIds, dimensions, attributes, combinations)).to.deep.equal({
143
- header: [],
144
- sections: [],
145
- rows: ['D2']
146
- });
147
- });
148
- it('nothing in rows with combinations', () => {
149
- const combinations = [
150
- {
151
- id: 'COMB1',
152
- concepts: ['D1', 'D2']
153
- },
154
- {
155
- id: 'COMB2',
156
- concepts: ['A1', 'A2']
157
- },
158
- ];
159
- const attributes = [
160
- { id: 'A1', series: true, relationship: ['D1', 'D2'] },
161
- { id: 'A2', series: true, relationship: ['D1', 'D2'] },
162
- ];
163
- const dimensions = [
164
- { id: 'D1' },
165
- { id: 'D2' },
166
- { id: 'D3' }
167
- ];
168
- const layoutIds = {
169
- sections: ['D1', 'D2'],
170
- header: ['D3'],
171
- rows: []
172
- };
173
- const defaultLayoutIds = {
174
- header: [],
175
- sections: [],
176
- rows: []
177
- };
178
-
179
- expect(getTableLayoutIds(defaultLayoutIds, layoutIds, dimensions, attributes, combinations)).to.deep.equal({
180
- header: ['D3'],
181
- sections: [],
182
- rows: ['COMB1', 'COMB2']
183
- });
184
- });
185
- it('nothing in rows with combinations 2', () => {
186
- const combinations = [
187
- {
188
- id: 'COMB1',
189
- concepts: ['D1', 'D2']
190
- },
191
- {
192
- id: 'COMB2',
193
- concepts: ['A1', 'A2']
194
- },
195
- ];
196
- const attributes = [
197
- { id: 'A1', series: true, relationship: ['D1', 'D2'] },
198
- { id: 'A2', series: true, relationship: ['D1', 'D2'] },
199
- ];
200
- const dimensions = [
201
- { id: 'D1' },
202
- { id: 'D2' },
203
- { id: 'D3' },
204
- { id: 'D4' }
205
- ];
206
- const defaultLayoutIds = {
207
- header: [],
208
- sections: [],
209
- rows: []
210
- };
211
- const layoutIds1 = {
212
- sections: ['COMB1', 'D4', 'COMB2'],
213
- header: ['D3'],
214
- rows: []
215
- };
216
- const layoutIds2 = {
217
- sections: ['D4', 'COMB1', 'COMB2'],
218
- header: ['D3'],
219
- rows: []
220
- };
221
- const layoutIds3 = {
222
- sections: ['COMB2', 'COMB1', 'D4'],
223
- header: ['D3'],
224
- rows: []
225
- };
226
- const layoutIds4 = {
227
- sections: ['COMB1', 'COMB2'],
228
- header: ['D3'],
229
- rows: []
230
- };
231
- expect(getTableLayoutIds(defaultLayoutIds, layoutIds1, dimensions, attributes, combinations)).to.deep.equal({
232
- header: ['D3'],
233
- sections: ['D4'],
234
- rows: ['COMB1', 'COMB2']
235
- });
236
- expect(getTableLayoutIds(defaultLayoutIds, layoutIds2, dimensions, attributes, combinations)).to.deep.equal({
237
- header: ['D3'],
238
- sections: ['COMB1', 'COMB2'],
239
- rows: ['D4']
240
- });
241
- expect(getTableLayoutIds(defaultLayoutIds, layoutIds3, dimensions, attributes, combinations)).to.deep.equal({
242
- header: ['D3'],
243
- sections: ['D4'],
244
- rows: ['COMB2', 'COMB1']
245
- });
246
- expect(getTableLayoutIds(defaultLayoutIds, layoutIds4, dimensions, attributes, combinations)).to.deep.equal({
247
- header: ['D3'],
248
- sections: ['COMB1', 'COMB2'],
249
- rows: ['D4']
250
- });
251
- });
252
- it('nothing in rows with combination without dimensions', () => {
253
- const combinations = [{
254
- id: 'COMB',
255
- concepts: ['A1', 'A2']
256
- }];
257
- const attributes = [
258
- { id: 'A1', series: true, relationship: ['D1'] },
259
- { id: 'A2', series: true, relationship: ['D1'] },
260
- ]
261
- const dimensions = [
262
- { id: 'D1' },
263
- { id: 'D2' },
264
- ];
265
- const defaultLayoutIds = {
266
- header: [],
267
- sections: [],
268
- rows: []
269
- };
270
- const layoutIds = {
271
- header: ['D2'],
272
- sections: ['COMB', 'D1'],
273
- rows: ['D3']
274
- };
275
- expect(getTableLayoutIds(defaultLayoutIds, layoutIds, dimensions, attributes, combinations)).to.deep.equal({
276
- header: ['D2'],
277
- sections: [],
278
- rows: ['COMB', 'D1']
279
- });
280
- });
281
- it('combinations and default layout definition', () => {
282
- const defaultLayoutIds = {
283
- header: ['MEASURE', 'REF_AREA'],
284
- sections: ['COMB2', 'COMB3'],
285
- rows: []
286
- };
287
- const combinations = [
288
- {
289
- id: 'COMB1',
290
- concepts: ['REF_SECTOR', 'MEASURE'],
291
- },
292
- {
293
- id: 'COMB2',
294
- concepts: ['UNIT_MEASURE', 'CURRENCY'],
295
- },
296
- {
297
- id: 'COMB3',
298
- concepts: ['ATTR1', 'ATTR2'],
299
- },
300
- {
301
- id: 'COMB4',
302
- concepts: ['ATTR3', 'ATTR4']
303
- }
304
- ];
305
- const dimensions = [
306
- { id: 'REF_AREA' },
307
- { id: 'REF_SECTOR' },
308
- { id: 'TRANSACTION' },
309
- { id: 'MEASURE' },
310
- { id: 'UNIT_MEASURE' },
311
- { id: 'CURRENCY' }
312
- ];
313
- const attributes = [
314
- { id: 'ATTR1', relationship: ['MEASURE'], series: true },
315
- { id: 'ATTR2', relationship: ['MEASURE'], series: true },
316
- { id: 'ATTR3', relationship: [], series: true },
317
- { id: 'ATTR4', relationship: [], series: true },
318
- ];
319
-
320
- const layoutIds1 = {
321
- header: [],
322
- sections: [],
323
- rows: []
324
- };
325
-
326
- const layoutIds2 = {
327
- header: ['TRANSACTION'],
328
- sections: ['REF_AREA'],
329
- rows: []
330
- };
331
-
332
- const layoutIds3 = {
333
- header: [],
334
- sections: ['MEASURE'],
335
- rows: []
336
- }
337
-
338
- expect(getTableLayoutIds(defaultLayoutIds, layoutIds1, dimensions, attributes, combinations)).to.deep.equal({
339
- header: ['COMB1', 'REF_AREA', 'COMB3',],
340
- sections: ['COMB2'],
341
- rows: ['TRANSACTION']
342
- });
343
-
344
- expect(getTableLayoutIds(defaultLayoutIds, layoutIds2, dimensions, attributes, combinations)).to.deep.equal({
345
- header: ['TRANSACTION', 'COMB1', 'COMB3'],
346
- sections: ['COMB2'],
347
- rows: ['REF_AREA']
348
- });
349
-
350
- expect(getTableLayoutIds(defaultLayoutIds, layoutIds3, dimensions, attributes, combinations)).to.deep.equal({
351
- header: ['REF_AREA'],
352
- sections: ['COMB1', 'COMB2', 'COMB3'],
353
- rows: ['TRANSACTION']
354
- });
355
- });
356
- });
@@ -1,109 +0,0 @@
1
- import { expect } from 'chai';
2
- import { hierarchiseDimensionWithNativeHierarchy } from '../src/rules2/src/hierarchiseDimensionWithNativeHierarchy2';
3
-
4
- describe('hierarchiseDimensionWithNativeHierarchy tests', () => {
5
- it('basic test', () => {
6
- const dimension = {
7
- id: 'test',
8
- values: [
9
- { id: 'FRA', parent: 'EA', __indexPosition: 101, isSelected: true },
10
- { id: 'GER', parent: 'EA', __indexPosition: 100, isSelected: true },
11
- { id: 'EA', parent: 'W', __indexPosition: 30, isSelected: true },
12
- { id: 'A', parent: 'W', __indexPosition: 20, isSelected: true },
13
- { id: 'W', parent: undefined, __indexPosition: 5, isSelected: true },
14
- { id: 'CHI', parent: undefined, __indexPosition: 0, isSelected: true }
15
- ]
16
- };
17
-
18
- const expected = {
19
- id: 'test',
20
- values: [
21
- { id: 'CHI', parent: undefined, parents: [], __indexPosition: 0, isSelected: true },
22
- { id: 'W', parent: undefined, parents: [], __indexPosition: 1, isSelected: true },
23
- { id: 'A', parent: 'W', parents: [1], __indexPosition: 2, isSelected: true },
24
- { id: 'EA', parent: 'W', parents: [1], __indexPosition: 3, isSelected: true },
25
- { id: 'GER', parent: 'EA', parents: [1, 3], __indexPosition: 4, isSelected: true },
26
- { id: 'FRA', parent: 'EA', parents: [1, 3], __indexPosition: 5, isSelected: true }
27
- ]
28
- };
29
-
30
- expect(hierarchiseDimensionWithNativeHierarchy(dimension)).to.deep.equal(expected);
31
- });
32
- it ('missing parent test', () => {
33
- const dimension = {
34
- id: 'test',
35
- values: [
36
- { id: 'FRA', parent: 'EA', __indexPosition: 101, isSelected: true },
37
- { id: 'GER', parent: 'EA', __indexPosition: 100, isSelected: true },
38
- { id: 'EA', parent: 'W', __indexPosition: 30, isSelected: true },
39
- { id: 'A', parent: 'W', __indexPosition: 20, isSelected: true },
40
- { id: 'CHI', parent: undefined, __indexPosition: 0, isSelected: true }
41
- ]
42
- };
43
-
44
- const expected = {
45
- id: 'test',
46
- values: [
47
- { id: 'CHI', parent: undefined, parents: [], __indexPosition: 0, isSelected: true },
48
- { id: 'A', parent: undefined, parents: [], __indexPosition: 1, isSelected: true },
49
- { id: 'EA', parent: undefined, parents: [], __indexPosition: 2, isSelected: true },
50
- { id: 'GER', parent: 'EA', parents: [2], __indexPosition: 3, isSelected: true },
51
- { id: 'FRA', parent: 'EA', parents: [2], __indexPosition: 4, isSelected: true }
52
- ]
53
- };
54
-
55
- expect(hierarchiseDimensionWithNativeHierarchy(dimension)).to.deep.equal(expected);
56
- });
57
- it ('empty id', () => {
58
- const dimension = {
59
- id: 'test',
60
- values: [
61
- { id: '', parent: '', __indexPosition: 101, isSelected: true },
62
- { id: 'GER', parent: 'EA', __indexPosition: 100, isSelected: true },
63
- { id: 'EA', parent: 'W', __indexPosition: 30, isSelected: true },
64
- { id: 'A', parent: 'W', __indexPosition: 20, isSelected: true },
65
- { id: 'CHI', parent: undefined, __indexPosition: 0, isSelected: true }
66
- ]
67
- };
68
-
69
- const expected = {
70
- id: 'test',
71
- values: [
72
- { id: 'CHI', parent: undefined, parents: [], __indexPosition: 0, isSelected: true },
73
- { id: 'A', parent: undefined, parents: [], __indexPosition: 1, isSelected: true },
74
- { id: 'EA', parent: undefined, parents: [], __indexPosition: 2, isSelected: true },
75
- { id: 'GER', parent: 'EA', parents: [2], __indexPosition: 3, isSelected: true },
76
- { id: '', parent: undefined, parents: [], __indexPosition: 4, isSelected: true }
77
- ]
78
- };
79
-
80
- expect(hierarchiseDimensionWithNativeHierarchy(dimension)).to.deep.equal(expected);
81
- });
82
- it('non selected parent', () => {
83
- const dimension = {
84
- id: 'test',
85
- values: [
86
- { id: 'FRA', parent: 'EA', __indexPosition: 101, isSelected: true },
87
- { id: 'GER', parent: 'EA', __indexPosition: 100, isSelected: true },
88
- { id: 'EA', parent: 'W', __indexPosition: 30, isSelected: false },
89
- { id: 'A', parent: 'W', __indexPosition: 20, isSelected: true },
90
- { id: 'W', parent: undefined, __indexPosition: 5, isSelected: true },
91
- { id: 'CHI', parent: undefined, __indexPosition: 0, isSelected: true }
92
- ]
93
- };
94
-
95
- const expected = {
96
- id: 'test',
97
- values: [
98
- { id: 'CHI', parent: undefined, parents: [], __indexPosition: 0, isSelected: true },
99
- { id: 'W', parent: undefined, parents: [], __indexPosition: 1, isSelected: true },
100
- { id: 'A', parent: 'W', parents: [1], __indexPosition: 2, isSelected: true },
101
- { id: 'EA', parent: 'W', parents: [1], __indexPosition: 3, isSelected: false },
102
- { id: 'GER', parent: 'EA', parents: [1], __indexPosition: 4, isSelected: true },
103
- { id: 'FRA', parent: 'EA', parents: [1], __indexPosition: 5, isSelected: true }
104
- ]
105
- };
106
-
107
- expect(hierarchiseDimensionWithNativeHierarchy(dimension)).to.deep.equal(expected);
108
- })
109
- });
@@ -1,102 +0,0 @@
1
- import { expect } from 'chai';
2
- import { isSharedLayoutCompatible } from '../src/rules/src/layout';
3
-
4
- const sdmxData = {
5
- structure: {
6
- dimensions: {
7
- observation: [
8
- { id: 'd0', values: [{ id: 'v1' }, { id: 'v2' }] },
9
- { id: 'd1', values: [{ id: 'v1' }, { id: 'v2' }, { id: 'v3' }] },
10
- { id: 'd2', values: [{ id: 'v1' }, { id: 'v2' }] },
11
- { id: 'd3', values: [{ id: 'v1' }] },
12
- { id: 'd4', values: [] },
13
- ]
14
- },
15
- }
16
- }
17
- const sdmxData2 = {
18
- structure: {
19
- dimensions: {
20
- observation: [
21
- { id: 'd0', values: [{ id: 'v1' }, { id: 'v2' }] },
22
- { id: 'd1', values: [{ id: 'v1' }, { id: 'v2' }, { id: 'v3' }] },
23
- { id: 'd2', values: [{ id: 'v1' }, { id: 'v2' }] },
24
- { id: 'd3', values: [{ id: 'v1' }] },
25
- { id: 'd4', values: [] },
26
- ]
27
- },
28
- annotations: [
29
- {
30
- title: "d6:d1,d3,d4",
31
- type: "COMBINED_CONCEPTS",
32
- text: "d6:Combined unit of measure",
33
- texts: {
34
- en: "d6:Combined unit of measure"
35
- }
36
- }
37
- ]
38
- }
39
- }
40
-
41
- describe('isSharedLayoutCompatible', () => {
42
- it('table compatible test', () => {
43
- const layoutIds = { rows: ['d0'], sections: ['d1'], header: ['d2'] };
44
- expect(isSharedLayoutCompatible(sdmxData, { type: 'table', config: { table: { layoutIds } } })).to.equal(true);
45
- });
46
- it('table compatible test combined', () => {
47
- const layoutIds = { rows: ['d0'], sections: ['d6'], header: ['d2'] };
48
- expect(isSharedLayoutCompatible(sdmxData2, { type: 'table', config: { table: { layoutIds, locale: 'en' } } })).to.equal(true);
49
- });
50
- it('table incompatible absent dimension in multi dims test', () => {
51
- const layoutIds = { rows: ['d0', 'd3'], sections: ['d1'], header: ['d2'] };
52
- expect(isSharedLayoutCompatible(sdmxData, { type: 'table', config: { table: { layoutIds } } })).to.equal(false);
53
- });
54
- it('table incompatible absent dimension in layout test', () => {
55
- const layoutIds = { rows: [], sections: ['d1'], header: ['d2'] };
56
- expect(isSharedLayoutCompatible(sdmxData, { type: 'table', config: { table: { layoutIds } } })).to.equal(false);
57
- });
58
- it('scatter chart compatible test', () => {
59
- const chartDimension = { id: 'd0', xId: 'v1', yId: 'v2' };
60
- expect(isSharedLayoutCompatible(sdmxData, { type: 'ScatterChart', config: { chart: { chartDimension } } })).to.equal(true);
61
- });
62
- it('scatter chart incompatible absent axis value test', () => {
63
- const chartDimension = { id: 'd0', xId: 'v1', yId: 'v3' };
64
- expect(isSharedLayoutCompatible(sdmxData, { type: 'ScatterChart', config: { chart: { chartDimension } } })).to.equal(false);
65
- });
66
- it('scatter chart incompatible wrong dimension test', () => {
67
- const chartDimension = { id: 'd3', xId: 'v1', yId: 'v2' };
68
- expect(isSharedLayoutCompatible(sdmxData, { type: 'ScatterChart', config: { chart: { chartDimension } } })).to.equal(false);
69
- });
70
- it('h symbol chart compatible test', () => {
71
- const chartDimension = { id: 'd1', serie: [{ id: 'v1' }, { id: 'v2' }, { id: 'v3'}] };
72
- expect(isSharedLayoutCompatible(sdmxData, { type: 'HorizontalSymbolChart', config: { chart: { chartDimension } } })).to.equal(true);
73
- });
74
- it('h symbol chart incompatible absent symbol value test', () => {
75
- const chartDimension = { id: 'd0', serie: [{ id: 'v1' }, { id: 'v2' }, { id: 'v3'}] };
76
- expect(isSharedLayoutCompatible(sdmxData, { type: 'HorizontalSymbolChart', config: { chart: { chartDimension } } })).to.equal(false);
77
- });
78
- it('h symbol chart incompatible absent dimension value test', () => {
79
- const chartDimension = { id: 'd5', serie: [{ id: 'v1' }, { id: 'v2' }, { id: 'v3'}] };
80
- expect(isSharedLayoutCompatible(sdmxData, { type: 'HorizontalSymbolChart', config: { chart: { chartDimension } } })).to.equal(false);
81
- });
82
- it('v symbol chart compatible test', () => {
83
- const chartDimension = { id: 'd1', serie: [{ id: 'v1' }, { id: 'v2' }, { id: 'v3'}] };
84
- expect(isSharedLayoutCompatible(sdmxData, { type: 'VerticalSymbolChart', config: { chart: { chartDimension } } })).to.equal(true);
85
- });
86
- it('v symbol chart incompatible absent symbol value test', () => {
87
- const chartDimension = { id: 'd0', serie: [{ id: 'v1' }, { id: 'v2' }, { id: 'v3'}] };
88
- expect(isSharedLayoutCompatible(sdmxData, { type: 'VerticalSymbolChart', config: { chart: { chartDimension } } })).to.equal(false);
89
- });
90
- it('v symbol chart incompatible absent dimension value test', () => {
91
- const chartDimension = { id: 'd5', serie: [{ id: 'v1' }, { id: 'v2' }, { id: 'v3'}] };
92
- expect(isSharedLayoutCompatible(sdmxData, { type: 'VerticalSymbolChart', config: { chart: { chartDimension } } })).to.equal(false);
93
- });
94
- it('stacked chart compatible test', () => {
95
- const chartDimension = { id: 'd0' };
96
- expect(isSharedLayoutCompatible(sdmxData, { type: 'StackedBarChart', config: { chart: { chartDimension } } })).to.equal(true);
97
- });
98
- it('stacked chart incompatible test', () => {
99
- const chartDimension = { id: 'd4' };
100
- expect(isSharedLayoutCompatible(sdmxData, { type: 'StackedBarChart', config: { chart: { chartDimension } } })).to.equal(false);
101
- });
102
- });