@sis-cc/dotstatsuite-components 14.3.6 → 15.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 (36) hide show
  1. package/lib/app.js +2 -6
  2. package/lib/index.js +9 -18
  3. package/lib/rules/src/index.js +142 -1
  4. package/lib/rules/src/properties/index.js +2 -5
  5. package/lib/rules/src/table/preparators/prepareData.js +4 -15
  6. package/lib/rules2/src/duplicateObservations.js +22 -38
  7. package/lib/rules2/src/index.js +63 -0
  8. package/lib/viewer/src/chart.js +1 -43
  9. package/package.json +2 -2
  10. package/src/app.js +0 -2
  11. package/src/index.js +0 -1
  12. package/src/rules/src/index.js +19 -0
  13. package/src/rules/src/properties/index.js +1 -4
  14. package/src/rules/src/table/preparators/prepareData.js +2 -10
  15. package/src/rules2/src/duplicateObservations.js +25 -39
  16. package/src/rules2/src/index.js +11 -0
  17. package/src/viewer/src/chart.js +1 -32
  18. package/test/duplicateObs.test.js +83 -0
  19. package/test/mocks/table-prep-simple-duplicate--dimensions2.json +858 -0
  20. package/test/mocks/table-prep-simple-duplicate--duplicated2.json +77502 -0
  21. package/test/mocks/table-prep-simple-duplicate--observations2.json +60002 -0
  22. package/test/table-prep-duplicate-perf.test.js +8 -14
  23. package/lib/rules-driver/src/app.js +0 -152
  24. package/lib/rules-driver/src/index.js +0 -97
  25. package/src/rules-driver/README.md +0 -131
  26. package/src/rules-driver/src/app.js +0 -123
  27. package/src/rules-driver/src/index.js +0 -60
  28. package/src/rules-driver/src/mocks/data1.json +0 -332
  29. package/src/rules-driver/src/mocks/data2.json +0 -309
  30. package/test/duplicateObservations.test.js +0 -108
  31. package/test/mocks/table-prep-multi-duplicate--duplicated.json +0 -26938
  32. package/test/mocks/table-prep-multi-duplicate--indexes.json +0 -1417
  33. package/test/mocks/table-prep-multi-duplicate--observations.json +0 -20330
  34. package/test/mocks/table-prep-simple-duplicate--duplicated.json +0 -77502
  35. package/test/mocks/table-prep-simple-duplicate--indexes.json +0 -274
  36. package/test/mocks/table-prep-simple-duplicate--observations.json +0 -60002
@@ -24,10 +24,9 @@ import {
24
24
  getObservationsAdvancedAttributes,
25
25
  getSeriesAdvancedAttributes
26
26
  } from '../../../../rules2/src/getAdvancedAttributes';
27
- import { duplicateObservations } from '../../../../rules2/src/duplicateObservations';
27
+ import { duplicateObs } from '../../../../rules2/src/duplicateObservations';
28
28
  import { hierarchiseDimensionWithAdvancedHierarchy } from '../../../../rules2/src/hierarchiseDimensionWithAdvancedHierarchy';
29
29
  import { hierarchiseDimensionWithNativeHierarchy } from '../../../../rules2/src/hierarchiseDimensionWithNativeHierarchy';
30
- import { getDimensionValuesIndexes } from '../../../../rules2/src/getDimensionValuesIndexes';
31
30
 
32
31
  export const prepareData = (sdmxJson, customAttributes, unitsProps={}, _options={}) => {
33
32
  const {
@@ -172,14 +171,7 @@ export const prepareData = (sdmxJson, customAttributes, unitsProps={}, _options=
172
171
  return hierarchiseDimensionWithAdvancedHierarchy(dim, R.prop(dim.id, hierarchies));
173
172
  })(manyValuesDimensions);
174
173
 
175
- const valuesIndexes = R.reduce(
176
- (acc, dim) => ({ ...acc, [dim.__index]: getDimensionValuesIndexes(dim.values) }),
177
- {},
178
- R.values(hierarchisedDimensions)
179
- );
180
-
181
- const duplicatedObservations = duplicateObservations(observations, valuesIndexes);
182
-
174
+ const duplicatedObservations = duplicateObs(R.values(hierarchisedDimensions), observations);
183
175
  return ({
184
176
  dimensions: {
185
177
  one: oneValueDimensions,
@@ -1,45 +1,31 @@
1
1
  import * as R from 'ramda';
2
2
 
3
- export const duplicateObservations = (observations, indexes) => {
4
- return R.addIndex(R.reduce)(
5
- (acc, obs, i) => {
3
+ export const duplicateObs = (dims, observations) => {
4
+ const duplicated = R.reduce(
5
+ (obs, dim) => {
6
+ const groupedObs = R.groupBy(o => R.prop(dim.id, o.indexedDimValIds), obs);
7
+ const enhancedObs = R.addIndex(R.map)(
8
+ (value, index) => {
9
+ const matchingObs = R.propOr([], value.id, groupedObs);
6
10
 
7
- const orderedIndexes = R.addIndex(R.map)(
8
- (valueIndex, dimIndex) => R.pathOr([Number(valueIndex)], [dimIndex, valueIndex], indexes),
9
- R.propOr([], 'dimValuesIndexes', obs)
10
- );
11
-
12
- let cartesian;
13
-
14
- if (R.any(is => R.length(is) > 1)(orderedIndexes)) {
15
- cartesian = R.reduce(
16
- (acc, oInds) => {
17
- const r = R.map(
18
- i => R.map(is => R.append(i, is), acc),
19
- oInds
20
- );
21
- return R.unnest(r);
22
- },
23
- R.pipe(R.head, R.map(R.of))(orderedIndexes),
24
- R.tail(orderedIndexes)
25
- );
26
- }
27
- else {
28
- cartesian = [R.unnest(orderedIndexes)];
29
- }
30
-
31
- const duplicatedObs = R.reduce(
32
- (acc, orderedDimIndexes) => {
33
- const key = R.join(':', orderedDimIndexes);
34
- return R.assoc(key, { ...obs, orderedDimIndexes }, acc);
11
+ return R.map(
12
+ obs => R.over(
13
+ R.lensProp('orderedDimIndexes'),
14
+ _indexes => {
15
+ const indexes = R.isNil(_indexes) ? R.map(i => Number(i), obs.dimValuesIndexes) : _indexes;
16
+ return R.set(R.lensIndex(dim.__index), index)(indexes);
17
+ }
18
+ )(obs),
19
+ matchingObs
20
+ );
35
21
  },
36
- {},
37
- cartesian
22
+ dim.values
38
23
  );
39
-
40
- return R.mergeRight(acc, duplicatedObs);
24
+ return R.unnest(enhancedObs);
41
25
  },
42
- {},
43
- R.values(observations)
44
- )
45
- };
26
+ R.values(observations),
27
+ dims
28
+ );
29
+ const res = R.indexBy(R.pipe(R.prop('orderedDimIndexes'), R.join(':')), duplicated);
30
+ return res;
31
+ };
@@ -12,3 +12,14 @@ export { getNotDisplayedIds } from './getNotDisplayedIds';
12
12
  export { getHCodelistsRefs, getHCodelistsRefsInData } from './getHCodelistsRefsInData';
13
13
  export { parseHierarchicalCodelist } from './parseHierarchicalCodelist';
14
14
  export { refinePartialHierarchy } from './hierarchiseDimensionWithAdvancedHierarchy';
15
+ export { getMetadataCoordinates } from './getMetadataCoordinates';
16
+ export {
17
+ getDataflowAdvancedAttributes,
18
+ getObservationsAdvancedAttributes,
19
+ getSeriesAdvancedAttributes
20
+ } from './getAdvancedAttributes';
21
+ export { duplicateObs } from './duplicateObservations';
22
+ export { hierarchiseDimensionWithAdvancedHierarchy } from './hierarchiseDimensionWithAdvancedHierarchy';
23
+ export { hierarchiseDimensionWithNativeHierarchy } from './hierarchiseDimensionWithNativeHierarchy';
24
+ export { getDimensionValuesIndexes } from './getDimensionValuesIndexes';
25
+
@@ -1,47 +1,16 @@
1
1
  import React from 'react';
2
2
  import { branch, compose, renderComponent, withProps } from 'recompose';
3
3
  import * as R from 'ramda';
4
- import cx from 'classnames';
5
- import { makeStyles } from '@material-ui/core/styles';
6
4
  import { NoData } from '@sis-cc/dotstatsuite-visions';
7
5
  import * as charts from '../../bridge-d3-react/src';
8
- import { SCATTER } from '../../rules/src/constants';
9
6
  import filterSeriesRegardingDimensions from './chartUtils/series';
10
7
  import AxisLegend from './legends/AxisLegend';
11
8
  import { isChartNoData } from './utils';
12
9
 
13
- const useStyles = makeStyles(() => ({
14
- container: {
15
- backgroundColor: 'none',
16
- overflow: 'hidden',
17
- position: 'relative',
18
- direction: 'ltr !important',
19
- },
20
- chartContainer: {
21
- '& .rcw-chart__chart__line--x:last-of-type': {
22
- visibility: 'hidden',
23
- },
24
- '& .rcw-chart__chart__line--y:last-of-type': {
25
- visibility: 'hidden',
26
- },
27
- '& .rcw-chart__chart__axis--x': {
28
- '& .tick:last-of-type': {
29
- visibility: 'hidden',
30
- }
31
- },
32
- '& .rcw-chart__chart__axis--y': {
33
- '& .tick:last-of-type': {
34
- visibility: 'hidden',
35
- }
36
- },
37
- }
38
- }));
39
-
40
10
  const Chart = ({ options, series, type, width, getAxisOptions }) => {
41
- const classes = useStyles();
42
11
  const ChartClass = charts[type];
43
12
  return (
44
- <div className={cx({ [classes.chartContainer]: !R.equals(SCATTER, type) })}>
13
+ <div>
45
14
  {
46
15
  (R.is(Number, width) && width < 370)
47
16
  ? null
@@ -0,0 +1,83 @@
1
+ import { expect } from 'chai';
2
+ import { duplicateObs } from '../src/rules2/src/duplicateObservations';
3
+
4
+ describe('duplicate obs tests', () => {
5
+ it('simple test', () => {
6
+ const dims = [{
7
+ id: 'REF_AREA',
8
+ __index: 2,
9
+ values: [
10
+ { id: 'W' },
11
+ { id: 'OECD' },
12
+ { id: 'FRA' },
13
+ { id: 'GER' },
14
+ { id: 'EA' },
15
+ { id: 'GER' },
16
+ { id: 'FRA' },
17
+ ]
18
+ }];
19
+
20
+ const obs = {
21
+ '0:0:0': {
22
+ indexedDimValIds: { FREQ: 'A', VAR: '_T', REF_AREA: 'FRA' },
23
+ dimValuesIndexes: [0, 0, 0],
24
+ },
25
+ '0:0:1': {
26
+ indexedDimValIds: { FREQ: 'A', VAR: '_T', REF_AREA: 'EA' },
27
+ dimValuesIndexes: [0, 0, 1],
28
+ },
29
+ '0:0:2': {
30
+ indexedDimValIds: { FREQ: 'A', VAR: '_T', REF_AREA: 'OECD' },
31
+ dimValuesIndexes: [0, 0, 2],
32
+ },
33
+ '0:0:3': {
34
+ indexedDimValIds: { FREQ: 'A', VAR: '_T', REF_AREA: 'GER' },
35
+ dimValuesIndexes: [0, 0, 3],
36
+ },
37
+ '0:0:4': {
38
+ indexedDimValIds: { FREQ: 'A', VAR: '_T', REF_AREA: 'W' },
39
+ dimValuesIndexes: [0, 0, 4],
40
+ },
41
+ };
42
+
43
+ const expected = {
44
+ '0:0:0': {
45
+ indexedDimValIds: { FREQ: 'A', VAR: '_T', REF_AREA: 'W' },
46
+ orderedDimIndexes: [0, 0, 0],
47
+ dimValuesIndexes: [0, 0, 4],
48
+ },
49
+ '0:0:1': {
50
+ indexedDimValIds: { FREQ: 'A', VAR: '_T', REF_AREA: 'OECD' },
51
+ orderedDimIndexes: [0, 0, 1],
52
+ dimValuesIndexes: [0, 0, 2],
53
+ },
54
+ '0:0:2': {
55
+ indexedDimValIds: { FREQ: 'A', VAR: '_T', REF_AREA: 'FRA' },
56
+ orderedDimIndexes: [0, 0, 2],
57
+ dimValuesIndexes: [0, 0, 0],
58
+ },
59
+ '0:0:3': {
60
+ indexedDimValIds: { FREQ: 'A', VAR: '_T', REF_AREA: 'GER' },
61
+ orderedDimIndexes: [0, 0, 3],
62
+ dimValuesIndexes: [0, 0, 3],
63
+ },
64
+ '0:0:4': {
65
+ indexedDimValIds: { FREQ: 'A', VAR: '_T', REF_AREA: 'EA' },
66
+ orderedDimIndexes: [0, 0, 4],
67
+ dimValuesIndexes: [0, 0, 1],
68
+ },
69
+ '0:0:5': {
70
+ indexedDimValIds: { FREQ: 'A', VAR: '_T', REF_AREA: 'GER' },
71
+ orderedDimIndexes: [0, 0, 5],
72
+ dimValuesIndexes: [0, 0, 3],
73
+ },
74
+ '0:0:6': {
75
+ indexedDimValIds: { FREQ: 'A', VAR: '_T', REF_AREA: 'FRA' },
76
+ orderedDimIndexes: [0, 0, 6],
77
+ dimValuesIndexes: [0, 0, 0],
78
+ }
79
+ };
80
+
81
+ expect(duplicateObs(dims, obs)).to.deep.equal(expected);
82
+ });
83
+ });