@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,30 +0,0 @@
1
- import * as R from 'ramda';
2
- import { getChartOptions } from '../../../rules/src/chart/getChartOptions';
3
- import { getFontFromTheme, getOptionsFromFont } from '../utils';
4
-
5
- export default (options, data, type, theme, timeFormats, locale) => {
6
- const axisFontOptions = R.pipe(getFontFromTheme(['axis']), getOptionsFromFont)(theme);
7
- const annotationFontOptions = R.pipe(getFontFromTheme(['annotation']), getOptionsFromFont)(theme);
8
- const tooltipFonts = {
9
- primary: getFontFromTheme(['tooltip', 'primary'])(theme),
10
- secondary: getFontFromTheme(['tooltip', 'secondary'])(theme)
11
- };
12
- const optionsWithFonts = R.evolve({
13
- axis: R.pipe(
14
- R.over(
15
- R.lensPath(['x', 'font']),
16
- R.pipe(R.when(R.isNil, R.always({})), R.mergeRight(axisFontOptions))
17
- ),
18
- R.over(
19
- R.lensPath(['y', 'font']),
20
- R.pipe(R.when(R.isNil, R.always({})), R.mergeRight(axisFontOptions))
21
- )
22
- ),
23
- serie: R.over(
24
- R.lensPath(['annotation', 'font']),
25
- R.pipe(R.when(R.isNil, R.always({})), R.mergeRight(annotationFontOptions))
26
- )
27
- })(options);
28
-
29
- return getChartOptions(data, type, optionsWithFonts, tooltipFonts, timeFormats, locale);
30
- };
@@ -1,51 +0,0 @@
1
- import * as R from 'ramda';
2
- import { H_SYMBOL, TIMELINE, V_SYMBOL } from '../../../rules/src/constants';
3
-
4
- const isFocused = (obj) => {
5
- const highlightIndex = R.propOr(-1, 'highlightIndex', obj);
6
- const baselineIndex = R.propOr(-1, 'baselineIndex', obj);
7
- return ((highlightIndex > -1) || (baselineIndex > -1));
8
- };
9
-
10
- const sampleFilterSeries = (series) => (
11
- R.map(
12
- serie => {
13
- const _datapoints = R.filter(isFocused, serie.datapoints);
14
- return { ...serie, datapoints: _datapoints };
15
- },
16
- series
17
- )
18
- );
19
-
20
- const lineFilterSeries = R.filter(isFocused);
21
-
22
- export default (series, type, options) => {
23
- const responsiveFocusFilter = R.pathOr(true, ['serie', 'responsiveFocusFilter'], options);
24
- if (!responsiveFocusFilter) {
25
- return series;
26
- }
27
- const height = R.path(['base', 'height'], options);
28
- const width = R.path(['base', 'width'], options);
29
- const minWidth = R.path(['base', 'minDisplayWidth'], options);
30
- const minHeight = R.path(['base', 'minDisplayHeight'], options);
31
- let filtered;
32
- if (type === H_SYMBOL) {
33
- if (height < minHeight) {
34
- filtered = sampleFilterSeries(series);
35
- return R.isEmpty(filtered[0].datapoints) ? series : filtered;
36
- }
37
- }
38
- else if (type === TIMELINE) {
39
- if (height < minHeight) {
40
- filtered = lineFilterSeries(series);
41
- return R.isEmpty(filtered) ? series : filtered;
42
- }
43
- }
44
- else if (type === V_SYMBOL) {
45
- if (width < minWidth) {
46
- filtered = sampleFilterSeries(series);
47
- return R.isEmpty(filtered[0].datapoints) ? series : filtered;
48
- }
49
- }
50
- return series;
51
- };
@@ -1,24 +0,0 @@
1
- import React from 'react';
2
- import * as R from 'ramda';
3
- import { DataFooter } from '@sis-cc/dotstatsuite-visions';
4
- import ChartLegends from './legends/ChartLegends';
5
- import { isChartNoData } from './utils';
6
-
7
- const Footer = ({ type, chartData, source, logo, copyright, chartOptions, isSticky, target, width }) => {
8
- const hasNoLegend = type === 'table' || isChartNoData({ data: chartData, type });
9
- const legend = hasNoLegend ? null : <ChartLegends data={chartData} options={chartOptions} type={type} width={width} />;
10
-
11
- return (
12
- <div {...(target ? { ref: target } : {})}>
13
- <DataFooter
14
- source={source}
15
- logo={logo}
16
- copyright={copyright}
17
- legend={legend}
18
- isSticky={isSticky}
19
- />
20
- </div>
21
- );
22
- };
23
-
24
- export default Footer;
@@ -1,10 +0,0 @@
1
- import React from 'react';
2
- import { DataHeader } from '@sis-cc/dotstatsuite-visions';
3
-
4
- const Header = ({ target, ...props }) => (
5
- <div {...(target ? { ref: target } : {})}>
6
- <DataHeader {...props} />
7
- </div>
8
- );
9
-
10
- export default Header;
@@ -1,158 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
- import * as R from 'ramda';
3
- import useSize from '@react-hook/size';
4
- import { Loading, NoData, TableHtml5 } from '@sis-cc/dotstatsuite-visions';
5
- import { makeStyles, useTheme } from '@mui/styles';
6
- import getChartOptions from './chartUtils/options';
7
- import Header from './header';
8
- import Chart from './chart';
9
- import Footer from './footer';
10
- import { isChartDataNotReady } from './utils';
11
-
12
- const useStyles = makeStyles(() => ({
13
- container: {
14
- borderColor: '#007bc7',
15
- borderBottomWidth: 1,
16
- borderLeftWidth: 0,
17
- borderTopWidth: 1,
18
- borderRightWidth: 0,
19
- borderStyle: 'solid',
20
- '& svg text::selection': {
21
- background: 'none'
22
- }
23
- },
24
- tableContainer: {
25
- minWidth: '100%',
26
- minHeight: '100%',
27
- willChange: 'transform, opacity'
28
- },
29
- chartContainer: {
30
- width: ({ fixedWidth }) => fixedWidth || '100%',
31
- height: ({ fixedHeight }) => fixedHeight || '100%',
32
- overflow: 'hidden',
33
- position: 'relative'
34
- }
35
- }));
36
-
37
- const ViewContent = ({ loading, loadingProps={}, type, width, errorMessage, ...rest }) => {
38
- if (loading)
39
- return <Loading message={loading} {...loadingProps} />;
40
- if (errorMessage)
41
- return <NoData message={errorMessage} />;
42
-
43
- if (type === 'table') {
44
- const tableProps = R.propOr({}, 'tableProps', rest);
45
- const hasNoObs = R.pipe(R.prop('cells'), R.anyPass([R.isNil, R.isEmpty]))(tableProps);
46
- if (hasNoObs) return <Loading />;
47
-
48
- return <TableHtml5 isRtl={R.prop('isRtl', rest)} {...tableProps} />;
49
- }
50
- if (isChartDataNotReady({ data: R.prop('chartData', rest) }) || !width) {
51
- return <Loading />;
52
- }
53
- return (
54
- <Chart
55
- data={R.prop('chartData', rest)}
56
- getAxisOptions={R.prop('getAxisOptions', rest)}
57
- heightOffsets={R.prop('heightOffsets', rest)}
58
- options={R.prop('chartOptions', rest)}
59
- type={type}
60
- width={width}
61
- />
62
- );
63
- };
64
-
65
- const Viewer = ({ type, targets={}, width, ...rest }) => {
66
- const classes = useStyles({
67
- fixedWidth: rest.fixedWidth,
68
- fixedHeight: rest.fixedHeight
69
- });
70
-
71
- return (
72
- <div
73
- {...(targets.viewer ? { ref: targets.viewer } : {})}
74
- className={[
75
- classes.container,
76
- type === 'table' ? classes.tableContainer : classes.chartContainer
77
- ]}
78
- >
79
- <Header
80
- target={targets.header}
81
- {...R.propOr({}, 'headerProps', rest)}
82
- />
83
- <ViewContent type={type} width={width} {...rest} />
84
- <Footer
85
- width={width}
86
- target={targets.footer}
87
- type={type}
88
- chartData={R.prop('chartData', rest)}
89
- chartOptions={R.prop('chartOptions', rest)}
90
- {...R.prop('footerProps', rest)}
91
- />
92
- </div>
93
- );
94
- };
95
-
96
- const defaultChartHeight = chartOptions => R.pipe(
97
- R.path(['base', 'height']),
98
- h => (R.isNil(h) || isNaN(h)) ? 0 : h
99
- )(chartOptions);
100
-
101
- const ViewerWrapper = ({ chartOptions, type, getResponsiveSize, ...props }) => {
102
- const theme = useTheme();
103
- const viewerTarget = React.useRef(null);
104
- const headerTarget = React.useRef(null);
105
- const footerTarget = React.useRef(null);
106
- const [viewerWidth, viewerHeight] = useSize(viewerTarget);
107
- const [_, headerHeight] = useSize(headerTarget, { initialHeight: -1 });
108
- const [___, footerHeight] = useSize(footerTarget, { initialHeight: -1 });
109
- const [chartSvgHeight, setChartSvgHeight] = useState(0);
110
- const defChartHeight = defaultChartHeight(chartOptions);
111
-
112
- useEffect(() => {
113
- if (R.is(Function, getResponsiveSize) && viewerWidth && headerHeight !== -1 && footerHeight !== -1) {
114
- getResponsiveSize({
115
- responsiveWidth: viewerWidth,
116
- responsiveHeight: viewerHeight
117
- });
118
- }
119
- }, [viewerWidth, viewerHeight]);
120
-
121
- useEffect(() => {
122
- if (headerHeight !== -1 && footerHeight !== -1 && !isNaN(headerHeight) && !isNaN(footerHeight)) {
123
- const nextHeight = defChartHeight - headerHeight - footerHeight - 2;
124
- setChartSvgHeight(nextHeight);
125
- }
126
- }, [headerHeight, footerHeight, defChartHeight]);
127
-
128
-
129
- if (type === 'table') {
130
- return <Viewer
131
- {...props}
132
- width={viewerWidth}
133
- type={type}
134
- />;
135
- }
136
-
137
- const preparedChartOptions = R.pipe(
138
- R.over(R.lensPath(['base', 'width']), R.when(R.anyPass([R.isNil, isNaN]), R.always(viewerWidth || 0))),
139
- R.set(R.lensPath(['base', 'height']), chartSvgHeight),
140
- chartOptions => getChartOptions(chartOptions, props.chartData, type, theme, props.timeFormats, props.locale),
141
- )(chartOptions);
142
-
143
- return <Viewer
144
- {...props}
145
- type={type}
146
- chartOptions={preparedChartOptions}
147
- fixedWidth={R.path(['base', 'width'], chartOptions)}
148
- fixedHeight={defChartHeight}
149
- targets={{
150
- viewer: viewerTarget,
151
- header: headerTarget,
152
- footer: footerTarget
153
- }}
154
- width={viewerWidth}
155
- />;
156
- };
157
-
158
- export default ViewerWrapper;
@@ -1,41 +0,0 @@
1
- import React from 'react';
2
- import * as R from 'ramda';
3
- import makeStyles from '@mui/styles/makeStyles';
4
- import { SCATTER } from '../../../rules/src/constants';
5
- import { getFontFromTheme } from '../utils';
6
-
7
- const useStyles = makeStyles(theme => {
8
- const legendFont = getFontFromTheme(['axisLegend'])(theme);
9
- return ({
10
- xLegend: legendFont,
11
- yLegend: {
12
- ...legendFont,
13
- left: 10,
14
- position: 'absolute',
15
- zIndex: 1,
16
- }
17
- })
18
- });
19
-
20
- const getAxisLabel = axis => R.pipe(
21
- R.propOr([], 'series'),
22
- R.head,
23
- R.when(R.isNil, R.always({})),
24
- R.path(['dimensionValues', axis, 'name'])
25
- );
26
-
27
- const AxisLegend = ({ axis, data, type }) => {
28
- const classes = useStyles();
29
- if (!R.equals(SCATTER, type))
30
- return null;
31
- switch (axis) {
32
- case 'x':
33
- return <span className={classes.xLegend}>→ {getAxisLabel('x')(data)}</span>;
34
- case 'y':
35
- return <span className={classes.yLegend}>↑ {getAxisLabel('y')(data)}</span>;
36
- default:
37
- return null;
38
- }
39
- };
40
-
41
- export default AxisLegend;
@@ -1,66 +0,0 @@
1
- import React from 'react';
2
- import * as R from 'ramda';
3
- import numeral from 'numeral';
4
- import { computeOptions } from '@sis-cc/dotstatsuite-d3-charts';
5
- import { ChoroplethLegend } from '../../../bridge-d3-react/src';
6
- import { useTheme } from '@mui/material/styles';
7
- import AxisLegend from './AxisLegend';
8
- import FocusLegend from './FocusLegend';
9
- import SeriesLegend from './SeriesLegend';
10
- import { CHORO } from '../../../rules/src/constants';
11
- import { getFontFromTheme, getOptionsFromFont } from '../utils';
12
-
13
-
14
- const ChoroLegend = ({ type, options, data }) => {
15
- if (type !== CHORO) {
16
- return null;
17
- }
18
- const theme = useTheme();
19
- const fontOptions = R.pipe(getFontFromTheme(['mapLegend']), getOptionsFromFont)(theme);
20
- const legendOptions = R.mergeDeepLeft(
21
- options,
22
- {
23
- legend: {
24
- choropleth: {
25
- width: 300,
26
- height: 30,
27
- margin: { left: 15, right: 15 },
28
- axis: {
29
- thickness: 0,
30
- orient: 'bottom',
31
- font: fontOptions,
32
- tick: {
33
- size: 5,
34
- thickness: 0
35
- },
36
- format: {
37
- proc: d => numeral(d).format('0,0.[00]')
38
- }
39
- }
40
- }
41
- }
42
- }
43
- );
44
-
45
- return (
46
- <ChoroplethLegend options={legendOptions} data={data.series} />
47
- );
48
- }
49
-
50
- const ChartLegends = ({ data, options, type, width }) => {
51
- const engineOptions = R.pipe(
52
- R.assocPath(['serie', 'stacked', 'layerSeries'], R.pathOr([], ['series', 0, 'layerSeries'], data)),
53
- computeOptions
54
- )(options);
55
-
56
- return (
57
- <div>
58
- <AxisLegend axis="x" data={data} type={type} />
59
- <FocusLegend data={data} options ={engineOptions} type={type} width={width} />
60
- <SeriesLegend data={data} options={engineOptions} type={type} />
61
- <ChoroLegend data={data} options={options} type={type} />
62
- </div>
63
- );
64
- };
65
-
66
- export default ChartLegends;
@@ -1,63 +0,0 @@
1
- import React from 'react';
2
- import * as R from 'ramda';
3
- import Legend from './Legend';
4
- import { SCATTER, TIMELINE } from '../../../rules/src/constants';
5
-
6
- export const REDUCED_THRESHOLD = 160;
7
-
8
- const scatterRenderer = ({ color }) => (
9
- <svg width='12' height='14'>
10
- <circle cx='7' cy='7' r='4' stroke={color} fill={color} />
11
- </svg>
12
- );
13
-
14
- const lineRenderer = ({ color }) => (
15
- <svg width='12' height='14'>
16
- <line x1='0' y1='7' x2='11' y2='7' stroke={color} strokeWidth='2' />
17
- </svg>
18
- );
19
-
20
- const FocusLegend = ({ data, options, type, width }) => {
21
- if (width < REDUCED_THRESHOLD) {
22
- return null;
23
- }
24
-
25
- const itemRenderer = R.pipe(
26
- R.when(R.always(type === SCATTER), R.always(scatterRenderer)),
27
- R.when(R.always(type === TIMELINE), R.always(lineRenderer)),
28
- )(null);
29
-
30
- const getItemLabel = R.ifElse(
31
- R.equals(SCATTER),
32
- R.always(R.pipe(R.prop('label'), R.split(' - '), R.last)),
33
- R.always(R.prop('label'))
34
- )(type);
35
-
36
- const items = R.pipe(
37
- R.pathOr({}, ['share', 'focused']),
38
- R.mapObjIndexed((selection, key) => {
39
- if (R.isNil(selection)) {
40
- return null;
41
- }
42
- const colors = R.pathOr([], ['serie', `${key}Colors`], options);
43
- const nColors = R.length(colors);
44
- return R.pipe(
45
- R.addIndex(R.map)((entry, index) => {
46
- if (entry.value === 'uniq-dp') {
47
- return null;
48
- }
49
- const color = R.nth(index % nColors, colors);
50
- return ({ color, label: getItemLabel(entry) });
51
- }),
52
- R.filter(R.identity)
53
- )(selection);
54
- }),
55
- R.props(['baseline', 'highlight']),
56
- R.filter(R.identity),
57
- R.unnest
58
- )(data)
59
-
60
- return (<Legend items={items} itemRenderer={itemRenderer} />);
61
- }
62
-
63
- export default FocusLegend;
@@ -1,46 +0,0 @@
1
- import React from 'react';
2
- import * as R from 'ramda';
3
- import makeStyles from '@mui/styles/makeStyles';
4
- import { getFontFromTheme } from '../utils';
5
-
6
- const useStyles = makeStyles(theme => ({
7
- legend: {
8
- ...getFontFromTheme(['chartLegend'])(theme),
9
- display: 'flex',
10
- flexDirection: 'row',
11
- flexWrap: 'wrap',
12
- justifyContent: 'flex-start',
13
- },
14
- entry: {
15
- alignItems: 'center',
16
- display: 'flex',
17
- flexDirection: 'row',
18
- flexWrap: 'wrap',
19
- marginLeft: 10,
20
- },
21
- text: { marginLeft: 5 }
22
- }));
23
-
24
- const Legend = ({ items, itemRenderer }) => {
25
- if (!R.is(Function, (itemRenderer)) || R.isNil(items) || R.isEmpty(items)) {
26
- return null;
27
- }
28
-
29
- const classes = useStyles();
30
-
31
- const legendEntries = R.addIndex(R.map)(
32
- (entry, index) => {
33
- const style = R.isNil(entry.color) ? {} : { color: entry.color };
34
- return (
35
- <div className={classes.entry} style={style} key={index}>
36
- {itemRenderer(entry)}
37
- <div className={classes.text} >{R.prop('label', entry)}</div>
38
- </div>
39
- );
40
- }
41
- )(items);
42
-
43
- return (<div className={classes.legend} >{legendEntries}</div>);
44
- };
45
-
46
- export default Legend;
@@ -1,78 +0,0 @@
1
- import React from 'react';
2
- import * as R from 'ramda';
3
- import Legend from './Legend';
4
- import { H_SYMBOL, STACKED_BAR, STACKED_ROW, V_SYMBOL } from '../../../rules/src/constants';
5
-
6
- const getSymbolSeriesItems = ({ data, options }) => {
7
- const symbolMarkers = R.path(['serie', 'symbol', 'markers'], options);
8
- const nMarkers = R.length(symbolMarkers);
9
- const markerSize = Number(R.path(['serie', 'symbol', 'markerDefaultSize'], options));
10
- const strokeWidth = R.path(['serie', 'symbol', 'markerDefaultStrokeWidth'], options);
11
- const size = Math.round(Math.sqrt(markerSize)) + 8;
12
- return R.pipe(
13
- R.pathOr([], ['series', 0, 'symbolValues']),
14
- R.addIndex(R.map)(
15
- (label, serieIndex) => {
16
- const marker = R.nth(serieIndex % nMarkers, symbolMarkers);
17
- return ({
18
- d: marker.path(markerSize),
19
- transform: `translate(${size / 2}, ${size / 2}) rotate(${R.propOr(0, 'rotate', marker)})`,
20
- style: R.pipe(
21
- R.mergeRight({ strokeWidth }),
22
- R.when(
23
- s => s.fill !== s.stroke,
24
- R.assoc('fill', 'white')
25
- )
26
- )(marker.style),
27
- size,
28
- label
29
- })
30
- }
31
- )
32
- )(data);
33
- };
34
-
35
- const getStackedSeriesItems = R.pipe(
36
- R.pathOr([], ['options', 'serie', 'stacked', 'layerSeries']),
37
- R.when(s => R.length(s) === 1, R.always([]))
38
- );
39
-
40
- const stackedLayerRenderer = ({ baseColor }) => (
41
- <svg width="21" height="14">
42
- <rect x='0' y='0' width='21' height='14' fill={baseColor} />
43
- </svg>
44
- );
45
-
46
- const symbolRenderer = ({ d, size, style, transform }) => (
47
- <svg width={size} height={size}>
48
- <path
49
- d={d}
50
- transform={transform}
51
- {...style}
52
- />
53
- </svg>
54
- );
55
-
56
- // stacked entries = [{ label, color }];
57
-
58
- const SeriesLegend = ({ data, options, type }) => {
59
- const itemRenderer = R.pipe(
60
- R.when(R.always(type === H_SYMBOL || type === V_SYMBOL), R.always(symbolRenderer)),
61
- R.when(R.always(type === STACKED_BAR || type === STACKED_ROW), R.always(stackedLayerRenderer))
62
- )(null);
63
-
64
- if (R.isNil(itemRenderer)) {
65
- return null;
66
- }
67
-
68
- const seriesItems = R.pipe(
69
- R.when(R.always(type === H_SYMBOL || type === V_SYMBOL), getSymbolSeriesItems),
70
- R.when(R.always(type === STACKED_BAR || type === STACKED_ROW), getStackedSeriesItems)
71
- )({ data, options });
72
-
73
- return (
74
- <Legend items={seriesItems} itemRenderer={itemRenderer} />
75
- );
76
- };
77
-
78
- export default SeriesLegend;
@@ -1,21 +0,0 @@
1
- import * as R from 'ramda';
2
-
3
- export const isChartNoData = R.anyPass([
4
- R.pipe(R.path(['data', 'series']), R.isEmpty),
5
- R.allPass([
6
- R.pipe(R.prop('type'), R.equals('ChoroplethChart'), R.not),
7
- R.pipe(R.path(['data', 'series', 0, 'datapoints']), R.anyPass([R.isNil, R.isEmpty]))
8
- ])
9
- ]);
10
-
11
- export const isChartDataNotReady = R.pipe(R.path(['data', 'series']), R.isNil);
12
-
13
- export const getFontFromTheme = customPath => R.converge(
14
- R.mergeRight,
15
- [R.pathOr({}, ['mixins', 'chart', 'main']), R.pathOr({}, R.concat(['mixins', 'chart'], customPath))]
16
- );
17
-
18
- export const getOptionsFromFont = R.pipe(
19
- R.props(['color', 'fontFamily', 'fontSize', 'fontWeight']),
20
- ([color, family, size, weight]) => ({ color, size, family, weight })
21
- );