@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.
- package/dist/dotstatsuite-components.js +38112 -0
- package/package.json +4 -1
- package/.editorconfig +0 -19
- package/.gitlab-ci.yml +0 -48
- package/prettier.config.js +0 -13
- package/src/app.js +0 -13
- package/src/bridge-d3-react/README.md +0 -42
- package/src/bridge-d3-react/src/app.js +0 -64
- package/src/bridge-d3-react/src/index.js +0 -17
- package/src/bridge-d3-react/src/mock-choro.js +0 -394
- package/src/bridge-d3-react/src/react-chart-factory.js +0 -65
- package/src/index.js +0 -12
- package/src/rules/README.md +0 -23
- package/src/rules/src/chart/getAxisOptions.js +0 -258
- package/src/rules/src/chart/getBaseOptions.js +0 -84
- package/src/rules/src/chart/getChartOptions.js +0 -118
- package/src/rules/src/chart/getGridOptions.js +0 -52
- package/src/rules/src/chart/getTooltipOptions.js +0 -230
- package/src/rules/src/constants.js +0 -64
- package/src/rules/src/date.js +0 -118
- package/src/rules/src/dimension-utils.js +0 -54
- package/src/rules/src/factories/choro-series.js +0 -65
- package/src/rules/src/factories/sample-focus.js +0 -22
- package/src/rules/src/factories/sample-series.js +0 -51
- package/src/rules/src/factories/scatter-dimension.js +0 -31
- package/src/rules/src/factories/scatter-focus.js +0 -39
- package/src/rules/src/factories/scatter-series.js +0 -94
- package/src/rules/src/factories/stacked-dimension.js +0 -29
- package/src/rules/src/factories/stacked-series.js +0 -185
- package/src/rules/src/factories/symbol-dimension.js +0 -29
- package/src/rules/src/factories/symbol-series.js +0 -62
- package/src/rules/src/factories/timeline-focus.js +0 -18
- package/src/rules/src/factories/timeline-series.js +0 -91
- package/src/rules/src/get-values-enhanced.js +0 -134
- package/src/rules/src/header/getDefaultSubtitle.js +0 -40
- package/src/rules/src/header/getHeaderUnits.js +0 -17
- package/src/rules/src/header/getSubtitleFlags.js +0 -43
- package/src/rules/src/header/getTitleFlags.js +0 -8
- package/src/rules/src/header/index.js +0 -4
- package/src/rules/src/index.js +0 -398
- package/src/rules/src/layout.js +0 -113
- package/src/rules/src/observation-formater.js +0 -83
- package/src/rules/src/preparators/enhanceObservations.js +0 -152
- package/src/rules/src/preparators/formatValue.js +0 -84
- package/src/rules/src/preparators/getObservations.js +0 -19
- package/src/rules/src/preparators/getReportingYearStart.js +0 -16
- package/src/rules/src/properties/errors.js +0 -19
- package/src/rules/src/properties/focus.js +0 -69
- package/src/rules/src/properties/getAvailableChartTypes.js +0 -34
- package/src/rules/src/properties/getHeaderProps.js +0 -74
- package/src/rules/src/properties/getInformationsStateFromNewProps.js +0 -47
- package/src/rules/src/properties/getObservationsType.js +0 -29
- package/src/rules/src/properties/getStringifiedSubtitle.js +0 -6
- package/src/rules/src/properties/index.js +0 -424
- package/src/rules/src/properties/information.js +0 -84
- package/src/rules/src/properties/linear.js +0 -129
- package/src/rules/src/properties/scatter.js +0 -158
- package/src/rules/src/properties/stacked.js +0 -98
- package/src/rules/src/properties/symbol.js +0 -79
- package/src/rules/src/properties/utils.js +0 -110
- package/src/rules/src/sdmx-data/index.js +0 -39
- package/src/rules/src/table/factories/getCellValue.js +0 -50
- package/src/rules/src/table/index.js +0 -1
- package/src/rules/src/v8-transformer.js +0 -176
- package/src/rules/test/extractSdmxArtefacts.js +0 -26
- package/src/rules/test/get-values-enhanced.test.js +0 -127
- package/src/rules/test/oecd-HEALTH_PROT-no-freq.json +0 -2903
- package/src/rules/test/oecd-HEALTH_PROT-parsed.js +0 -398
- package/src/rules/test/oecd-HEALTH_PROT-wrong-freq.json +0 -2913
- package/src/rules/test/oecd-HEALTH_PROT.json +0 -2913
- package/src/rules/test/oecd-KEI.json +0 -372
- package/src/rules/test/scatter-property.js +0 -455
- package/src/rules/test/stacked-property.js +0 -273
- package/src/rules/test/symbol-property.js +0 -262
- package/src/rules/test/v8-transformer.test.js +0 -90
- package/src/rules2/src/applyHierarchicalCodesToDim.js +0 -149
- package/src/rules2/src/combinedValuesDisplay.js +0 -74
- package/src/rules2/src/constants.js +0 -6
- package/src/rules2/src/duplicateObservations.js +0 -35
- package/src/rules2/src/enhanceObservations.js +0 -95
- package/src/rules2/src/getAdvAttrSeriesAtCoordinates.js +0 -29
- package/src/rules2/src/getAttributesSeries.js +0 -36
- package/src/rules2/src/getCombinationDefinitions.js +0 -47
- package/src/rules2/src/getDataflowAttributes.js +0 -23
- package/src/rules2/src/getDataflowTooltipAttributesIds.js +0 -31
- package/src/rules2/src/getDimensionValuesIndexes.js +0 -13
- package/src/rules2/src/getHCodelistsRefsInData.js +0 -32
- package/src/rules2/src/getHeaderCombinations.js +0 -48
- package/src/rules2/src/getHeaderCoordinates.js +0 -7
- package/src/rules2/src/getHeaderSubtitle.js +0 -34
- package/src/rules2/src/getHeaderTitle.js +0 -15
- package/src/rules2/src/getMSDInformations.js +0 -23
- package/src/rules2/src/getManyValuesDimensions.js +0 -34
- package/src/rules2/src/getMetadataCoordinates.js +0 -37
- package/src/rules2/src/getMetadataStructureFromData.js +0 -17
- package/src/rules2/src/getNotDisplayedIds.js +0 -53
- package/src/rules2/src/getOneValueDimensions.js +0 -34
- package/src/rules2/src/getSeriesCombinations.js +0 -24
- package/src/rules2/src/hasCellMetadata.js +0 -14
- package/src/rules2/src/hierarchiseDimensionWithAdvancedHierarchy2.js +0 -57
- package/src/rules2/src/hierarchiseDimensionWithNativeHierarchy2.js +0 -35
- package/src/rules2/src/index.js +0 -50
- package/src/rules2/src/parseAttributes.js +0 -41
- package/src/rules2/src/parseCombinations.js +0 -102
- package/src/rules2/src/parseHierarchicalCodelist.js +0 -48
- package/src/rules2/src/parseMetadataSeries.js +0 -117
- package/src/rules2/src/prepareData.js +0 -73
- package/src/rules2/src/refineAttributes.js +0 -16
- package/src/rules2/src/refineDimensions.js +0 -18
- package/src/rules2/src/refineMetadataCoordinates.js +0 -28
- package/src/rules2/src/refineTimePeriod.js +0 -127
- package/src/rules2/src/sdmx3.0DataFormatPatch.js +0 -9
- package/src/rules2/src/table/declineObservationsOverAttributes.js +0 -32
- package/src/rules2/src/table/getCells.js +0 -93
- package/src/rules2/src/table/getCellsAttributesIds.js +0 -38
- package/src/rules2/src/table/getCellsMetadataCoordinates.js +0 -13
- package/src/rules2/src/table/getCombinationDimensionsData.js +0 -39
- package/src/rules2/src/table/getCuratedCells.js +0 -33
- package/src/rules2/src/table/getFlagsAndNotes.js +0 -23
- package/src/rules2/src/table/getIndexedCombinationsByDisplay.js +0 -16
- package/src/rules2/src/table/getLayout.js +0 -84
- package/src/rules2/src/table/getLayoutData2.js +0 -198
- package/src/rules2/src/table/getSortedLayoutIndexes.js +0 -124
- package/src/rules2/src/table/getTableLabelAccessor.js +0 -9
- package/src/rules2/src/table/getTableLayoutIds.js +0 -314
- package/src/rules2/src/table/getTableProps.js +0 -75
- package/src/rules2/src/table/parseSeriesIndexesHierarchies.js +0 -79
- package/src/rules2/src/table/parseValueHierarchy.js +0 -33
- package/src/rules2/src/table/refineLayoutSize2.js +0 -321
- package/src/rules2/src/utils.js +0 -37
- package/src/viewer/mocks/bar.js +0 -33
- package/src/viewer/mocks/gpp-symbol.js +0 -93
- package/src/viewer/mocks/gpp-time.js +0 -1103
- package/src/viewer/mocks/row.js +0 -39
- package/src/viewer/mocks/scatter.js +0 -93
- package/src/viewer/mocks/stack.js +0 -161
- package/src/viewer/src/app/leg.js +0 -36
- package/src/viewer/src/app/nodata-res.js +0 -22
- package/src/viewer/src/app/nodata-sized.js +0 -23
- package/src/viewer/src/app/one-table-cell.js +0 -70
- package/src/viewer/src/app/table.js +0 -423
- package/src/viewer/src/app/use-case-1.js +0 -33
- package/src/viewer/src/app/use-case-2.js +0 -38
- package/src/viewer/src/app/use-case-3.js +0 -18
- package/src/viewer/src/app.js +0 -116
- package/src/viewer/src/chart.js +0 -52
- package/src/viewer/src/chartUtils/options.js +0 -30
- package/src/viewer/src/chartUtils/series.js +0 -51
- package/src/viewer/src/footer.js +0 -24
- package/src/viewer/src/header.js +0 -10
- package/src/viewer/src/index.js +0 -158
- package/src/viewer/src/legends/AxisLegend.js +0 -41
- package/src/viewer/src/legends/ChartLegends.js +0 -66
- package/src/viewer/src/legends/FocusLegend.js +0 -63
- package/src/viewer/src/legends/Legend.js +0 -46
- package/src/viewer/src/legends/SeriesLegend.js +0 -78
- package/src/viewer/src/utils.js +0 -21
- package/test/applyHierarchicalCodesToDim.test.js +0 -160
- package/test/combinedValuesDisplay.test.js +0 -66
- package/test/duplicateObs.test.js +0 -118
- package/test/enhanceObservations2.test.js +0 -257
- package/test/getAttributesSeries.test.js +0 -66
- package/test/getAxisOptions.test.js +0 -309
- package/test/getBaseOptions.test.js +0 -77
- package/test/getCellValue.test.js +0 -32
- package/test/getCells.test.js +0 -178
- package/test/getCellsMetadataCoordinates.test.js +0 -40
- package/test/getCombinationDefinitions.test.js +0 -104
- package/test/getCombinationDimensionsData.test.js +0 -99
- package/test/getDataflowAttributes.test.js +0 -23
- package/test/getDataflowTooltipAttributesIds.test.js +0 -146
- package/test/getDimensionValuesIndexes.test.js +0 -33
- package/test/getGridOptions.test.js +0 -65
- package/test/getHCodelistsRefs.test.js +0 -23
- package/test/getHeaderCombinations.test.js +0 -62
- package/test/getHeaderTitle.test.js +0 -25
- package/test/getLayout.test.js +0 -54
- package/test/getLayoutData2.test.js +0 -535
- package/test/getMSDInformations.test.js +0 -35
- package/test/getMetadataCoordinates.test.js +0 -0
- package/test/getNotDisplayedIds.test.js +0 -47
- package/test/getObservationsType.test.js +0 -55
- package/test/getOneValueDimensions.test.js +0 -35
- package/test/getReportingYearStart.test.js +0 -59
- package/test/getSeriesCombinations.test.js +0 -29
- package/test/getSortedLayoutIndexes.test.js +0 -1138
- package/test/getTableLabelAccessor.test.js +0 -50
- package/test/getTableLayoutIds.test.js +0 -356
- package/test/hierarchiseDimensionWithNativeHierarchy2.test.js +0 -109
- package/test/isTableLayoutCompatible.test.js +0 -102
- package/test/metadata-parsing-perf.test.js +0 -509
- package/test/mocks/MSD_TEST.json +0 -490
- package/test/mocks/OECD_SNA_TABLE1_1.0_-_AUS_V_metadata.json +0 -152
- package/test/mocks/h-codelist.json +0 -2095
- package/test/mocks/large_metadata_series.json +0 -701
- package/test/mocks/observations-advanced-attributes.json +0 -55382
- package/test/mocks/table-invert-time--data.json +0 -80211
- package/test/mocks/table-invert-time--inverted.json +0 -80076
- package/test/mocks/table-layout-multi-hierarchies--layout.json +0 -621
- package/test/mocks/table-layout-multi-hierarchies--layoutData.json +0 -32411
- package/test/mocks/table-layout-multi-hierarchies--layoutIndexes.json +0 -2760
- package/test/mocks/table-layout-multi-hierarchies--observations.json +0 -30688
- package/test/mocks/table-layout-multi-hierarchies--sizedIndexes.json +0 -2762
- package/test/mocks/table-layout-truncation1--layout.json +0 -27469
- package/test/mocks/table-layout-truncation1--layoutData.json +0 -20358
- package/test/mocks/table-layout-truncation1--layoutIndexes.json +0 -7512
- package/test/mocks/table-layout-truncation1--observations.json +0 -70002
- package/test/mocks/table-layout-truncation1--sizedIndexes.json +0 -3011
- package/test/mocks/table-prep-multi-hierarchies--attributes.json +0 -46
- package/test/mocks/table-prep-multi-hierarchies--dimensions.json +0 -688
- package/test/mocks/table-prep-multi-hierarchies--enhancedObservations.json +0 -19696
- package/test/mocks/table-prep-multi-hierarchies--observations.json +0 -8246
- package/test/mocks/table-prep-multi-hierarchies--sdmxJson.json +0 -2985
- package/test/mocks/table-prep-simple-duplicate--dimensions2.json +0 -858
- package/test/mocks/table-prep-simple-duplicate--duplicated2.json +0 -77502
- package/test/mocks/table-prep-simple-duplicate--observations2.json +0 -60002
- package/test/mocks/table-prep-truncation1--dimensions.json +0 -35057
- package/test/mocks/table-prep-truncation1--enhancedObservations.json +0 -70002
- package/test/mocks/table-prep-truncation1--observations.json +0 -27502
- package/test/mocks/table-prep-truncation1--sdmxJson.json +0 -55103
- package/test/mocks/table-prep-units--observations.json +0 -284286
- package/test/mocks/table-prep-units--unitsSeries.json +0 -41042
- package/test/parseAttributes.test.js +0 -36
- package/test/parseCombinations.test.js +0 -172
- package/test/parseHierarchicalCodelist.test.js +0 -140
- package/test/parseMetadataSeries.test.js +0 -128
- package/test/parseSeriesIndexesHierarchies.test.js +0 -345
- package/test/parseValueHierarchy.test.js +0 -138
- package/test/refineAttributes.test.js +0 -29
- package/test/refineLayoutSize2.test.js +0 -3410
- package/test/refineMetadataCoordinates.test.js +0 -86
- package/test/refineTimePeriod.test.js +0 -580
- package/test/refinedDimensions.test.js +0 -35
- package/vite.config.mjs +0 -51
|
@@ -1,321 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
|
|
3
|
-
const toKey = indexes => R.reduce(
|
|
4
|
-
(acc, _ind) => {
|
|
5
|
-
const ind = R.is(Array, _ind) ? toKey(_ind) : String(Math.abs(_ind));
|
|
6
|
-
if (R.isEmpty(ind)) {
|
|
7
|
-
return acc;
|
|
8
|
-
}
|
|
9
|
-
return R.isEmpty(acc) ? ind : `${acc}:${ind}`
|
|
10
|
-
},
|
|
11
|
-
'',
|
|
12
|
-
indexes
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
const getPivotKey = indexes => R.pipe(
|
|
16
|
-
R.props(indexes),
|
|
17
|
-
R.join(':')
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
const getPivots = (layout, shape) => R.pipe(
|
|
21
|
-
R.props(shape),
|
|
22
|
-
R.map(
|
|
23
|
-
R.pipe(
|
|
24
|
-
R.map(entry => R.has('dimensions', entry) ? R.pluck('__index', entry.dimensions || []) : entry.__index),
|
|
25
|
-
R.unnest,
|
|
26
|
-
getPivotKey
|
|
27
|
-
)
|
|
28
|
-
)
|
|
29
|
-
)(layout);
|
|
30
|
-
|
|
31
|
-
const indexWithPivots = (pivots, observations) => R.pipe(
|
|
32
|
-
R.values,
|
|
33
|
-
R.reduce(
|
|
34
|
-
(acc, obs) => {
|
|
35
|
-
const path = R.map(
|
|
36
|
-
pivot => pivot(obs.orderedDimIndexes),
|
|
37
|
-
pivots
|
|
38
|
-
);
|
|
39
|
-
return R.over(
|
|
40
|
-
R.lensPath(path),
|
|
41
|
-
R.ifElse(R.isNil, R.always([obs]), R.append(obs))
|
|
42
|
-
)(acc);
|
|
43
|
-
},
|
|
44
|
-
{}
|
|
45
|
-
)
|
|
46
|
-
)(observations);
|
|
47
|
-
|
|
48
|
-
export const getCuratedCells = ({ layout, observations, shape }) => {
|
|
49
|
-
const pivots = getPivots(layout, shape);
|
|
50
|
-
return indexWithPivots(pivots, observations);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const filterSeries = (series, getHasStillData) => {
|
|
54
|
-
let removedMissingIndexes = [];
|
|
55
|
-
return R.reduce((acc, serie) => {
|
|
56
|
-
const hasStillData = getHasStillData(serie);
|
|
57
|
-
const serieParentsSets = R.map(p => new Set(p), R.propOr([], 'parentsIndexes', serie));
|
|
58
|
-
if (!hasStillData) {
|
|
59
|
-
removedMissingIndexes = R.addIndex(R.map)((mIs, ind) => {
|
|
60
|
-
const filtered = R.filter(i => serieParentsSets[ind].has(i), R.nth(ind, removedMissingIndexes) || []);
|
|
61
|
-
return R.concat(filtered, mIs);
|
|
62
|
-
}, serie.missingIndexes || []);
|
|
63
|
-
return acc;
|
|
64
|
-
}
|
|
65
|
-
const _serie = R.pipe(
|
|
66
|
-
R.over(
|
|
67
|
-
R.lensProp('missingIndexes'),
|
|
68
|
-
(missingIndexes = []) => R.addIndex(R.map)((mIs, ind) => {
|
|
69
|
-
const removed = R.nth(ind, removedMissingIndexes) || [];
|
|
70
|
-
if (R.isEmpty(removed)) {
|
|
71
|
-
return mIs;
|
|
72
|
-
}
|
|
73
|
-
const filteredRemoved = R.filter(i => serieParentsSets[ind].has(i), removed);
|
|
74
|
-
return R.concat(filteredRemoved, mIs || []);
|
|
75
|
-
}, missingIndexes)
|
|
76
|
-
),
|
|
77
|
-
R.over(
|
|
78
|
-
R.lensProp('parentsIndexes'),
|
|
79
|
-
(parentsIndexes = []) => R.addIndex(R.map)((p, ind) => {
|
|
80
|
-
return R.reject(i => R.includes(i, R.nth(ind, removedMissingIndexes) || []), p || []);
|
|
81
|
-
}, parentsIndexes)
|
|
82
|
-
)
|
|
83
|
-
)(serie);
|
|
84
|
-
removedMissingIndexes = [];
|
|
85
|
-
return R.append(_serie, acc);
|
|
86
|
-
}, [], series);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export const refineSections = (sections, extractedKeys, curatedObs) => R.pipe(
|
|
90
|
-
R.map(
|
|
91
|
-
(section) => {
|
|
92
|
-
const sectionKey = toKey(R.propOr([], 'indexes', R.head(section)));
|
|
93
|
-
const getHasRowStillData = (row) => {
|
|
94
|
-
const rowKey = toKey(R.prop('indexes', row));
|
|
95
|
-
return R.pipe(
|
|
96
|
-
R.path([sectionKey, rowKey]),
|
|
97
|
-
R.omit(extractedKeys),
|
|
98
|
-
R.isEmpty,
|
|
99
|
-
R.not
|
|
100
|
-
)(curatedObs);
|
|
101
|
-
};
|
|
102
|
-
return R.over(
|
|
103
|
-
R.lensIndex(1),
|
|
104
|
-
rows => filterSeries(rows, getHasRowStillData)
|
|
105
|
-
)(section);
|
|
106
|
-
}
|
|
107
|
-
),
|
|
108
|
-
R.filter(
|
|
109
|
-
R.pipe(R.nth(1), R.isEmpty, R.not)
|
|
110
|
-
)
|
|
111
|
-
)(sections);
|
|
112
|
-
|
|
113
|
-
export const refineHeader = (headers, extractedKeys, curatedObs) => {
|
|
114
|
-
const getHasHeaderStillData = (header) => {
|
|
115
|
-
const headerKey = toKey(R.prop('indexes', header));
|
|
116
|
-
return R.pipe(
|
|
117
|
-
R.prop(headerKey),
|
|
118
|
-
(sections) => {
|
|
119
|
-
return R.pickBy(
|
|
120
|
-
(rows, section) => R.pipe(
|
|
121
|
-
R.omit(R.propOr([], section, extractedKeys)),
|
|
122
|
-
R.isEmpty,
|
|
123
|
-
R.not
|
|
124
|
-
)(rows),
|
|
125
|
-
sections
|
|
126
|
-
);
|
|
127
|
-
},
|
|
128
|
-
R.isEmpty,
|
|
129
|
-
R.not
|
|
130
|
-
)(curatedObs);
|
|
131
|
-
};
|
|
132
|
-
return filterSeries(headers, getHasHeaderStillData);
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
const getSerieLinesCount = serie => {
|
|
136
|
-
const missingParents = R.propOr([], 'missingParents', serie);
|
|
137
|
-
const missingParentsRowsCount = R.pipe(R.flatten, R.length)(missingParents);
|
|
138
|
-
return missingParentsRowsCount + 1;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export const truncateSectionRows = (n, sectionsData) => {
|
|
142
|
-
let truncated = sectionsData;
|
|
143
|
-
let extractedKeys = {};
|
|
144
|
-
let _n = n;
|
|
145
|
-
while (_n > 0) {
|
|
146
|
-
const lastSection = R.last(truncated);
|
|
147
|
-
const rows = lastSection[1];
|
|
148
|
-
const rowsLength = R.length(rows);
|
|
149
|
-
let truncatedRowsCount = 0;
|
|
150
|
-
while (_n > 0 && truncatedRowsCount !== rowsLength) {
|
|
151
|
-
const rowsCount = getSerieLinesCount(R.nth(-1 * truncatedRowsCount, rows));
|
|
152
|
-
_n = _n - rowsCount;
|
|
153
|
-
truncatedRowsCount++;
|
|
154
|
-
}
|
|
155
|
-
const sectionKey = R.pipe(R.head, R.prop('indexes'), toKey)(lastSection);
|
|
156
|
-
extractedKeys = {
|
|
157
|
-
...extractedKeys,
|
|
158
|
-
[sectionKey]: R.pipe(
|
|
159
|
-
R.takeLast(truncatedRowsCount),
|
|
160
|
-
R.map(r => toKey(R.prop('indexes', r)))
|
|
161
|
-
)(rows)
|
|
162
|
-
};
|
|
163
|
-
if (_n > 0) {
|
|
164
|
-
truncated = R.dropLast(1, truncated);
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
truncated = R.over(R.lensIndex(-1), R.over(R.lensIndex(1), R.dropLast(truncatedRowsCount)))(truncated);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return ({ truncated, extractedKeys });
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
export const truncateHeader = (n, headerData) => {
|
|
174
|
-
let { truncated, extractedKeys } = { truncated: headerData, extractedKeys: [] };
|
|
175
|
-
let _n = n;
|
|
176
|
-
while (_n > 0) {
|
|
177
|
-
const lastHeader = R.last(truncated);
|
|
178
|
-
const columnsCount = getSerieLinesCount(lastHeader);
|
|
179
|
-
const extractedKey = toKey(R.prop('indexes', lastHeader));
|
|
180
|
-
extractedKeys = R.append(extractedKey, extractedKeys);
|
|
181
|
-
truncated = R.dropLast(1, truncated);
|
|
182
|
-
_n = _n - columnsCount;
|
|
183
|
-
}
|
|
184
|
-
return ({ truncated, extractedKeys });
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
const truncateLayout = (isVertical) => R.ifElse(
|
|
188
|
-
R.always(isVertical),
|
|
189
|
-
truncateSectionRows,
|
|
190
|
-
truncateHeader,
|
|
191
|
-
);
|
|
192
|
-
|
|
193
|
-
const refineLayout = (isVertical) => R.ifElse(
|
|
194
|
-
R.always(isVertical),
|
|
195
|
-
refineHeader,
|
|
196
|
-
refineSections
|
|
197
|
-
)
|
|
198
|
-
|
|
199
|
-
const getShape = isVertical => isVertical ? ['header', 'sections', 'rows'] : ['sections', 'rows', 'header'];
|
|
200
|
-
|
|
201
|
-
const getRefinedLayout = (isVertical, truncated, refined) => R.ifElse(
|
|
202
|
-
R.always(isVertical),
|
|
203
|
-
R.pipe(R.assoc('sections', truncated), R.assoc('header', refined)),
|
|
204
|
-
R.pipe(R.assoc('header', truncated), R.assoc('sections', refined)),
|
|
205
|
-
)({});
|
|
206
|
-
|
|
207
|
-
const segregateLayout = (isVertical) => R.ifElse(
|
|
208
|
-
R.always(isVertical),
|
|
209
|
-
R.props(['sections', 'header']),
|
|
210
|
-
R.props(['header', 'sections'])
|
|
211
|
-
);
|
|
212
|
-
|
|
213
|
-
export const refineLayoutSize = ({ layout, observations, limit }) => layoutIndexes => {
|
|
214
|
-
const { header, sections } = layoutIndexes;
|
|
215
|
-
if (R.isNil(limit) || limit === 0 || R.all(R.isEmpty, [header, sections])) {
|
|
216
|
-
return R.pipe(
|
|
217
|
-
R.set(R.lensProp('truncated'), false),
|
|
218
|
-
R.set(R.lensProp('totalCells'), null),
|
|
219
|
-
)(layoutIndexes);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
//number of dimensions in header
|
|
223
|
-
const headerDimCount = R.pipe(
|
|
224
|
-
R.head, // first column
|
|
225
|
-
R.when(R.isNil, R.always({})),
|
|
226
|
-
R.propOr([], 'indexes'),
|
|
227
|
-
R.length // number of dims
|
|
228
|
-
)(header);
|
|
229
|
-
|
|
230
|
-
//number of columns for values
|
|
231
|
-
const headerValuesCount = R.pipe(
|
|
232
|
-
R.reduce((acc, header) => {
|
|
233
|
-
const columnsCount = getSerieLinesCount(header);
|
|
234
|
-
return acc + columnsCount;
|
|
235
|
-
}, 0),
|
|
236
|
-
R.when(R.equals(0), R.always(1))
|
|
237
|
-
)(header);
|
|
238
|
-
|
|
239
|
-
//total of cells in header
|
|
240
|
-
const headerCellsCount = headerDimCount * (headerValuesCount + 1);
|
|
241
|
-
|
|
242
|
-
// number of dimensions in a row
|
|
243
|
-
const rowDimCount = R.pipe(
|
|
244
|
-
R.head, // firstSection
|
|
245
|
-
R.last, // rows,
|
|
246
|
-
R.head, // first row
|
|
247
|
-
R.propOr([], 'indexes'),
|
|
248
|
-
R.length
|
|
249
|
-
)(sections);
|
|
250
|
-
|
|
251
|
-
// number of cells in a row
|
|
252
|
-
const rowCellsCount = rowDimCount + headerValuesCount + 1;
|
|
253
|
-
|
|
254
|
-
// number of rows
|
|
255
|
-
const rowsCount = R.pipe(
|
|
256
|
-
R.map(R.last),
|
|
257
|
-
R.unnest,
|
|
258
|
-
R.reduce((acc, row) => {
|
|
259
|
-
const rowsCount = getSerieLinesCount(row);
|
|
260
|
-
return acc + rowsCount;
|
|
261
|
-
}, 1)
|
|
262
|
-
)(sections);
|
|
263
|
-
|
|
264
|
-
// total of cells in all rows
|
|
265
|
-
const rowsCellsCount = rowCellsCount * rowsCount;
|
|
266
|
-
|
|
267
|
-
// number of sections cells
|
|
268
|
-
const sectionsCellsCount = R.ifElse(
|
|
269
|
-
R.pipe(R.head, R.head, R.propOr([], 'indexes'), R.length, R.equals(0)),
|
|
270
|
-
R.always(0),
|
|
271
|
-
R.length
|
|
272
|
-
)(sections);
|
|
273
|
-
|
|
274
|
-
const total = rowsCellsCount + sectionsCellsCount + headerCellsCount;
|
|
275
|
-
|
|
276
|
-
const excess = total - limit;
|
|
277
|
-
if (excess <= 0) {
|
|
278
|
-
return R.pipe(
|
|
279
|
-
R.set(R.lensProp('truncated'), false),
|
|
280
|
-
R.set(R.lensProp('totalCells'), total),
|
|
281
|
-
)(layoutIndexes);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
// total of cells in one column
|
|
285
|
-
const columnCellsCount = headerDimCount + rowsCount;
|
|
286
|
-
|
|
287
|
-
const isVertical = columnCellsCount > rowCellsCount;
|
|
288
|
-
|
|
289
|
-
const [toTruncate, toRefine] = segregateLayout(isVertical)(layoutIndexes);
|
|
290
|
-
|
|
291
|
-
let cutLength = R.pipe(
|
|
292
|
-
R.ifElse(R.identity, R.always(rowCellsCount), R.always(columnCellsCount)),
|
|
293
|
-
R.divide(excess),
|
|
294
|
-
Math.ceil
|
|
295
|
-
)(isVertical);
|
|
296
|
-
|
|
297
|
-
const maxCutLength = isVertical ? rowsCount - 2 : headerValuesCount - 1;
|
|
298
|
-
cutLength = cutLength > maxCutLength ? maxCutLength : cutLength;
|
|
299
|
-
|
|
300
|
-
const { truncated, extractedKeys } = truncateLayout(isVertical)(cutLength, toTruncate);
|
|
301
|
-
|
|
302
|
-
const dimsLength = R.pipe(R.values, R.head, R.propOr([], 'orderedDimIndexes'), R.length)(observations);
|
|
303
|
-
const _layout = R.map(
|
|
304
|
-
R.map(entry => entry.id === 'OBS_ATTRIBUTES' ? R.assoc('__index', dimsLength - 1, entry) : entry),
|
|
305
|
-
layout
|
|
306
|
-
);
|
|
307
|
-
const curatedObs = R.pipe(
|
|
308
|
-
getShape,
|
|
309
|
-
(shape) => getCuratedCells({ layout: _layout, observations, shape })
|
|
310
|
-
)(isVertical);
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
const refined = refineLayout(isVertical)(toRefine, extractedKeys, curatedObs);
|
|
314
|
-
|
|
315
|
-
const result = getRefinedLayout(isVertical, truncated, refined);
|
|
316
|
-
|
|
317
|
-
return R.pipe(
|
|
318
|
-
R.set(R.lensProp('truncated'), true),
|
|
319
|
-
R.set(R.lensProp('totalCells'), total),
|
|
320
|
-
)(result);
|
|
321
|
-
};
|
package/src/rules2/src/utils.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
|
|
3
|
-
export const trimedProps = (properties, obj) => R.reduce(
|
|
4
|
-
(acc, prop) => {
|
|
5
|
-
if (R.isNil(R.prop(prop, obj))) {
|
|
6
|
-
return acc;
|
|
7
|
-
}
|
|
8
|
-
return R.append(obj[prop], acc);
|
|
9
|
-
},
|
|
10
|
-
[],
|
|
11
|
-
properties,
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
export const getLayoutCoordinatesValidator = (layoutCoordinates, topCoordinates={}) => (coordinates) => {
|
|
15
|
-
if (R.isEmpty(coordinates)) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
if (R.has('OBS_ATTRIBUTES', layoutCoordinates) || R.has('OBS_ATTRIBUTES', topCoordinates)) {
|
|
19
|
-
const obsAttrCoord = R.prop('OBS_ATTRIBUTES', layoutCoordinates)
|
|
20
|
-
|| R.prop('OBS_ATTRIBUTES', topCoordinates);
|
|
21
|
-
if (obsAttrCoord !== 'OBS_VALUE') {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
const keys = R.keys(coordinates);
|
|
26
|
-
let res = true;
|
|
27
|
-
let notInTop = {};
|
|
28
|
-
R.forEach(key => {
|
|
29
|
-
if (R.prop(key, layoutCoordinates) !== R.prop(key, coordinates)) {
|
|
30
|
-
res = false;
|
|
31
|
-
}
|
|
32
|
-
if (!R.has(key, topCoordinates)) {
|
|
33
|
-
notInTop[key] = key;
|
|
34
|
-
}
|
|
35
|
-
}, keys);
|
|
36
|
-
return res && !R.isEmpty(notInTop);
|
|
37
|
-
};
|
package/src/viewer/mocks/bar.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export default () => ({
|
|
2
|
-
chartData: {
|
|
3
|
-
series: [
|
|
4
|
-
{ datapoints: [
|
|
5
|
-
{x: 'Hungary', y: 5.5},
|
|
6
|
-
{x: 'Sweden', y: 5.6},
|
|
7
|
-
{x: 'Estonia', y: 5.7},
|
|
8
|
-
{x: 'Finland', y: 5.8},
|
|
9
|
-
{x: 'Belgium', y: 5.9},
|
|
10
|
-
{x: 'Turkey', y: 6},
|
|
11
|
-
{x: 'France', y: 6.5},
|
|
12
|
-
{x: 'Poland', y: 6.6},
|
|
13
|
-
{x: 'Slovenia', y: 6.8},
|
|
14
|
-
{x: 'European Union', y: 7.4, baselineIndex: 0},
|
|
15
|
-
{x: 'Euro area (18 countries)', y: 8.2},
|
|
16
|
-
{x: 'Ireland', y: 8.7, highlightIndex: 0},
|
|
17
|
-
{x: 'Italy', y: 8.9},
|
|
18
|
-
{x: 'Slovak Republic', y: 9.9},
|
|
19
|
-
{x: 'Portugal', y: 10.9},
|
|
20
|
-
{x: 'South Africa', y: 12.3, highlightIndex: 1},
|
|
21
|
-
{x: 'Spain (2 digits)', y: 16.86 }
|
|
22
|
-
]
|
|
23
|
-
}
|
|
24
|
-
]
|
|
25
|
-
},
|
|
26
|
-
headerProps: {
|
|
27
|
-
title: { label: 'Science performance (PISA)' },
|
|
28
|
-
subtitle: [{ label: 'Mean score 2015, Annual incl. OECD, all countries' }],
|
|
29
|
-
},
|
|
30
|
-
footerProps: {
|
|
31
|
-
source: { label: 'data.oecd.org', link: 'http://data.oecd.org/' }
|
|
32
|
-
}
|
|
33
|
-
});
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
export default () => ({
|
|
2
|
-
headerProps: {
|
|
3
|
-
"title": { label: "Growth previous period - Annual - 2015" },
|
|
4
|
-
},
|
|
5
|
-
footerProps: {
|
|
6
|
-
soure: { label: 'source', link: 'http://dotstat.oecd.org/' }
|
|
7
|
-
},
|
|
8
|
-
chartData: {
|
|
9
|
-
"series": [
|
|
10
|
-
{
|
|
11
|
-
"datapoints": [
|
|
12
|
-
{
|
|
13
|
-
"category": "Finland",
|
|
14
|
-
"values": [
|
|
15
|
-
-0.958831808585503,
|
|
16
|
-
-0.938640709195226
|
|
17
|
-
],
|
|
18
|
-
highlightIndex: 0
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"category": "Canada",
|
|
22
|
-
"values": [
|
|
23
|
-
-0.734931326089172,
|
|
24
|
-
0.178223109790082
|
|
25
|
-
]
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"category": "Belgium",
|
|
29
|
-
"values": [
|
|
30
|
-
-0.0160655474335108,
|
|
31
|
-
0.177647331428157
|
|
32
|
-
],
|
|
33
|
-
highlightIndex: 1
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"category": "Chile",
|
|
37
|
-
"values": [
|
|
38
|
-
0.230172987500003,
|
|
39
|
-
0.286348587500551
|
|
40
|
-
]
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
"category": "Estonia",
|
|
44
|
-
"values": [
|
|
45
|
-
0.292360493199452,
|
|
46
|
-
1.4055978394304
|
|
47
|
-
]
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
"category": "Australia",
|
|
51
|
-
"values": [
|
|
52
|
-
1.18005263064255,
|
|
53
|
-
-1.70548071959404
|
|
54
|
-
],
|
|
55
|
-
baselineIndex: 0
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
"category": "Denmark",
|
|
59
|
-
"values": [
|
|
60
|
-
1.18634492777014,
|
|
61
|
-
2.47915590644139
|
|
62
|
-
]
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
"category": "France",
|
|
66
|
-
"values": [
|
|
67
|
-
1.96360436882936,
|
|
68
|
-
1.92806480043649
|
|
69
|
-
]
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
"category": "Austria",
|
|
73
|
-
"values": [
|
|
74
|
-
2.11995066296641,
|
|
75
|
-
2.36545969532268
|
|
76
|
-
]
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
"category": "Czech Republic",
|
|
80
|
-
"values": [
|
|
81
|
-
4.62318401937048,
|
|
82
|
-
6.01902272562258
|
|
83
|
-
]
|
|
84
|
-
}
|
|
85
|
-
],
|
|
86
|
-
"symbolValues": [
|
|
87
|
-
"Industrial production, s.a.",
|
|
88
|
-
"Total manufacturing, s.a."
|
|
89
|
-
]
|
|
90
|
-
}
|
|
91
|
-
],
|
|
92
|
-
}
|
|
93
|
-
})
|