@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,230 +0,0 @@
1
- import * as R from 'ramda';
2
- import numeral from 'numeral';
3
- import { format } from 'date-fns';
4
- import {
5
- BAR,
6
- CHORO,
7
- H_SYMBOL,
8
- ROW,
9
- SCATTER,
10
- STACKED_BAR,
11
- STACKED_ROW,
12
- TIMELINE,
13
- V_SYMBOL
14
- } from '../constants';
15
- import { getTimeProc } from './getAxisOptions';
16
-
17
- export const getTooltipOptions = (data, type, options, fonts={}, timeFormats={}, locale) => {
18
- const primaryFonts = (color) => (`
19
- font-size: ${R.pathOr(12, ['primary', 'fontSize'], fonts)}px;
20
- font-family: ${R.pathOr('inherit', ['primary', 'fontFamily'], fonts)};
21
- font-weight: ${R.pathOr('normal', ['primary', 'fontWeight'], fonts)};
22
- color: ${color};
23
- padding: 5px;
24
- border: 1px solid ${color};
25
- background: white;
26
- opacity: .8;
27
- `);
28
-
29
- const secondaryFonts = `
30
- font-family: ${R.pathOr('inherit', ['secondary', 'fontFamily'], fonts)};
31
- font-size: ${R.pathOr(12, ['secondary', 'fontSize'], fonts)}px;
32
- font-weight: ${R.pathOr('normal', ['secondary', 'fontWeight'], fonts)};
33
- `;
34
-
35
- const valueFormatter = d => numeral(d).format('0,0.[00]');
36
-
37
- const timeFormatter = R.pipe(
38
- R.prop('frequency'),
39
- freq => getTimeProc(freq, timeFormats, locale),
40
- R.when(
41
- R.anyPass([R.isNil, R.complement(R.is)(Function)]),
42
- R.always(date => format(date, 'MMM YY'))
43
- )
44
- )(data);
45
-
46
- return R.pipe(
47
- R.pathOr({}, ['serie', 'tooltip']),
48
- R.cond([
49
- [
50
- R.always(R.equals(BAR, type)),
51
- R.mergeRight({
52
- layout: (serie, datum, color) => (`
53
- <div style="${primaryFonts(color)}">
54
- <div style="text-align: right;">
55
- ${datum.x}
56
- </div>
57
- <div style="text-align: right; ${secondaryFonts}">
58
- ${datum.formatedValue || valueFormatter(datum.y)}
59
- </div>
60
- </div>
61
- `)
62
- })
63
- ],
64
- [
65
- R.always(R.equals(ROW, type)),
66
- R.mergeRight({
67
- layout: (serie, datum, color) => (`
68
- <div style="${primaryFonts(color)}">
69
- <div style="text-align: right;">
70
- ${datum.y}
71
- </div>
72
- <div style="text-align: right; ${secondaryFonts}">
73
- ${datum.formatedValue || valueFormatter(datum.x)}
74
- </div>
75
- <div>
76
- `)
77
- })
78
- ],
79
- [
80
- R.always(R.equals(SCATTER, type)),
81
- R.mergeRight({
82
- layout: (serie, datum, color) => (`
83
- <div style="${primaryFonts(color)}">
84
- <div style="text-align: right;">
85
- ${R.pipe(R.propOr({}, 'dimensionValues'), R.values, R.pluck('name'), R.join(' '))(datum)}
86
- </div>
87
- <div style="text-align: right;">
88
- ${R.path(['dimensionValues', 'x', 'name'], serie)}
89
- <span style="${secondaryFonts}">
90
- ${datum.xFormat || valueFormatter(datum.x)}
91
- </span>
92
- </div>
93
- <div style="text-align: right;">
94
- ${R.path(['dimensionValues', 'y', 'name'], serie)}
95
- <span style="${secondaryFonts}">
96
- ${datum.yFormat || valueFormatter(datum.y)}
97
- </span>
98
- </div>
99
- </div>
100
- `)
101
- })
102
- ],
103
- [
104
- R.always(R.equals(TIMELINE, type)),
105
- R.mergeRight({
106
- layout: (serie, datum, color) => (`
107
- <div style="${primaryFonts(color)}">
108
- <div style="text-align: right;">
109
- ${R.pipe(R.propOr({}, 'dimensionValues'), R.values, R.pluck('name'), R.join('<br />'))(datum)}
110
- </div>
111
- <div style="text-align: right;">
112
- ${datum.timeLabel}
113
- </div>
114
- <div style="text-align: right; ${secondaryFonts}">
115
- ${datum.formatedValue || valueFormatter(datum.y)}
116
- </div>
117
- </div>
118
- `)
119
- })
120
- ],
121
- [
122
- R.always(R.equals(H_SYMBOL, type)),
123
- R.mergeRight({
124
- layout: (serie, datum, color) => (`
125
- <div style="${primaryFonts(color)}">
126
- <div style="text-align: right;">
127
- ${datum.y}
128
- <br />
129
- ${datum.symbolValue}
130
- </div>
131
- <div style="text-align: right; ${secondaryFonts}">
132
- ${datum.formatedValue || valueFormatter(datum.x)}
133
- </div>
134
- </div>
135
- `)
136
- })
137
- ],
138
- [
139
- R.always(R.equals(V_SYMBOL, type)),
140
- R.mergeRight({
141
- layout: (serie, datum, color) => (`
142
- <div style="${primaryFonts(color)}">
143
- <div style="text-align: right;">
144
- ${datum.x}
145
- <br />
146
- ${datum.symbolValue}
147
- </div>
148
- <div style="text-align: right; ${secondaryFonts}">
149
- ${datum.formatedValue || valueFormatter(datum.y)}
150
- </div>
151
- </div>
152
- `)
153
- })
154
- ],
155
- [
156
- R.always(R.equals(STACKED_BAR, type)),
157
- R.mergeRight({
158
- layout: (serie, datum, color) => (`
159
- <div style="${primaryFonts(color)}">
160
- <div style="text-align: right;">
161
- ${datum.x}
162
- </div>
163
- <div style="text-align: right;">
164
- ${datum.layerLabel}
165
- </div>
166
- <div style="text-align: right; font-size: ${R.pathOr(12, ['secondary', 'fontSize'], fonts)}px;">
167
- Value:
168
- <span style="${secondaryFonts}">
169
- ${R.is(Function, datum.formater) ? datum.formater(datum.height) : valueFormatter(datum.height)}
170
- </span>
171
- </div>
172
- <div style="text-align: right; font-size: ${R.pathOr(12, ['secondary', 'fontSize'], fonts)}px;">
173
- Cumulated:
174
- <span style="${secondaryFonts}">
175
- ${R.is(Function, datum.formater) ? datum.formater(datum.y) : valueFormatter(datum.y)}
176
- </span>
177
- </div>
178
- </div>
179
- `)
180
- })
181
- ],
182
- [
183
- R.always(R.equals(STACKED_ROW, type)),
184
- R.mergeRight({
185
- layout: (serie, datum, color) => (`
186
- <div style="${primaryFonts(color)}">
187
- <div style="text-align: right;">
188
- ${datum.y}
189
- </div>
190
- <div style="text-align: right;">
191
- ${datum.layerLabel}
192
- </div>
193
- <div style="text-align: right; font-size: ${R.pathOr(12, ['secondary', 'fontSize'], fonts)}px;">
194
- Value:
195
- <span style="${secondaryFonts}">
196
- ${R.is(Function, datum.formater) ? datum.formater(datum.width) : valueFormatter(datum.width)}
197
- </span>
198
- </div>
199
- <div style="text-align: right; font-size: ${R.pathOr(12, ['secondary', 'fontSize'], fonts)}px;">
200
- Cumulated:
201
- <span style="${secondaryFonts}">
202
- ${R.is(Function, datum.formater) ? datum.formater(datum.x) : valueFormatter(datum.x)}
203
- </span>
204
- </div>
205
- </div>
206
- `)
207
- })
208
- ],
209
- [
210
- R.always(R.equals(CHORO, type)),
211
- R.mergeRight({
212
- layout: (serie, datum, color) => (`
213
- <div style="${primaryFonts(color)}">
214
- <div style="text-align: right;">
215
- ${R.pathOr('', ['properties', 'label'], datum)}
216
- </div>
217
- <div style="text-align: right;">
218
- ${R.pathOr('', ['properties', 'category'], datum)}
219
- </div>
220
- <div style="text-align: right; ${secondaryFonts}">
221
- ${R.pipe(R.pathOr(null, ['properties', 'value']), valueFormatter)(datum)}
222
- </div>
223
- </div>
224
- `)
225
- })
226
- ],
227
- [R.T, R.identity]
228
- ])
229
- )(options);
230
- };
@@ -1,64 +0,0 @@
1
- export const BAR = 'BarChart';
2
- export const ROW = 'RowChart';
3
- export const SCATTER = 'ScatterChart';
4
- export const TIMELINE = 'TimelineChart';
5
- export const H_SYMBOL = 'HorizontalSymbolChart';
6
- export const V_SYMBOL = 'VerticalSymbolChart';
7
- export const STACKED_BAR = 'StackedBarChart';
8
- export const STACKED_ROW = 'StackedRowChart';
9
- export const CHORO = 'ChoroplethChart';
10
- export const PERCENT = 'percent';
11
- export const VALUES = 'values';
12
- export const TYPES = {
13
- [BAR]: BAR,
14
- [ROW]: ROW,
15
- [SCATTER]: SCATTER,
16
- [TIMELINE]: TIMELINE,
17
- [H_SYMBOL]: H_SYMBOL,
18
- [V_SYMBOL]: V_SYMBOL,
19
- [STACKED_BAR]: STACKED_BAR,
20
- [STACKED_ROW]: STACKED_ROW,
21
- [CHORO]: CHORO,
22
- };
23
- export const FREQ_A = 'annual';
24
- export const FREQ_S = 'semesterly';
25
- export const FREQ_Q = 'quarterly';
26
- export const FREQ_M = 'monthly';
27
- export const DEFAULT_UPR_IDS = {
28
- U: ['UNIT', 'UNIT_MEASURE', 'UNIT_MEAS', 'UNITS'],
29
- P: ['UNIT_MULT', 'POWERCODE', 'POWER', 'MAGNITUDE', 'SCALE'],
30
- R: ['REF_PERIOD', 'REFERENCEPERIOD', 'BASE_PER']
31
- };
32
-
33
- export const DEFAULT_REJECTED_UPR_VALUES_IDS = {
34
- U: [],
35
- P: ['0'],
36
- R: []
37
- };
38
-
39
- export const DEFAULT_REJECTED_SUBTITLE_IDS = ['_L', '_T', '_Z'];
40
-
41
- export const DIMENSION_DISPLAY_PARTS = {
42
- DESCRIPTION: 'description',
43
- CODE: 'code',
44
- BOTH: 'both',
45
- };
46
-
47
- export const DEFAULT_MAJOR_ATTRIBUTES = {
48
- DECIMALS: {
49
- ID: 'DECIMALS',
50
- ROLE: 'DECIMALS'
51
- },
52
- SCALE: {
53
- ID: 'SCALE'
54
- }
55
- };
56
-
57
- export const V8_SDMX_JSON = "application/vnd.sdmx.data+json;version=1.0.0-wd";
58
-
59
- export const OBS_TYPE_NUMBER = 'OBS_TYPE_NUMBER';
60
- export const OBS_TYPE_NUMERICAL_STRING = 'OBS_TYPE_NUMERICAL_STRING';
61
- export const OBS_TYPE_STRING = 'OBS_TYPE_STRING';
62
- export const REPORTING_YEAR_START_DAY = 'REPORTING_YEAR_START_DAY';
63
- export const REPYEARSTART = 'REPYEARSTART';
64
-
@@ -1,118 +0,0 @@
1
- import * as R from 'ramda';
2
- import dateFns from 'date-fns';
3
- import fr from 'date-fns/locale/fr';
4
- import de from 'date-fns/locale/de';
5
- import en from 'date-fns/locale/en';
6
- import es from 'date-fns/locale/es';
7
- import ar from 'date-fns/locale/ar';
8
- import it from 'date-fns/locale/it';
9
- import nl from 'date-fns/locale/nl';
10
- import th from 'date-fns/locale/th';
11
-
12
- const isValidDate = period =>
13
- R.and(dateFns.isDate, date => R.not(R.equals(date.getTime(date), NaN)))(new Date(period));
14
-
15
- export const dateWithoutTZ = date => dateFns.addMinutes(date, date.getTimezoneOffset());
16
-
17
- export const getLocale = R.cond([
18
- [R.equals('fr'), R.always(fr)],
19
- [R.equals('de'), R.always(de)],
20
- [R.equals('es'), R.always(es)],
21
- [R.equals('ar'), R.always(ar)],
22
- [R.equals('it'), R.always(it)],
23
- [R.equals('nl'), R.always(nl)],
24
- [R.equals('th'), R.always(th)],
25
- [R.T, R.always(en)]
26
- ]);
27
-
28
- const formaterPeriod = (locale, format) => date => dateFns.format(date, format, { locale: getLocale(locale) });
29
-
30
- export const getReportedTimePeriodLabel = (freq, _format, locale) => (reportYearStart, { id, start, reportedStart }) => {
31
- const year = dateFns.getYear(start);
32
- const reportStartDate = new Date(year, reportYearStart.month, reportYearStart.day);
33
- const isReportFirstDate = dateFns.isEqual(reportStartDate, new Date(year, 1, 1));
34
- if (isReportFirstDate || freq === 'D') {
35
- return R.isNil(_format) || freq !== 'M'
36
- ? id : dateFns.format(start, _format, { locale: getLocale(locale) });
37
- }
38
- const nextYear = year + 1;
39
- if (freq === 'A') {
40
- return `${year}/${nextYear}`;
41
- }
42
- if (freq === 'S') {
43
- const [semester] = R.match(/S\d/, id);
44
- return `${year}/${nextYear}-${semester}`;
45
- }
46
- if (freq === 'Q') {
47
- const [quarter] = R.match(/Q\d/, id);
48
- return `${year}/${nextYear}-${quarter}`;
49
- }
50
- if (freq === 'M') {
51
- const isFirstDayOfMonth = dateFns.isFirstDayOfMonth(reportedStart);
52
- if (isFirstDayOfMonth) {
53
- return R.isNil(_format) ? id : dateFns.format(reportedStart, _format, { locale: getLocale(locale) });
54
- }
55
- const [month] = R.match(/M[\d]{2}/, id);
56
- return `${year}/${nextYear}-${month}`;
57
- }
58
- const [week] = R.match(/W[\d]{2}/, id)
59
- return `${year}/${nextYear}-${week}`;
60
- };
61
-
62
- export const getReportedTimePeriod = (reportYearStart, value, freq) => {
63
- let start = new Date(R.prop('start', value));
64
- let end = dateWithoutTZ(new Date(R.prop('end', value)));
65
- if(reportYearStart.month === '01' && reportYearStart.day === '01') {
66
- return ({ start, end });
67
- }
68
- start = dateFns.addMonths(start, reportYearStart.month - 1);
69
- start = dateFns.addDays(start, reportYearStart.day - 1);
70
- if (freq === 'A') {
71
- end = dateFns.addYears(start, 1);
72
- }
73
- if (freq === 'S') {
74
- end = dateFns.addMonths(start, 6);
75
- }
76
- if (freq === 'Q') {
77
- end = dateFns.addMonths(start, 3);
78
- }
79
- if (freq === 'M') {
80
- end = dateFns.addMonths(start, 6);
81
- }
82
- if (freq === 'W' || freq === 'B') {
83
- end = dateFns.addDays(start, 7);
84
- }
85
- if (freq === 'D') {
86
- end = dateFns.addDays(start, 1);
87
- }
88
- if (freq === 'H') {
89
- end = dateFns.addHours(start, 1);
90
- }
91
- if (freq === 'N') {
92
- end = dateFns.addMinutes(start, 1);
93
- }
94
- end = dateFns.subSeconds(end, 1);
95
- return ({ start, end });
96
- };
97
-
98
- export const getReportedTimePeriodNote = (reportYearStart, start, end, freq) => {
99
- if(reportYearStart.month === '01' && reportYearStart.day === '01') {
100
- return null;
101
- }
102
- if (R.includes(freq, ['D', 'H', 'N'])) {
103
- return null;
104
- }
105
- const isFirstDayOfMonth = dateFns.isFirstDayOfMonth(start);
106
- if (freq === 'M' && isFirstDayOfMonth) {
107
- return null;
108
- }
109
- const formatedStart = dateFns.format(start, 'YYYY-MM-DD');
110
- const formatedEnd = dateFns.format(end, 'YYYY-MM-DD');
111
- return ({ value: { name: `${formatedStart} - ${formatedEnd}` } });
112
- };
113
-
114
-
115
- export const getTimePeriodLabel = (locale, format = 'YYYY MMM') => R.pipe(
116
- R.when(R.isNil, R.always('')),
117
- R.when(isValidDate, formaterPeriod(locale, format)),
118
- );
@@ -1,54 +0,0 @@
1
- import { isEmpty, isNil, get, has, reduce } from 'lodash';
2
-
3
- export const dimensionValueDisplay =
4
- (display, accessors = {}) =>
5
- (dimensionValue) => {
6
- const id = get(dimensionValue, accessors.id || 'id', '');
7
- const name = get(dimensionValue, accessors.name || 'name', '');
8
- // a non-coded component (dim | attr) has no name, names nor label
9
- // the only valid thing to display is the id
10
- if (get(dimensionValue, 'isNonCoded', false)) return id;
11
- //auto-generated flags have no id nor name
12
- if (isEmpty(id) && isEmpty(name)) return ''
13
- switch (display) {
14
- case 'label':
15
- return isEmpty(name) ? `[${id}]` : name;
16
- case 'code':
17
- return id;
18
- case 'both':
19
- if (isNil(id) || isEmpty(id)) return name;
20
- return `(${id}) ${name}`;
21
- default:
22
- return null;
23
- }
24
- };
25
-
26
- export const dimensionValueDisplayAt = (dimension, index, display) => {
27
- const dimensionValue = get(dimension, `values[${Number(index)}]`, {});
28
- return dimensionValueDisplay(display)(dimensionValue);
29
- };
30
-
31
- export const categoryDisplay = (
32
- splitObservationKey,
33
- dimensions,
34
- dimensionsWithValuesIndexedById,
35
- rejectedId,
36
- display,
37
- ) => {
38
- return reduce(
39
- splitObservationKey,
40
- (memo, dimensionValueIndex, dimensionIndex) => {
41
- const dimension = get(dimensions, `[${dimensionIndex}]`, {});
42
- if (
43
- has(dimensionsWithValuesIndexedById, dimension.id) &&
44
- dimension.id !== rejectedId
45
- ) {
46
- memo.push(
47
- dimensionValueDisplayAt(dimension, dimensionValueIndex, display),
48
- );
49
- }
50
- return memo;
51
- },
52
- [],
53
- ).join(' - ');
54
- };
@@ -1,65 +0,0 @@
1
- import { get, has, head, isUndefined, map, split, transform } from 'lodash';
2
- import { getRefAreaDimension } from '@sis-cc/dotstatsuite-sdmxjs';
3
- import { categoryDisplay, dimensionValueDisplay } from '../dimension-utils';
4
-
5
- const parseByAreas = (observations, refAreaDimension) => {
6
- if (isUndefined(refAreaDimension)) {
7
- return null;
8
- }
9
- const refAreaDimIndex = get(refAreaDimension, 'index');
10
- const refAreaValues = refAreaDimension.values;
11
-
12
- return transform(
13
- observations,
14
- (acc, value, key) => {
15
- const splitedKey = split(key, ':');
16
- const areaValueIndex = get(splitedKey, `[${refAreaDimIndex}]`, null);
17
- const areaValue = get(refAreaValues, `[${areaValueIndex}]`, null);
18
- const areaId = get(areaValue, 'id', null);
19
- if (!has(acc, areaId)) {
20
- acc[areaId] = [];
21
- }
22
- acc[areaId].push({ splitedKey, value, areaValueIndex });
23
- },
24
- {}
25
- );
26
- };
27
-
28
- export default ({ observations, dimensions }, dimensionsWithValuesIndexedById, topoMap, display) => {
29
- const refAreaDimension = getRefAreaDimension({ dimensions });
30
- const observationsByAreas = parseByAreas(observations, refAreaDimension);
31
- const topology = get(topoMap, 'topology', {});
32
- const areaSelection = get(topoMap, 'areaSelection', null);
33
- const topoAreas = get(topology, `objects.${areaSelection}`, null);
34
- if (!observationsByAreas || !topoAreas) {
35
- return null;
36
- }
37
- const topoAreasWithData = map(
38
- topoAreas.geometries,
39
- (areaGeometry) => {
40
- const areaObservation = head(get(observationsByAreas, get(areaGeometry, 'properties.id', null), []));
41
- const areaValueIndex = get(areaObservation, 'areaValueIndex', null);
42
- const areaValue = get(refAreaDimension, `values[${areaValueIndex}]`, null);
43
- return {
44
- ...areaGeometry,
45
- properties: {
46
- ...get(areaGeometry, 'properties', {}),
47
- label: dimensionValueDisplay(display)(areaValue),
48
- value: head(get(areaObservation, 'value', [])),
49
- category: categoryDisplay(get(areaObservation, 'splitedKey', null), dimensions, dimensionsWithValuesIndexedById, refAreaDimension.id, display),
50
- }
51
- };
52
- }
53
- );
54
- return ({
55
- objects: {
56
- areas: {
57
- type: topoAreas.type,
58
- geometries: topoAreasWithData
59
- }
60
- },
61
- arcs: topology.arcs,
62
- bbox: topology.bbox,
63
- transform: topology.transform
64
- });
65
- }
@@ -1,22 +0,0 @@
1
- import { map, each, get, omit, isArray, keys, head } from 'lodash';
2
-
3
- export default function focus(series, focusSelections) {
4
- const serie = head(series);
5
- const datapoints = get(serie, 'datapoints', []);
6
-
7
- const _datapoints = map(datapoints, (datapoint) => {
8
- let _datapoint = omit(datapoint, map(keys(focusSelections), focusKey => `${focusKey}Index`));
9
-
10
- each(focusSelections, (focusSelection, focusKey) => {
11
- const _focusKey = `${focusKey}Index`;
12
-
13
- each(isArray(focusSelection) ? focusSelection : [focusSelection], (focus, index) => {
14
- if (get(focus, 'value') === _datapoint.key) _datapoint[_focusKey] = index;
15
- });
16
- });
17
-
18
- return _datapoint;
19
- });
20
-
21
- return [{ ...serie, datapoints: _datapoints }];
22
- }
@@ -1,51 +0,0 @@
1
- import { map, sortBy, head, isEmpty, isNil, split } from 'lodash';
2
- import { categoryDisplay } from '../dimension-utils';
3
- import { getFormatedObservation } from '../observation-formater';
4
-
5
- export const getDatapoints = (
6
- keys, observations, dimensions, dimensionsWithValuesIndexedById, sortDirection, display, formaterAttrs
7
- ) => {
8
- const [categoryKey, valueKey] = keys;
9
- const sortFunc = dp => dp[valueKey] * sortDirection;
10
-
11
- return sortBy(
12
- map(
13
- observations,
14
- (observationValue, observationKey) => {
15
- const value = head(observationValue);
16
- const category = categoryDisplay(split(observationKey, ':'), dimensions, dimensionsWithValuesIndexedById, null, display);
17
- const categoryIds = categoryDisplay(split(observationKey, ':'), dimensions, dimensionsWithValuesIndexedById, null, 'code');
18
- const formatedValue = getFormatedObservation(observationValue, formaterAttrs);
19
-
20
- let key = categoryIds;
21
- if (isNil(key) || isEmpty(key)) {
22
- key = 'uniq-dp';
23
- }
24
-
25
- return { value, category, [valueKey]: value, [categoryKey]: category, key, formatedValue };
26
- }
27
- ),
28
- sortFunc
29
- );
30
- };
31
-
32
- export const series = (
33
- keys, observations, dimensions, dimensionsWithValuesIndexedById, sortDirection, display, formaterAttrs
34
- ) => {
35
- return [{
36
- datapoints: getDatapoints(
37
- keys, observations, dimensions, dimensionsWithValuesIndexedById, sortDirection, display, formaterAttrs
38
- )
39
- }]
40
- };
41
-
42
- export default (chartType, { observations, dimensions }, dimensionsWithValuesIndexedById, display, formaterAttrs) => {
43
- switch(chartType) {
44
- case 'BarChart':
45
- return series(['x', 'y'], observations, dimensions, dimensionsWithValuesIndexedById, 1, display, formaterAttrs);
46
- case 'RowChart':
47
- return series(['y', 'x'], observations, dimensions, dimensionsWithValuesIndexedById, -1, display, formaterAttrs);
48
- default:
49
- return [];
50
- }
51
- };
@@ -1,31 +0,0 @@
1
- import { reject, head, isEmpty, get, isNil, isUndefined, find } from 'lodash';
2
- import { isRefAreaDimension } from '@sis-cc/dotstatsuite-sdmxjs';
3
-
4
- export default (dimensions, ids) => {
5
- if (isEmpty(dimensions)) return;
6
-
7
- let chartDimension;
8
- const id = get(ids, 'id');
9
- if (!isNil(id)) chartDimension = find(dimensions, { id });
10
-
11
- if (isUndefined(chartDimension)) {
12
- const _dimensions = reject(dimensions, isRefAreaDimension);
13
- chartDimension = head(isEmpty(_dimensions) ? dimensions : _dimensions);
14
- }
15
-
16
- const chartDimensionId = get(chartDimension, 'id');
17
-
18
- const values = get(chartDimension, 'values', []);
19
-
20
- const xValue = find(values, value => value.id === get(ids, 'xId', null));
21
- const yValue = find(values, value => (value.id === get(ids, 'yId', null) && (value.id !== xId)));
22
- //if same xId & yId provided, xId is taken in account
23
- const xId = isUndefined(xValue) ? head(isUndefined(yValue) ? values : reject(values, yValue)).id : xValue.id;
24
- const yId = isUndefined(yValue) ? find(values, value => value.id !== xId).id : yValue.id;
25
-
26
- return {
27
- id: chartDimensionId,
28
- xId,
29
- yId,
30
- };
31
- };
@@ -1,39 +0,0 @@
1
- import { map, each, omit, get, split, reduce, isEmpty, keys } from 'lodash';
2
-
3
- export default function focus(series, focusSelections) {
4
- // scatter has only 1 serie
5
- const serie = get(series, '[0]', {});
6
-
7
- const _focusSelections = reduce(
8
- focusSelections,
9
- (memo, focusSelection, focusKey) => {
10
- if (!isEmpty(focusSelection)) memo[focusKey] = focusSelection;
11
- return memo;
12
- },
13
- {}
14
- );
15
-
16
- if (isEmpty(_focusSelections)) return series;
17
-
18
- const datapoints = get(serie, 'datapoints', []);
19
-
20
- let _datapoints = map(datapoints, (datapoint) => (
21
- omit(datapoint, map(keys(focusSelections), focusKey => `${focusKey}Index`))
22
- ));
23
-
24
- const __datapoints = map(_datapoints, (datapoint) => {
25
- each(_focusSelections, (focusSelection, focusKey) => {
26
- const _focusKey = `${focusKey}Index`;
27
-
28
- each(focusSelection, (focus, i) => {
29
- const _focus = get(focus, 'options', {});
30
- const dimensionValueId = get(datapoint, `dimensionValues.${_focus.dimensionId}.id`);
31
- if (dimensionValueId === _focus.dimensionValueId) datapoint[_focusKey] = i;
32
- });
33
- });
34
-
35
- return datapoint;
36
- });
37
-
38
- return [{ ...serie, datapoints: __datapoints }];
39
- }