@sis-cc/dotstatsuite-components 22.6.0 → 23.0.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 (194) hide show
  1. package/dist/bridge-d3-react/src/index.js +1 -2
  2. package/dist/bridge-d3-react/src/index.js.map +1 -1
  3. package/dist/rules/src/chart/getChartOptions.js +1 -1
  4. package/dist/rules/src/chart/getChartOptions.js.map +1 -1
  5. package/dist/rules/src/constants.js +1 -35
  6. package/dist/rules/src/constants.js.map +1 -1
  7. package/dist/rules/src/dimension-utils.js +26 -24
  8. package/dist/rules/src/dimension-utils.js.map +1 -1
  9. package/dist/rules/src/factories/choro-series.js +43 -32
  10. package/dist/rules/src/factories/choro-series.js.map +1 -1
  11. package/dist/rules/src/factories/focus.js +20 -0
  12. package/dist/rules/src/factories/focus.js.map +1 -0
  13. package/dist/rules/src/factories/getChartSeries.js +11 -0
  14. package/dist/rules/src/factories/getChartSeries.js.map +1 -0
  15. package/dist/rules/src/factories/sample-focus.js +14 -18
  16. package/dist/rules/src/factories/sample-focus.js.map +1 -1
  17. package/dist/rules/src/factories/sample-series.js +20 -20
  18. package/dist/rules/src/factories/sample-series.js.map +1 -1
  19. package/dist/rules/src/factories/scatter-focus.js +21 -35
  20. package/dist/rules/src/factories/scatter-focus.js.map +1 -1
  21. package/dist/rules/src/factories/scatter-series.js +5 -5
  22. package/dist/rules/src/factories/scatter-series.js.map +1 -1
  23. package/dist/rules/src/factories/series.js +48 -0
  24. package/dist/rules/src/factories/series.js.map +1 -0
  25. package/dist/rules/src/factories/stacked-series.js +6 -7
  26. package/dist/rules/src/factories/stacked-series.js.map +1 -1
  27. package/dist/rules/src/factories/symbol-series.js +39 -46
  28. package/dist/rules/src/factories/symbol-series.js.map +1 -1
  29. package/dist/rules/src/factories/timeline-focus.js +10 -14
  30. package/dist/rules/src/factories/timeline-focus.js.map +1 -1
  31. package/dist/rules/src/factories/timeline-series.js +37 -41
  32. package/dist/rules/src/factories/timeline-series.js.map +1 -1
  33. package/dist/rules/src/get-values-enhanced.js +6 -0
  34. package/dist/rules/src/get-values-enhanced.js.map +1 -1
  35. package/dist/rules/src/index.js +6 -371
  36. package/dist/rules/src/index.js.map +1 -1
  37. package/dist/rules/src/layout.js +4 -2
  38. package/dist/rules/src/layout.js.map +1 -1
  39. package/dist/rules/src/observation-formater.js +8 -14
  40. package/dist/rules/src/observation-formater.js.map +1 -1
  41. package/dist/rules/src/properties/focus.js +51 -3
  42. package/dist/rules/src/properties/focus.js.map +1 -1
  43. package/dist/rules/src/properties/getHeaderProps.js +2 -53
  44. package/dist/rules/src/properties/getHeaderProps.js.map +1 -1
  45. package/dist/rules/src/properties/index.js +3 -94
  46. package/dist/rules/src/properties/index.js.map +1 -1
  47. package/dist/rules/src/properties/linear.js +4 -4
  48. package/dist/rules/src/properties/linear.js.map +1 -1
  49. package/dist/rules/src/properties/scatter.js +4 -4
  50. package/dist/rules/src/properties/scatter.js.map +1 -1
  51. package/dist/rules/src/properties/stacked.js +5 -7
  52. package/dist/rules/src/properties/stacked.js.map +1 -1
  53. package/dist/rules/src/properties/symbol.js.map +1 -1
  54. package/dist/rules/src/properties/utils.js +11 -12
  55. package/dist/rules/src/properties/utils.js.map +1 -1
  56. package/dist/rules/src/sdmx-data/index.js +2 -27
  57. package/dist/rules/src/sdmx-data/index.js.map +1 -1
  58. package/dist/rules2/src/combinedValuesDisplay.js +2 -2
  59. package/dist/rules2/src/combinedValuesDisplay.js.map +1 -1
  60. package/dist/rules2/src/getAttributes.js +37 -0
  61. package/dist/rules2/src/getAttributes.js.map +1 -0
  62. package/dist/rules2/src/getDataflowTooltipAttributesIds.js +2 -2
  63. package/dist/rules2/src/getDataflowTooltipAttributesIds.js.map +1 -1
  64. package/dist/rules2/src/getHeaderCombinations.js +1 -1
  65. package/dist/rules2/src/getHeaderCombinations.js.map +1 -1
  66. package/dist/rules2/src/getHeaderSubtitle.js +1 -1
  67. package/dist/rules2/src/getHeaderSubtitle.js.map +1 -1
  68. package/dist/rules2/src/getHeaderTitle.js +1 -1
  69. package/dist/rules2/src/getHeaderTitle.js.map +1 -1
  70. package/dist/rules2/src/getMetadataCoordinates.js +1 -1
  71. package/dist/rules2/src/getMetadataCoordinates.js.map +1 -1
  72. package/dist/rules2/src/getNotDisplayedIds.js +1 -1
  73. package/dist/rules2/src/getNotDisplayedIds.js.map +1 -1
  74. package/dist/rules2/src/index.js +1 -0
  75. package/dist/rules2/src/index.js.map +1 -1
  76. package/dist/rules2/src/parseAttributes.js +2 -2
  77. package/dist/rules2/src/parseAttributes.js.map +1 -1
  78. package/dist/rules2/src/parseHierarchicalCodelist.js +1 -1
  79. package/dist/rules2/src/parseHierarchicalCodelist.js.map +1 -1
  80. package/dist/rules2/src/parseMetadataSeries.js +1 -1
  81. package/dist/rules2/src/parseMetadataSeries.js.map +1 -1
  82. package/dist/rules2/src/prepareData.js +10 -3
  83. package/dist/rules2/src/prepareData.js.map +1 -1
  84. package/dist/rules2/src/refineDimensions.js +53 -8
  85. package/dist/rules2/src/refineDimensions.js.map +1 -1
  86. package/dist/rules2/src/table/getCells.js +1 -1
  87. package/dist/rules2/src/table/getCells.js.map +1 -1
  88. package/dist/rules2/src/table/getLayout.js +1 -1
  89. package/dist/rules2/src/table/getLayout.js.map +1 -1
  90. package/dist/rules2/src/table/getTableLayoutIds.js +1 -1
  91. package/dist/rules2/src/table/getTableLayoutIds.js.map +1 -1
  92. package/dist/rules2/src/table/getTableProps.js +0 -1
  93. package/dist/rules2/src/table/getTableProps.js.map +1 -1
  94. package/dist/rules2/src/table/parseValueHierarchy.js.map +1 -1
  95. package/dist/rules2/src/table/refineLayoutSize2.js +1 -1
  96. package/dist/rules2/src/table/refineLayoutSize2.js.map +1 -1
  97. package/dist/rules2/src/utils.js.map +1 -1
  98. package/dist/viewer/src/chart.js +13 -2
  99. package/dist/viewer/src/chart.js.map +1 -1
  100. package/dist/viewer/src/legends/FocusLegend.js +1 -1
  101. package/dist/viewer/src/legends/FocusLegend.js.map +1 -1
  102. package/package.json +6 -5
  103. package/src/bridge-d3-react/src/index.js +0 -1
  104. package/src/rules/src/chart/getChartOptions.js +2 -2
  105. package/src/rules/src/constants.js +0 -35
  106. package/src/rules/src/dimension-utils.js +25 -23
  107. package/src/rules/src/factories/choro-series.js +41 -30
  108. package/src/rules/src/factories/focus.js +17 -0
  109. package/src/rules/src/factories/getChartSeries.js +8 -0
  110. package/src/rules/src/factories/sample-focus.js +14 -18
  111. package/src/rules/src/factories/sample-series.js +20 -20
  112. package/src/rules/src/factories/scatter-focus.js +22 -36
  113. package/src/rules/src/factories/scatter-series.js +8 -8
  114. package/src/rules/src/factories/series.js +45 -0
  115. package/src/rules/src/factories/stacked-series.js +4 -5
  116. package/src/rules/src/factories/symbol-series.js +37 -44
  117. package/src/rules/src/factories/timeline-focus.js +10 -14
  118. package/src/rules/src/factories/timeline-series.js +35 -39
  119. package/src/rules/src/get-values-enhanced.js +6 -0
  120. package/src/rules/src/index.js +7 -384
  121. package/src/rules/src/layout.js +4 -2
  122. package/src/rules/src/observation-formater.js +14 -20
  123. package/src/rules/src/properties/focus.js +50 -2
  124. package/src/rules/src/properties/getHeaderProps.js +1 -53
  125. package/src/rules/src/properties/index.js +2 -93
  126. package/src/rules/src/properties/linear.js +2 -2
  127. package/src/rules/src/properties/scatter.js +4 -4
  128. package/src/rules/src/properties/stacked.js +4 -6
  129. package/src/rules/src/properties/symbol.js +0 -1
  130. package/src/rules/src/properties/utils.js +11 -22
  131. package/src/rules/src/sdmx-data/index.js +2 -31
  132. package/src/rules2/src/combinedValuesDisplay.js +2 -2
  133. package/src/rules2/src/getAttributes.js +34 -0
  134. package/src/rules2/src/getDataflowTooltipAttributesIds.js +2 -2
  135. package/src/rules2/src/getHeaderCombinations.js +1 -1
  136. package/src/rules2/src/getHeaderSubtitle.js +2 -2
  137. package/src/rules2/src/getHeaderTitle.js +1 -1
  138. package/src/rules2/src/getMetadataCoordinates.js +1 -1
  139. package/src/rules2/src/getNotDisplayedIds.js +1 -1
  140. package/src/rules2/src/index.js +1 -0
  141. package/src/rules2/src/parseAttributes.js +2 -2
  142. package/src/rules2/src/parseHierarchicalCodelist.js +1 -1
  143. package/src/rules2/src/parseMetadataSeries.js +1 -1
  144. package/src/rules2/src/prepareData.js +10 -3
  145. package/src/rules2/src/refineDimensions.js +53 -8
  146. package/src/rules2/src/table/getCells.js +2 -2
  147. package/src/rules2/src/table/getLayout.js +2 -2
  148. package/src/rules2/src/table/getTableLayoutIds.js +9 -9
  149. package/src/rules2/src/table/getTableProps.js +0 -1
  150. package/src/rules2/src/table/parseValueHierarchy.js +0 -7
  151. package/src/rules2/src/table/refineLayoutSize2.js +5 -5
  152. package/src/rules2/src/utils.js +0 -11
  153. package/src/viewer/src/app/leg.js +0 -1
  154. package/src/viewer/src/chart.jsx +23 -1
  155. package/src/viewer/src/legends/FocusLegend.jsx +1 -1
  156. package/dist/rules/src/factories/scatter-dimension.js +0 -35
  157. package/dist/rules/src/factories/scatter-dimension.js.map +0 -1
  158. package/dist/rules/src/factories/stacked-dimension.js +0 -32
  159. package/dist/rules/src/factories/stacked-dimension.js.map +0 -1
  160. package/dist/rules/src/factories/symbol-dimension.js +0 -32
  161. package/dist/rules/src/factories/symbol-dimension.js.map +0 -1
  162. package/dist/rules/src/header/getDefaultSubtitle.js +0 -44
  163. package/dist/rules/src/header/getDefaultSubtitle.js.map +0 -1
  164. package/dist/rules/src/header/getHeaderUnits.js +0 -21
  165. package/dist/rules/src/header/getHeaderUnits.js.map +0 -1
  166. package/dist/rules/src/header/getSubtitleFlags.js +0 -47
  167. package/dist/rules/src/header/getSubtitleFlags.js.map +0 -1
  168. package/dist/rules/src/header/getTitleFlags.js +0 -12
  169. package/dist/rules/src/header/getTitleFlags.js.map +0 -1
  170. package/dist/rules/src/properties/errors.js +0 -22
  171. package/dist/rules/src/properties/errors.js.map +0 -1
  172. package/dist/rules/src/properties/getInformationsStateFromNewProps.js +0 -50
  173. package/dist/rules/src/properties/getInformationsStateFromNewProps.js.map +0 -1
  174. package/dist/rules/src/v8-transformer.js +0 -174
  175. package/dist/rules/src/v8-transformer.js.map +0 -1
  176. package/src/bridge-d3-react/src/app.js +0 -64
  177. package/src/bridge-d3-react/src/mock-choro.js +0 -394
  178. package/src/rules/src/factories/scatter-dimension.js +0 -32
  179. package/src/rules/src/factories/stacked-dimension.js +0 -29
  180. package/src/rules/src/factories/symbol-dimension.js +0 -29
  181. package/src/rules/src/header/getDefaultSubtitle.js +0 -40
  182. package/src/rules/src/header/getHeaderUnits.js +0 -17
  183. package/src/rules/src/header/getSubtitleFlags.js +0 -43
  184. package/src/rules/src/header/getTitleFlags.js +0 -8
  185. package/src/rules/src/header/index.js +0 -4
  186. package/src/rules/src/preparators/enhanceObservations.js +0 -152
  187. package/src/rules/src/properties/errors.js +0 -19
  188. package/src/rules/src/properties/getInformationsStateFromNewProps.js +0 -47
  189. package/src/rules/src/properties/information.js +0 -84
  190. package/src/rules/src/v8-transformer.js +0 -177
  191. package/src/rules2/src/getAdvAttrSeriesAtCoordinates.js +0 -29
  192. package/src/rules2/src/getMetadataStructureFromData.js +0 -17
  193. package/src/rules2/src/refineMetadataCoordinates.js +0 -28
  194. package/src/rules2/src/table/getCombinationDimensionsData.js +0 -39
@@ -1,12 +1,61 @@
1
1
  import * as R from 'ramda';
2
- import { extractSdmxArtefacts, focus } from '../';
2
+ import getSeries from '../factories/series';
3
3
  import { BAR, ROW, TIMELINE } from '../constants';
4
4
  import { hasFocus } from './utils';
5
+ import { dimensionValueDisplay, parseDisplay } from '../dimension-utils';
5
6
 
6
7
  const sampleFocusTypes = { [BAR]: BAR, [ROW]: ROW, [TIMELINE]: TIMELINE };
7
8
 
8
9
  const focusComparator = (op1, op2) => op1.value === op2.value;
9
10
 
11
+ const focus = (data, type, dimension, _display) => {
12
+ const display = parseDisplay(_display);
13
+ switch(type) {
14
+ case 'RowChart': case 'BarChart':
15
+ case 'HorizontalSymbolChart': case 'VerticalSymbolChart':
16
+ case 'StackedBarChart': case 'StackedRowChart':
17
+ return R.pipe(
18
+ getSeries,
19
+ R.pathOr([], [0, 'datapoints']),
20
+ R.map(dp => ({ label: dp.category, value: dp.key })),
21
+ )({ data, type, options: { display }, singularity: dimension });
22
+ case 'TimelineChart':
23
+ return R.pipe(
24
+ getSeries,
25
+ R.map(serie => ({ label: serie.category, value: serie.key })),
26
+ )({ data, type, options: { display }, singularity: dimension });
27
+ case 'ScatterChart':
28
+ const id = R.prop('id', dimension);
29
+ if (R.isNil(id))
30
+ return [];
31
+ return R.pipe(
32
+ R.propOr([], 'dimensions'),
33
+ R.reduce((acc, dim) => {
34
+ if (dim.header || dim.id === id) {
35
+ return acc;
36
+ }
37
+ const dimOptions = R.map(val => ({
38
+ label: `${dimensionValueDisplay(display)(dim)} - ${dimensionValueDisplay(display)(val)}`,
39
+ options: { dimensionId: dim.id, dimensionValueId: val.id },
40
+ value: `${dim.id}-${val.id}`
41
+ }), R.propOr([], 'values', dim));
42
+ return R.concat(acc, dimOptions);
43
+ }, []),
44
+ )(data);
45
+ default:
46
+ return [];
47
+ }
48
+ };
49
+
50
+ export const parseFocus = (data, type, dimension, display, { baseline, highlight }) => {
51
+ const options = focus(data, type, dimension, display);
52
+ const optionsSet = new Set(R.pluck('value', options));
53
+
54
+ const parseSelection = R.reject(({ value }) => !optionsSet.has(value));
55
+
56
+ return ({ baseline: parseSelection(baseline), highlight: parseSelection(highlight) });
57
+ };
58
+
10
59
  export const focusOptions = (props, state, otherFocus, singularity) => {
11
60
  if (!hasFocus(props.type)) {
12
61
  return [];
@@ -44,7 +93,6 @@ const filterFocus = (focus, keyedOptions, type) => R.reduce(
44
93
  )
45
94
 
46
95
  export const focusStateFromNewProps = ({ data, display, type }, singularity, state) => {
47
- const { id } = extractSdmxArtefacts(data);
48
96
  const highlightState = R.propOr([], 'highlight', state);
49
97
  const baselineState = R.propOr([], 'baseline', state);
50
98
  const options = focus(data, type, singularity, display);
@@ -1,11 +1,5 @@
1
1
  import * as R from 'ramda';
2
- import {
3
- getDefaultSubtitle,
4
- getHeaderUnits,
5
- getSubtitleFlags,
6
- getTitleFlags
7
- } from '../header';
8
- import { dimensionValueDisplay, parseDisplay } from '../';
2
+ import { dimensionValueDisplay, parseDisplay } from '../dimension-utils';
9
3
  import { isChart } from './utils';
10
4
 
11
5
  const isCustomInvalid = ({ type }) => (value) => R.isNil(value) || !isChart(type);
@@ -16,57 +10,11 @@ const getDataflowName = (props) => {
16
10
  return dimensionValueDisplay(display)(dataflow);
17
11
  };
18
12
 
19
- export const getTitleLabel = (props, state) => R.when(
20
- isCustomInvalid({ type: props.type }),
21
- R.always(getDataflowName(props))
22
- )(state.title);
23
-
24
- export const getSubtitle = (props, state) => R.ifElse(
25
- isCustomInvalid({type: props.type }),
26
- R.always(getDefaultSubtitle({
27
- customAttributes: props.customAttributes,
28
- dimensions: state.dimensions,
29
- display: props.display,
30
- units: state.units
31
- })),
32
- (label) => {
33
- const flags = getSubtitleFlags({
34
- customAttributes: props.customAttributes,
35
- dimensions: state.dimensions,
36
- display: props.display,
37
- units: state.units
38
- });
39
- return ([{ label, flags }]);
40
- }
41
- )(state.subtitle);
42
-
43
13
  export const getSourceLabel = (props, state) => R.when(
44
14
  isCustomInvalid({ type: props.type }),
45
15
  R.always(getDataflowName(props))
46
16
  )(state.sourceLabel);
47
17
 
48
- export const getHeaderProps = (props, state) => {
49
- const title = {
50
- label: getTitleLabel(props, state),
51
- flags: getTitleFlags({
52
- customAttributes: props.customAttributes,
53
- dataflowAttributes: state.dataflowAttributes,
54
- display: props.display,
55
- })
56
- };
57
-
58
- const subtitle = getSubtitle(props, state);
59
-
60
- const uprs = getHeaderUnits({
61
- display: props.display,
62
- units: R.assoc(
63
- 'values',
64
- R.pathOr([], ['units', 'headerUnits'], state)
65
- )(R.pathOr({}, ['units', 'unitDimension'], props))
66
- });
67
- return ({ subtitle, title, uprs });
68
- };
69
-
70
18
  export const getFooterProps = (props, state) => ({
71
19
  withCopyright: isChart(props.type) ? state.withCopyright : true,
72
20
  withLogo: isChart(props.type) ? state.withLogo : true,
@@ -1,6 +1,4 @@
1
1
  import * as R from 'ramda';
2
- import { getDataFrequency } from '@sis-cc/dotstatsuite-sdmxjs';
3
- import { series } from '../';
4
2
  import {
5
3
  H_SYMBOL,
6
4
  SCATTER,
@@ -49,12 +47,11 @@ import {
49
47
  hasFocus,
50
48
  isChart,
51
49
  isNaturalInt,
52
- isNumber,
53
50
  optionParser,
54
51
  } from './utils';
55
- import { getTitleLabel, getSubtitle, getSourceLabel } from './getHeaderProps';
52
+ import { getSourceLabel } from './getHeaderProps';
56
53
  import { stringifySubtitle } from './getStringifiedSubtitle';
57
- import { getHasNoTimePeriodError } from './errors';
54
+
58
55
  /*
59
56
  - width/height -> initial undefined, if undefined or blank, replaced by options.base
60
57
  */
@@ -72,32 +69,6 @@ export const toSingularity = ({ data, type }, state) => {
72
69
  }
73
70
  };
74
71
 
75
- export const toChartData = (props, state) => {
76
- const dimensions = R.pathOr([], ['data', 'structure', 'dimensions', 'observation'], props);
77
- const attributes = R.pathOr([], ['data', 'structure', 'attributes', 'observation'], props);
78
- const frequency = props.type === TIMELINE ? getDataFrequency({ dimensions, attributes }) : null;
79
- return ({
80
- frequency,
81
- series: series(
82
- props.data,
83
- props.type,
84
- R.pick(['highlight', 'baseline'], state),
85
- toSingularity(props, state),
86
- props.map,
87
- props.display,
88
- props.formaterIds
89
- ),
90
- share: {
91
- focused: R.pick(['highlight', 'baseline'], state),
92
- chartDimension: toSingularity(props, state),
93
- }
94
- });
95
- };
96
-
97
- export const getErrors = (props, state) => ({
98
- noTime: getHasNoTimePeriodError(props),
99
- });
100
-
101
72
  const toFloat = (value) => {
102
73
  const float = parseFloat(value);
103
74
  return isNaN(float) ? undefined : float;
@@ -171,25 +142,6 @@ export const toChartOptions = (props, state) => {
171
142
  });
172
143
  };
173
144
 
174
- export const initialState = {
175
- highlight: [],
176
- baseline: [],
177
- fixedWidth: undefined,
178
- fixedHeight: undefined,
179
- freqStep: undefined,
180
- responsiveWidth: undefined,
181
- responsiveHeight: undefined,
182
- scatterDimension: undefined,
183
- scatterX: undefined,
184
- scatterY: undefined,
185
- symbolDimension: undefined,
186
- stackedDimension: undefined,
187
- stackedMode: undefined,
188
- id: undefined,
189
- type: undefined,
190
- ...linearInitialState,
191
- };
192
-
193
145
  export const stateFromNewProps = (props, state) => {
194
146
  const focusState = sampleFocusStateFromNewProps(props, state);
195
147
  const scatterState = scatterStateFromNewProps(props, state);
@@ -212,49 +164,6 @@ export const stateFromNewProps = (props, state) => {
212
164
  });
213
165
  };
214
166
 
215
- const propertiesParsers = {
216
- highlight: onChangeFocusSelection,
217
- baseline: onChangeFocusSelection,
218
- fixedWidth: (value) => isNaturalInt(value) ? value : undefined,
219
- fixedHeight: (value) => isNaturalInt(value) ? value : undefined,
220
- responsiveWidth: (value) => isNumber(value) ? value : undefined,
221
- responsiveHeight: (value) => isNumber(value) ? value : undefined,
222
- freqStep: (value) => isNaturalInt(value) ? value : undefined,
223
- title: R.identity,
224
- subtitle: R.identity,
225
- sourceLabel: R.identity,
226
- scatterDimension: optionParser,
227
- scatterX: optionParser,
228
- scatterY: optionParser,
229
- symbolDimension: optionParser,
230
- stackedDimension: optionParser,
231
- stackedMode: optionParser,
232
- maxX: (value) => isNumber(value) ? value : undefined,
233
- maxY: (value) => isNumber(value) ? value : undefined,
234
- minX: (value) => isNumber(value) ? value : undefined,
235
- minY: (value) => isNumber(value) ? value : undefined,
236
- pivotX: (value) => isNumber(value) ? value : undefined,
237
- pivotY: (value) => isNumber(value) ? value : undefined,
238
- stepX: (value) => isNaturalInt(value) ? value : undefined,
239
- stepY: (value) => isNaturalInt(value) ? value : undefined,
240
- };
241
-
242
- export const onChangeProperties = (state, onChange) => (newProperties) => {
243
- const apply = R.is(Function, onChange) ? onChange : R.identity;
244
- const refined = R.pipe(
245
- R.mapObjIndexed((value, key) => {
246
- const _parser = R.prop(key, propertiesParsers);
247
- const parser = R.is(Function, _parser) ? _parser : R.identity;
248
- return parser(value);
249
- }),
250
- R.pickBy((value, key) => value !== R.prop(key, state))
251
- )(newProperties);
252
- if (R.isEmpty(refined)) {
253
- return ;
254
- }
255
- apply(refined);
256
- };
257
-
258
167
  export const toProperties = (props, state, onChange) => ({
259
168
  ...toLinearProperties(props, state, onChange),
260
169
  highlight: {
@@ -95,7 +95,7 @@ export const toProperties = (props, state, onChange) => ({
95
95
  pivotX: isNumber(value) ? value : undefined
96
96
  }),
97
97
  value: R.when(
98
- v => R.isNil(v) && (R.propEq('type', ROW)(props) || R.propEq('type', STACKED_ROW)(props)),
98
+ v => R.isNil(v) && (R.propEq(ROW, 'type')(props) || R.propEq(STACKED_ROW, 'type')(props)),
99
99
  R.always(0)
100
100
  )(R.isNil(state.pivotX) ? String(state.computedPivotX) : state.pivotX)
101
101
  },
@@ -106,7 +106,7 @@ export const toProperties = (props, state, onChange) => ({
106
106
  pivotY: isNumber(value) ? value : undefined
107
107
  }),
108
108
  value: R.when(
109
- v => R.isNil(v) && (R.propEq('type', BAR)(props) || R.propEq('type', STACKED_BAR)(props)),
109
+ v => R.isNil(v) && (R.propEq(BAR, 'type')(props) || R.propEq(STACKED_BAR, 'type')(props)),
110
110
  R.always(0)
111
111
  )(R.isNil(state.pivotY) ? String(state.computedPivotY) : state.pivotY)
112
112
  },
@@ -66,7 +66,7 @@ export const scatterStateValueToOption = (property, props, state) => {
66
66
  return undefined;
67
67
  }
68
68
  const value = R.find(
69
- R.propEq('id', R.prop(property, state)),
69
+ R.propEq(R.prop(property, state), 'id'),
70
70
  R.prop('values', dimension)
71
71
  );
72
72
  return artefactToOption(props.display)(value);
@@ -74,7 +74,7 @@ export const scatterStateValueToOption = (property, props, state) => {
74
74
 
75
75
  export const onChangeScatterVal = ({ data, type }, state, valKey, otherValKey) => (value) => {
76
76
  const options = scatterValueOptions({ data, type }, state);
77
- const [matching, otherOptions] = R.partition(R.propEq('value', value), options);
77
+ const [matching, otherOptions] = R.partition(R.propEq(value, 'value'), options);
78
78
  if (R.isEmpty(matching)) {
79
79
  return ({});
80
80
  }
@@ -135,10 +135,10 @@ export const scatterStateFromNewProps = (props, state) => {
135
135
 
136
136
  //dirty as f
137
137
  const scatterX = R.isNil(_scatterX)
138
- ? R.head(R.reject(R.propEq('id', R.prop('id', _scatterY)), values))
138
+ ? R.head(R.reject(R.propEq(R.prop('id', _scatterY), 'id'), values))
139
139
  : _scatterX;
140
140
  const scatterY = R.isNil(_scatterY)
141
- ? R.head(R.reject(R.propEq('id', R.prop('id', scatterX)), values))
141
+ ? R.head(R.reject(R.propEq(R.prop('id', scatterX),'id'), values))
142
142
  : _scatterY;
143
143
 
144
144
  const scatterState = toScatterState(
@@ -6,7 +6,6 @@ import {
6
6
  getPropertyDimension,
7
7
  toState
8
8
  } from './utils';
9
- import { splitDimensions } from '../';
10
9
  import { focusStateFromNewProps } from './focus';
11
10
 
12
11
  const getStackedDimension = getPropertyDimension('stackedDimension');
@@ -41,8 +40,8 @@ export const onChangeStackedDimension = ({ data }, state) => (value) => {
41
40
  export const stackedModeOptions = [{ value: VALUES }, { value: PERCENT }];
42
41
 
43
42
  export const isStackedDimActive = ({ data, type }) => {
44
- const { values } = splitDimensions(data);
45
- if (R.length(values) < 2) {
43
+ const dimensions = getDimensionsWithValues(data);
44
+ if (R.length(dimensions) < 2) {
46
45
  return false;
47
46
  }
48
47
  return isStacked(type);
@@ -67,9 +66,8 @@ export const stackedStateFromNewProps = (props, state) => {
67
66
 
68
67
  let dimension = getStackedDimension(data, state);
69
68
  if (R.isNil(dimension)) {
70
- const { value, values } = splitDimensions(data);
71
- if (R.length(values) === 1) {
72
- dimension = R.head(value);
69
+ if (R.length(dimensions) === 1) {
70
+ dimension = R.find(R.prop('header'), data.dimensions);
73
71
  }
74
72
  else {
75
73
  const { area, time, other } = getGroupedDimensions(data);
@@ -1,5 +1,4 @@
1
1
  import * as R from 'ramda';
2
- import { extractSdmxArtefacts } from '../';
3
2
  import { H_SYMBOL, V_SYMBOL } from '../constants';
4
3
  import {
5
4
  getDimensionsWithValues,
@@ -3,8 +3,7 @@ import {
3
3
  find,
4
4
  groupBy,
5
5
  has,
6
- head,
7
- is,
6
+ isEmpty,
8
7
  isNil,
9
8
  length,
10
9
  map,
@@ -13,9 +12,11 @@ import {
13
12
  pipe,
14
13
  prop,
15
14
  propEq,
15
+ propOr,
16
+ reject
16
17
  } from 'ramda';
17
18
  import { isRefAreaDimension, isTimePeriodDimension } from '@sis-cc/dotstatsuite-sdmxjs';
18
- import { extractSdmxArtefacts, parseDisplay, splitDimensions } from '../';
19
+ import { parseDisplay } from '../dimension-utils';
19
20
  import { CHORO, STACKED_BAR, STACKED_ROW, TYPES } from '../constants';
20
21
  import { dimensionValueDisplay } from '../dimension-utils';
21
22
 
@@ -30,26 +31,23 @@ export const isPositiveNumber = (input) => {
30
31
 
31
32
  export const isNaturalInt = value => isNil(value) || /^\d+$/.test(String(value));
32
33
 
33
- export const isInt = value => isNil(value) || /^-?\d+$/.test(String(value));
34
34
 
35
35
  export const isChart = (type) => has(type, TYPES);
36
36
 
37
37
  export const hasFocus = (type) => has(type, omit([CHORO], TYPES));
38
38
 
39
39
  export const getDimensionsWithValues = (data) => pipe(
40
- splitDimensions,
41
- prop('values'),
40
+ propOr([], 'dimensions'),
41
+ reject(d => d.header || isEmpty(d.values || []))
42
42
  )(data);
43
43
 
44
44
  export const toState = (artefact) => prop('id', artefact);
45
45
 
46
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
- );
47
+ const dimensionId = prop(property, state);
48
+ const { dimensions = [] } = data || {};
49
+
50
+ return find(propEq(dimensionId, 'id'), dimensions);
53
51
  };
54
52
 
55
53
  export const getGroupedDimensions = pipe(
@@ -73,10 +71,6 @@ export const optionParser = option => pipe(
73
71
  option => is(String, option) ? option : undefined
74
72
  )(option);
75
73
 
76
- export const optionsParser = selection => pipe(
77
- selection => is(Array, selection) ? selection : [selection],
78
- selection => map(optionParser, selection)
79
- )(selection);
80
74
 
81
75
  export const artefactToOption = (display) => (artefact) => isNil(artefact)
82
76
  ? undefined
@@ -85,11 +79,6 @@ export const artefactToOption = (display) => (artefact) => isNil(artefact)
85
79
  value: prop('id', artefact)
86
80
  };
87
81
 
88
- export const dimensionWithValuesToOptions = ({ data, display }) => pipe(
89
- getDimensionsWithValues,
90
- map(artefactToOption(display))
91
- )(data);
92
-
93
82
  export const chartDimensionToOption = (property) => ({ data, display }, state) => pipe(
94
83
  getPropertyDimension(property),
95
84
  artefactToOption(display)
@@ -99,7 +88,7 @@ export const chartDimensionOptions = ({ data, type, display }, typeValidator) =>
99
88
  if (!typeValidator(type)) {
100
89
  return [];
101
90
  }
102
- const dimensions = prop('values', splitDimensions(data));
91
+ const dimensions = getDimensionsWithValues(data);
103
92
  if ((equals(type, STACKED_BAR) || equals(type, STACKED_ROW)) && length(dimensions) === 1) {
104
93
  return [];
105
94
  }
@@ -1,39 +1,10 @@
1
1
  import * as R from 'ramda';
2
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
3
  const NOT_DISPLAYED = 'NOT_DISPLAYED';
13
4
 
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
5
  export const getIsHidden = annotations => R.pipe(
35
- R.find(R.propEq('type', NOT_DISPLAYED)),
6
+ R.find(R.propEq(NOT_DISPLAYED, 'type')),
36
7
  R.complement(R.isNil)
37
8
  )(annotations);
38
9
 
39
- export const getFullName = R.identity;
10
+ export const getFullName = R.identity;
@@ -1,5 +1,5 @@
1
1
  import * as R from 'ramda';
2
- import { dimensionValueDisplay } from '../../rules/src';
2
+ import { dimensionValueDisplay } from '../../rules/src/dimension-utils';
3
3
  import { REJECTED_VALUE_IDS } from './constants';
4
4
 
5
5
  const getRefinedMissinParentsLabels = R.pipe(
@@ -46,7 +46,7 @@ const _combinedValuesDisplay = (_display) => (values) =>
46
46
  if (!R.isEmpty(labels) || _display !== 'label') {
47
47
  return R.join(', ', labels);
48
48
  }
49
- const totalValue = R.find(R.propEq('id', '_T'), values);
49
+ const totalValue = R.find(R.propEq('_T', 'id'), values);
50
50
  if (!R.isNil(totalValue)) {
51
51
  return dimensionValueDisplay('label')(totalValue);
52
52
  }
@@ -0,0 +1,34 @@
1
+ import * as R from 'ramda';
2
+ import { getIsHidden } from '../../rules/src/sdmx-data';
3
+ import { getValuesEnhanced } from '../../rules/src/get-values-enhanced';
4
+
5
+ export const getAttributes = ({ attributes, annotations, options }) => {
6
+ const {
7
+ hiddenCombinations = {},
8
+ hiddenValues = {},
9
+ locale = '',
10
+ ...restOptions
11
+ } = options;
12
+
13
+ const datasetAttributes = R.propOr([], 'dataSet', attributes);
14
+ const obsAttributes = R.propOr([], 'observation', attributes);
15
+
16
+ return R.pipe(
17
+ R.concat,
18
+ R.addIndex(R.map)((attr, index) => {
19
+ const attrAnnotations = R.props(attr.annotations || [], annotations);
20
+ return ({
21
+ ...attr,
22
+ __index: index,
23
+ display: !R.has(attr.id, hiddenValues) && !getIsHidden(attrAnnotations),
24
+ values: getValuesEnhanced({
25
+ locale,
26
+ annotations,
27
+ parent: attr.id,
28
+ hiddenIds: hiddenValues,
29
+ options: restOptions,
30
+ })(attr.values || [])
31
+ })
32
+ })
33
+ )(obsAttributes, datasetAttributes);
34
+ };
@@ -4,8 +4,8 @@ export const getDataflowTooltipAttributesIds = (sdmxJson, defaults = {}) => {
4
4
  const dataflowAnnotationsIndexes = R.pathOr([], ['data', 'dataSets', 0, 'annotations'], sdmxJson);
5
5
  const dataflowAnnotations = R.props(dataflowAnnotationsIndexes, R.pathOr([], ['data', 'structure', 'annotations'], sdmxJson));
6
6
 
7
- const flagsAttrAnnotation = R.find(R.propEq('type', 'LAYOUT_FLAG'), dataflowAnnotations);
8
- const footnotesAttrAnnotation = R.find(R.propEq('type', 'LAYOUT_NOTE'), dataflowAnnotations);
7
+ const flagsAttrAnnotation = R.find(R.propEq('LAYOUT_FLAG', 'type'), dataflowAnnotations);
8
+ const footnotesAttrAnnotation = R.find(R.propEq('LAYOUT_NOTE', 'type'), dataflowAnnotations);
9
9
 
10
10
  const customFlags = R.pipe(
11
11
  R.propOr('', 'title'),
@@ -1,5 +1,5 @@
1
1
  import * as R from 'ramda';
2
- import { dimensionValueDisplay } from '../../rules/src';
2
+ import { dimensionValueDisplay } from '../../rules/src/dimension-utils';
3
3
  import { combinedValuesDisplay } from './combinedValuesDisplay';
4
4
  import { REJECTED_VALUE_IDS } from './constants';
5
5
 
@@ -1,6 +1,6 @@
1
1
  import * as R from 'ramda';
2
2
  import { getFlagsAndNotes } from './table/getFlagsAndNotes';
3
- import { dimensionValueDisplay } from '../../rules/src/';
3
+ import { dimensionValueDisplay } from '../../rules/src/dimension-utils';
4
4
 
5
5
  export const getHeaderSubtitle = (dimensions, combinations, customAttributes, display, microdataDimension) => {
6
6
  const combinationsConepts = R.pipe(R.pluck('concepts'), R.unnest)(combinations);
@@ -8,7 +8,7 @@ export const getHeaderSubtitle = (dimensions, combinations, customAttributes, di
8
8
 
9
9
  return R.reduce(
10
10
  (acc, dim) => {
11
- if (!R.propOr(true, 'display', dim) || R.propEq('id', microdataDimension, dim)
11
+ if (!R.propOr(true, 'display', dim) || R.propEq(microdataDimension, 'id', dim)
12
12
  || R.includes(dim.id, combinationsConepts)) {
13
13
  return acc;
14
14
  }
@@ -1,5 +1,5 @@
1
1
  import * as R from 'ramda';
2
- import { dimensionValueDisplay } from '../../rules/src';
2
+ import { dimensionValueDisplay } from '../../rules/src/dimension-utils';
3
3
  import { getFlagsAndNotes } from './table/getFlagsAndNotes';
4
4
 
5
5
  export const getHeaderTitle = (dataflow, attributes, display, customAttributes) => ({
@@ -6,7 +6,7 @@ export const getMetadataCoordinates = (sdmxJson) => {
6
6
  const metadataAvailKeys = R.pipe(
7
7
  R.pathOr([], ['data', 'dataSets', 0, 'dimensionGroupAttributes']),
8
8
  R.map(indexes => R.props(indexes, annotations)),
9
- R.filter(R.find(a => a && R.propEq('type', 'HAS_METADATA', a))),
9
+ R.filter(R.find(a => a && R.propEq('HAS_METADATA', 'type', a))),
10
10
  R.keys
11
11
  )(sdmxJson);
12
12
 
@@ -42,7 +42,7 @@ const getNotDisplayedValues = annot => {
42
42
  };
43
43
 
44
44
  export const getNotDisplayedIds = (annotations) => R.pipe(
45
- R.find(R.propEq('type', 'NOT_DISPLAYED')),
45
+ R.find(R.propEq('NOT_DISPLAYED', 'type')),
46
46
  R.converge((hiddenValues, hiddenCombinations) => ({
47
47
  hiddenValues,
48
48
  hiddenCombinations
@@ -16,6 +16,7 @@ export { refinePartialHierarchy } from './hierarchiseDimensionWithAdvancedHierar
16
16
  export { hierarchiseDimensionWithNativeHierarchy } from './hierarchiseDimensionWithNativeHierarchy2';
17
17
  export { getDimensionValuesIndexes } from './getDimensionValuesIndexes';
18
18
  export { getCombinationDefinitions, parseCombinationDefinition } from './getCombinationDefinitions';
19
+ export { getAttributes } from './getAttributes';
19
20
  export { refineDimensions } from './refineDimensions';
20
21
  export { parseAttributes } from './parseAttributes';
21
22
  export { parseCombinations } from './parseCombinations';
@@ -14,10 +14,10 @@ export const parseAttributes = (attributes, dimensions, customAttributes) => {
14
14
  || attr.id === REPYEARSTART) {
15
15
  return R.assoc('display', false, res);
16
16
  }
17
- if (R.propEq('id', customAttributes.prefscale, attr)) {
17
+ if (R.propEq(customAttributes.prefscale, 'id', attr)) {
18
18
  return R.assoc('prefscale', true, res);
19
19
  }
20
- if (R.propEq('id', customAttributes.decimals, attr)) {
20
+ if (R.propEq(customAttributes.decimals, 'id', attr)) {
21
21
  return R.assoc('decimals', true, res);
22
22
  }
23
23
  if (R.hasPath(['relationship', 'none'], attr) || R.hasPath(['relationship', 'dataflow'], attr)) {
@@ -2,7 +2,7 @@ import * as R from 'ramda';
2
2
 
3
3
  export const parseHierarchicalCodelist = (sdmxJson, hierarchyId) => {
4
4
  const hCodelist = R.pathOr({}, ['data', 'hierarchicalCodelists', 0], sdmxJson);
5
- const hierarchy = R.find(R.propEq('id', hierarchyId), hCodelist.hierarchies || []);
5
+ const hierarchy = R.find(R.propEq(hierarchyId, 'id'), hCodelist.hierarchies || []);
6
6
 
7
7
  const getParentedCodes = (codes, parent) => {
8
8
  const ids = R.pluck('codeID', codes);
@@ -47,7 +47,7 @@ export const parseMetadataSeries = (metadataJson, options) => {
47
47
  const val = R.nth(Number(vInd), dim.values || []);
48
48
 
49
49
  const originalVal = R.find(
50
- R.propEq('id', val.id),
50
+ R.propEq(val.id, 'id'),
51
51
  )(R.propOr([], 'values', R.nth(dInd, options.dimensions)));
52
52
  return R.propOr('', '__index', originalVal);
53
53
  }),