@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,158 +0,0 @@
1
- import * as R from 'ramda';
2
- import { isRefAreaDimension } from '@sis-cc/dotstatsuite-sdmxjs';
3
- import { SCATTER } from '../constants';
4
- import {
5
- artefactToOption,
6
- getDimensionsWithValues,
7
- getPropertyDimension,
8
- toState,
9
- } from './utils';
10
- import { focusStateFromNewProps } from './focus';
11
-
12
- const getScatterDimension = getPropertyDimension('scatterDimension');
13
-
14
- const toScatterState = (dim, xVal, yVal) => ({
15
- scatterDimension: toState(dim),
16
- scatterX: toState(xVal),
17
- scatterY: toState(yVal),
18
- });
19
-
20
- export const toScatterSingularity = (state) => ({
21
- id: R.prop('scatterDimension', state),
22
- xId: R.prop('scatterX', state),
23
- yId: R.prop('scatterY', state),
24
- });
25
-
26
- export const isScatter = (type) => type === SCATTER;
27
-
28
- export const scatterValueOptions = ({ data, type, display }, state) => {
29
- if (!isScatter(type)) {
30
- return [];
31
- }
32
- const scatterDimension = getScatterDimension(data, state);
33
- if (R.isNil(scatterDimension)) {
34
- return [];
35
- }
36
- return R.map(
37
- artefactToOption(display),
38
- R.prop('values', scatterDimension)
39
- );
40
- };
41
-
42
- export const onChangeScatterDim = (props, state) => (value) => {
43
- const { data } = props;
44
- const dimension = getScatterDimension(data, { scatterDimension: value });
45
- if (R.isNil(dimension)) {
46
- return ({});
47
- }
48
-
49
- const [xVal, yVal] = R.take(2, R.prop('values', dimension));
50
-
51
- const newScatterState = toScatterState(dimension, xVal, yVal);
52
-
53
- return ({
54
- ...newScatterState,
55
- ...focusStateFromNewProps(
56
- props,
57
- toScatterSingularity(newScatterState),
58
- state
59
- )
60
- });
61
- };
62
-
63
- export const scatterStateValueToOption = (property, props, state) => {
64
- const dimension = getScatterDimension(props.data, state);
65
- if (R.isNil(dimension) || !isScatter(props.type)) {
66
- return undefined;
67
- }
68
- const value = R.find(
69
- R.propEq('id', R.prop(property, state)),
70
- R.prop('values', dimension)
71
- );
72
- return artefactToOption(props.display)(value);
73
- };
74
-
75
- export const onChangeScatterVal = ({ data, type }, state, valKey, otherValKey) => (value) => {
76
- const options = scatterValueOptions({ data, type }, state);
77
- const [matching, otherOptions] = R.partition(R.propEq('value', value), options);
78
- if (R.isEmpty(matching)) {
79
- return ({});
80
- }
81
- const stateOtherValue = R.prop(otherValKey, state);
82
- return ({
83
- [valKey]: value,
84
- [otherValKey]: stateOtherValue === value
85
- ? R.prop('value', R.head(otherOptions))
86
- : stateOtherValue
87
- });
88
- };
89
-
90
- //----------------------------------------------------------------------------------------------------
91
-
92
- export const scatterStateFromNewProps = (props, state) => {
93
- const { data, type } = props;
94
- const undefinedState = toScatterState(undefined, undefined, undefined);
95
- if (!isScatter(type)) {
96
- return undefinedState;
97
- }
98
- if (R.isNil(data)) {
99
- return {};
100
- }
101
- const dimensions = getDimensionsWithValues(data);
102
- if (R.isEmpty(dimensions)) {
103
- return { ...undefinedState, highlight: [], baseline: [] };
104
- }
105
-
106
- let scatterDimension = getScatterDimension(props.data, state);
107
- if (R.isNil(scatterDimension)) {
108
- const refinedDimensions = R.reject(isRefAreaDimension, dimensions);
109
- scatterDimension = R.head(R.isEmpty(refinedDimensions) ? dimensions : refinedDimensions);
110
- }
111
-
112
- const values = R.prop('values', scatterDimension);
113
-
114
- const stateScatterX = R.prop('scatterX', state);
115
- let stateScatterY = R.prop('scatterY', state);
116
-
117
- if (stateScatterX === stateScatterY) {
118
- stateScatterY = undefined;
119
- }
120
-
121
- let _scatterX = undefined;
122
- let _scatterY = undefined;
123
-
124
- R.forEach(
125
- (value) => {
126
- if (R.prop('id', value) === stateScatterX) {
127
- _scatterX = value;
128
- }
129
- else if (R.prop('id', value) === stateScatterY) {
130
- _scatterY = value;
131
- }
132
- },
133
- values
134
- );
135
-
136
- //dirty as f
137
- const scatterX = R.isNil(_scatterX)
138
- ? R.head(R.reject(R.propEq('id', R.prop('id', _scatterY)), values))
139
- : _scatterX;
140
- const scatterY = R.isNil(_scatterY)
141
- ? R.head(R.reject(R.propEq('id', R.prop('id', scatterX)), values))
142
- : _scatterY;
143
-
144
- const scatterState = toScatterState(
145
- scatterDimension,
146
- scatterX,
147
- scatterY,
148
- );
149
-
150
- return ({
151
- ...scatterState,
152
- ...focusStateFromNewProps(
153
- props,
154
- toScatterSingularity(scatterState),
155
- state
156
- )
157
- });
158
- };
@@ -1,98 +0,0 @@
1
- import * as R from 'ramda';
2
- import { PERCENT, STACKED_BAR, STACKED_ROW, VALUES } from '../constants';
3
- import {
4
- getDimensionsWithValues,
5
- getGroupedDimensions,
6
- getPropertyDimension,
7
- toState
8
- } from './utils';
9
- import { splitDimensions } from '../';
10
- import { focusStateFromNewProps } from './focus';
11
-
12
- const getStackedDimension = getPropertyDimension('stackedDimension');
13
-
14
- const stackedModes = { [PERCENT]: PERCENT, [VALUES]: VALUES };
15
-
16
- export const isStacked = (type) => type === STACKED_BAR || type === STACKED_ROW;
17
-
18
- const toStackedState = (dimension, mode) => ({
19
- stackedDimension: toState(dimension),
20
- stackedMode: mode,
21
- });
22
-
23
- export const toStackedSingularity = (state) => ({
24
- id: R.prop('stackedDimension', state),
25
- mode: R.prop('stackedMode', state),
26
- limit: 5
27
- });
28
-
29
- export const onChangeStackedDimension = ({ data }, state) => (value) => {
30
- const dimension = getStackedDimension(data, { stackedDimension: value });
31
- if (R.isNil(dimension)) {
32
- return ({});
33
- }
34
- return ({
35
- stackedDimension: toState(dimension),
36
- highlight: [],
37
- baseline: [],
38
- })
39
- };
40
-
41
- export const stackedModeOptions = [{ value: VALUES }, { value: PERCENT }];
42
-
43
- export const isStackedDimActive = ({ data, type }) => {
44
- const { values } = splitDimensions(data);
45
- if (R.length(values) < 2) {
46
- return false;
47
- }
48
- return isStacked(type);
49
- };
50
-
51
- export const onChangeStackedMode = (value) => R.has(value, stackedModes)
52
- ? ({ stackedMode: value })
53
- : ({});
54
-
55
- export const stackedStateFromNewProps = (props, state) => {
56
- const { data, type } = props;
57
- if (!isStacked(type)) {
58
- return toStackedState(undefined, undefined);
59
- }
60
- if (R.isNil(data)) {
61
- return {};
62
- }
63
- const dimensions = getDimensionsWithValues(data);
64
- if (R.isEmpty(dimensions)) {
65
- return { ...toStackedState(undefined, undefined), baseline: [], highlight: [] };
66
- }
67
-
68
- let dimension = getStackedDimension(data, state);
69
- if (R.isNil(dimension)) {
70
- const { value, values } = splitDimensions(data);
71
- if (R.length(values) === 1) {
72
- dimension = R.head(value);
73
- }
74
- else {
75
- const { area, time, other } = getGroupedDimensions(data);
76
- if (!R.isNil(area) && !R.isEmpty(area)) {
77
- dimension = R.head(area);
78
- }
79
- else if (!R.isNil(time) && !R.isEmpty(time)) {
80
- dimension = R.head(time)
81
- }
82
- else {
83
- dimension = R.head(other);
84
- }
85
- }
86
- }
87
- const _mode = R.prop('stackedMode', state);
88
- const mode = R.has(_mode, stackedModes) ? _mode : VALUES;
89
- const stackedState = toStackedState(dimension, mode);
90
- return ({
91
- ...stackedState,
92
- ...focusStateFromNewProps(
93
- props,
94
- toStackedSingularity(stackedState),
95
- state
96
- )
97
- });
98
- }
@@ -1,79 +0,0 @@
1
- import * as R from 'ramda';
2
- import { extractSdmxArtefacts } from '../';
3
- import { H_SYMBOL, V_SYMBOL } from '../constants';
4
- import {
5
- getDimensionsWithValues,
6
- getGroupedDimensions,
7
- getPropertyDimension,
8
- toState
9
- } from './utils';
10
- import { focusStateFromNewProps } from './focus';
11
-
12
- const getSymbolDimension = getPropertyDimension('symbolDimension');
13
-
14
- export const isSymbol = (type) => (type === H_SYMBOL || type === V_SYMBOL);
15
-
16
- const toSymbolState = (dimension) => ({
17
- symbolDimension: toState(dimension)
18
- });
19
-
20
- export const toSymbolSingularity = (data, state) => {
21
- const symbolDimension = getSymbolDimension(data, state);
22
- const res = ({
23
- id: R.isNil(symbolDimension) ? undefined : R.prop('id', symbolDimension),
24
- serie: R.pipe(
25
- R.prop('values'),
26
- values => R.isNil(values) ? [] : values,
27
- R.take(5)
28
- )(symbolDimension),
29
- });
30
- return res;
31
- };
32
-
33
- export const symbolStateFromNewProps = (props, state) => {
34
- const { data, type } = props;
35
- if (!isSymbol(type)) {
36
- return toSymbolState(undefined);
37
- }
38
- if (R.isNil(data)) {
39
- return {};
40
- }
41
- const dimensions = getDimensionsWithValues(data);
42
- if (R.isEmpty(dimensions)) {
43
- return { ...toSymbolState(undefined), baseline: [], highlight: [] };
44
- }
45
- let symbolDimension = getSymbolDimension(data, state);
46
- if (R.isNil(symbolDimension)) {
47
- const { area, other, time } = getGroupedDimensions(data);
48
- if (!R.isNil(other) && !R.isEmpty(other)) {
49
- symbolDimension = R.head(other);
50
- }
51
- else if (!R.isNil(time) && !R.isEmpty(time)) {
52
- symbolDimension = R.head(time);
53
- }
54
- else {
55
- symbolDimension = R.head(area);
56
- }
57
- }
58
- const symbolState = toSymbolState(symbolDimension);
59
- return ({
60
- ...symbolState,
61
- ...focusStateFromNewProps(
62
- props,
63
- toSymbolSingularity(data, symbolState),
64
- state
65
- )
66
- });
67
- };
68
-
69
- export const onChangeSymbolDim = ({ data }) => (option) => {
70
- const dimension = getSymbolDimension(data, { symbolDimension: option });
71
- if (R.isNil(dimension)) {
72
- return ({});
73
- }
74
- return ({
75
- ...toSymbolState(dimension),
76
- highlight: [],
77
- baseline: [],
78
- });
79
- };
@@ -1,110 +0,0 @@
1
- import {
2
- equals,
3
- find,
4
- groupBy,
5
- has,
6
- head,
7
- is,
8
- isNil,
9
- length,
10
- map,
11
- not,
12
- omit,
13
- pipe,
14
- prop,
15
- propEq,
16
- } from 'ramda';
17
- import { isRefAreaDimension, isTimePeriodDimension } from '@sis-cc/dotstatsuite-sdmxjs';
18
- import { extractSdmxArtefacts, parseDisplay, splitDimensions } from '../';
19
- import { CHORO, STACKED_BAR, STACKED_ROW, TYPES } from '../constants';
20
- import { dimensionValueDisplay } from '../dimension-utils';
21
-
22
- export const isNumber = (input) => {
23
- const value = Number(input);
24
- return not(isNil(value) || isNaN(value));
25
- };
26
-
27
- export const isPositiveNumber = (input) => {
28
- return (isNumber(input) && Number(input) >= 0);
29
- };
30
-
31
- export const isNaturalInt = value => isNil(value) || /^\d+$/.test(String(value));
32
-
33
- export const isInt = value => isNil(value) || /^-?\d+$/.test(String(value));
34
-
35
- export const isChart = (type) => has(type, TYPES);
36
-
37
- export const hasFocus = (type) => has(type, omit([CHORO], TYPES));
38
-
39
- export const getDimensionsWithValues = (data) => pipe(
40
- splitDimensions,
41
- prop('values'),
42
- )(data);
43
-
44
- export const toState = (artefact) => prop('id', artefact);
45
-
46
- export const getPropertyDimension = (property) => (data, state) => {
47
- const statePropertyDimensionId = prop(property, state);
48
- const { dimensions } = extractSdmxArtefacts(data);
49
- return find(
50
- propEq('id', statePropertyDimensionId),
51
- dimensions
52
- );
53
- };
54
-
55
- export const getGroupedDimensions = pipe(
56
- getDimensionsWithValues,
57
- groupBy(
58
- dimension => {
59
- if (isRefAreaDimension(dimension)) {
60
- return 'area';
61
- }
62
- if (isTimePeriodDimension(dimension)) {
63
- return 'time';
64
- }
65
- return 'other';
66
- }
67
- )
68
- );
69
-
70
- export const optionParser = option => pipe(
71
- option => is(Array, option) ? head(option) : option,
72
- option => is(Object, option) ? prop('value', option) : option,
73
- option => is(String, option) ? option : undefined
74
- )(option);
75
-
76
- export const optionsParser = selection => pipe(
77
- selection => is(Array, selection) ? selection : [selection],
78
- selection => map(optionParser, selection)
79
- )(selection);
80
-
81
- export const artefactToOption = (display) => (artefact) => isNil(artefact)
82
- ? undefined
83
- : {
84
- label: dimensionValueDisplay(parseDisplay(display))(artefact),
85
- value: prop('id', artefact)
86
- };
87
-
88
- export const dimensionWithValuesToOptions = ({ data, display }) => pipe(
89
- getDimensionsWithValues,
90
- map(artefactToOption(display))
91
- )(data);
92
-
93
- export const chartDimensionToOption = (property) => ({ data, display }, state) => pipe(
94
- getPropertyDimension(property),
95
- artefactToOption(display)
96
- )(data, state);
97
-
98
- export const chartDimensionOptions = ({ data, type, display }, typeValidator) => {
99
- if (!typeValidator(type)) {
100
- return [];
101
- }
102
- const dimensions = prop('values', splitDimensions(data));
103
- if ((equals(type, STACKED_BAR) || equals(type, STACKED_ROW)) && length(dimensions) === 1) {
104
- return [];
105
- }
106
- return map(
107
- artefactToOption(display),
108
- dimensions
109
- );
110
- };
@@ -1,39 +0,0 @@
1
- import * as R from 'ramda';
2
-
3
- export const LAYOUT_ROW = 'LAYOUT_ROW';
4
- export const LAYOUT_COLUMN = 'LAYOUT_COLUMN';
5
- export const LAYOUT_ROW_SECTION = 'LAYOUT_ROW_SECTION';
6
-
7
- const ROWS = 'rows';
8
- const HEADER = 'header';
9
- const SECTIONS = 'sections';
10
-
11
- const ORDER = 'ORDER';
12
- const NOT_DISPLAYED = 'NOT_DISPLAYED';
13
-
14
- const getType = R.propOr({}, 'type');
15
- const getIds = (stringIds = '') => R.pipe(
16
- R.append(R.split(',', stringIds)),
17
- R.flatten
18
- );
19
- const getPivot = (key, stringIds) => R.over(R.lensProp(key), getIds(stringIds));
20
-
21
- export const setAnnotationsLayout = (stringIds, layout) => R.reduce((acc, annotation) => {
22
- if (R.equals(getType(annotation), LAYOUT_ROW)) return getPivot(ROWS, stringIds)(acc);
23
- if (R.equals(getType(annotation), LAYOUT_COLUMN)) return getPivot(HEADER, stringIds)(acc);
24
- if (R.equals(getType(annotation), LAYOUT_ROW_SECTION)) return getPivot(SECTIONS, stringIds)(acc);
25
- return acc;
26
- }, layout);
27
-
28
- export const getRelationnalAnnotations = annotationIndexes => annotations => R.map(annotationIndex =>
29
- R.propOr({}, annotationIndex)(annotations)
30
- )(annotationIndexes);
31
-
32
- export const hiddenFormat = { isHidden: true }
33
-
34
- export const getIsHidden = annotations => R.pipe(
35
- R.find(R.propEq('type', NOT_DISPLAYED)),
36
- R.complement(R.isNil)
37
- )(annotations);
38
-
39
- export const getFullName = R.identity;
@@ -1,50 +0,0 @@
1
- import * as R from 'ramda';
2
- import numeral from 'numeral';
3
-
4
- const isValidNumber = R.both(R.is(Number), R.complement(R.equals(NaN)));
5
-
6
- export const getCellValue = (observation) => {
7
- const value = R.prop('value', observation);
8
- if (R.is(Boolean, value)) {
9
- return value;
10
- }
11
- if (R.is(String, value)) {
12
- const monthMatch = value.match(/^\-\-([\d]{2})$/);
13
- if (R.is(Array, monthMatch)) {
14
- return R.nth(1, monthMatch);
15
- }
16
- const monthDayMatch = value.match(/^\-\-([\d]{2}\-[\d]{2})$/);
17
- if (R.is(Array, monthDayMatch)) {
18
- return R.nth(1, monthDayMatch);
19
- }
20
- const dayMatch = value.match(/^\-\-\-([\d]{2})$/);
21
- if (R.is(Array, dayMatch)) {
22
- return R.nth(1, dayMatch);
23
- }
24
- return value;
25
- }
26
- const scale = Number(observation.prefscale);
27
- const formatScale = R.ifElse(
28
- R.always(isValidNumber(scale)),
29
- value => numeral(value).multiply(Math.pow(10, -1 * Number(scale))).value(),
30
- R.identity
31
- );
32
- const formatSeparator = value => numeral(value).format(`0,0.[0000000]`);
33
- const decimals = Number(observation.decimals);
34
- const formatDecimals = R.ifElse(
35
- R.always(isValidNumber(decimals)),
36
- value => numeral(value).format(
37
- R.ifElse(R.equals(0), R.always('0,0'), d => `0,0.${R.join('', R.times(R.always('0'), d))}`)(decimals)
38
- ),
39
- formatSeparator
40
- );
41
- const res = R.ifElse(
42
- isValidNumber,
43
- R.pipe(
44
- formatScale,
45
- formatDecimals,
46
- ),
47
- R.always('..')
48
- )(observation.value);
49
- return res;
50
- };
@@ -1 +0,0 @@
1
- export { getCellValue } from './factories/getCellValue';