@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,424 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
import { getDataFrequency } from '@sis-cc/dotstatsuite-sdmxjs';
|
|
3
|
-
import { series } from '../';
|
|
4
|
-
import {
|
|
5
|
-
H_SYMBOL,
|
|
6
|
-
SCATTER,
|
|
7
|
-
STACKED_BAR,
|
|
8
|
-
STACKED_ROW,
|
|
9
|
-
TIMELINE,
|
|
10
|
-
V_SYMBOL,
|
|
11
|
-
} from '../constants';
|
|
12
|
-
import {
|
|
13
|
-
onChangeFocusSelection,
|
|
14
|
-
focusOptions,
|
|
15
|
-
sampleFocusStateFromNewProps,
|
|
16
|
-
} from './focus';
|
|
17
|
-
import {
|
|
18
|
-
isScatter,
|
|
19
|
-
onChangeScatterDim,
|
|
20
|
-
onChangeScatterVal,
|
|
21
|
-
scatterStateFromNewProps,
|
|
22
|
-
scatterStateValueToOption,
|
|
23
|
-
scatterValueOptions,
|
|
24
|
-
toScatterSingularity,
|
|
25
|
-
} from './scatter';
|
|
26
|
-
import {
|
|
27
|
-
isSymbol,
|
|
28
|
-
onChangeSymbolDim,
|
|
29
|
-
symbolStateFromNewProps,
|
|
30
|
-
toSymbolSingularity,
|
|
31
|
-
} from './symbol';
|
|
32
|
-
import {
|
|
33
|
-
isStacked,
|
|
34
|
-
isStackedDimActive,
|
|
35
|
-
onChangeStackedDimension,
|
|
36
|
-
onChangeStackedMode,
|
|
37
|
-
stackedModeOptions,
|
|
38
|
-
stackedStateFromNewProps,
|
|
39
|
-
toStackedSingularity
|
|
40
|
-
} from './stacked';
|
|
41
|
-
import {
|
|
42
|
-
linearStateFromNewProps,
|
|
43
|
-
initialState as linearInitialState,
|
|
44
|
-
toProperties as toLinearProperties
|
|
45
|
-
} from './linear';
|
|
46
|
-
import {
|
|
47
|
-
chartDimensionOptions,
|
|
48
|
-
chartDimensionToOption,
|
|
49
|
-
hasFocus,
|
|
50
|
-
isChart,
|
|
51
|
-
isNaturalInt,
|
|
52
|
-
isNumber,
|
|
53
|
-
optionParser,
|
|
54
|
-
} from './utils';
|
|
55
|
-
import { getTitleLabel, getSubtitle, getSourceLabel } from './getHeaderProps';
|
|
56
|
-
import { stringifySubtitle } from './getStringifiedSubtitle';
|
|
57
|
-
import { getHasNoTimePeriodError } from './errors';
|
|
58
|
-
/*
|
|
59
|
-
- width/height -> initial undefined, if undefined or blank, replaced by options.base
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
export const toSingularity = ({ data, type }, state) => {
|
|
63
|
-
switch(type) {
|
|
64
|
-
case SCATTER:
|
|
65
|
-
return toScatterSingularity(state);
|
|
66
|
-
case H_SYMBOL: case V_SYMBOL:
|
|
67
|
-
return toSymbolSingularity(data, state);
|
|
68
|
-
case STACKED_BAR: case STACKED_ROW:
|
|
69
|
-
return toStackedSingularity(state);
|
|
70
|
-
default:
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export const toChartData = (props, state) => {
|
|
76
|
-
const dimensions = R.pathOr([], ['data', 'structure', 'dimensions', 'observation'], props);
|
|
77
|
-
const attributes = R.pathOr([], ['data', 'structure', 'attributes', 'observation'], props);
|
|
78
|
-
const frequency = props.type === TIMELINE ? getDataFrequency({ dimensions, attributes }) : null;
|
|
79
|
-
return ({
|
|
80
|
-
frequency,
|
|
81
|
-
series: series(
|
|
82
|
-
props.data,
|
|
83
|
-
props.type,
|
|
84
|
-
R.pick(['highlight', 'baseline'], state),
|
|
85
|
-
toSingularity(props, state),
|
|
86
|
-
props.map,
|
|
87
|
-
props.display,
|
|
88
|
-
props.formaterIds
|
|
89
|
-
),
|
|
90
|
-
share: {
|
|
91
|
-
focused: R.pick(['highlight', 'baseline'], state),
|
|
92
|
-
chartDimension: toSingularity(props, state),
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export const getErrors = (props, state) => ({
|
|
98
|
-
noTime: getHasNoTimePeriodError(props),
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
const toFloat = (value) => {
|
|
102
|
-
const float = parseFloat(value);
|
|
103
|
-
return isNaN(float) ? undefined : float;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const toOption = (stateValue, optionValue) => R.isNil(stateValue)
|
|
107
|
-
? optionValue : toFloat(stateValue);
|
|
108
|
-
|
|
109
|
-
const getFreqStepOption = (props, state) => {
|
|
110
|
-
if (props.type !== TIMELINE) {
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
const inputState = toFloat(state.freqStep);
|
|
114
|
-
return R.isNil(inputState) ? 1 : inputState;
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
export const toChartOptions = (props, state) => {
|
|
118
|
-
const options = R.propOr({}, 'options', props);
|
|
119
|
-
const base = R.propOr({}, 'base', options);
|
|
120
|
-
const axis = R.propOr({}, 'axis', options);
|
|
121
|
-
const axeX = R.propOr({}, 'x', axis);
|
|
122
|
-
const axeY = R.propOr({}, 'y', axis);
|
|
123
|
-
const linearX = R.propOr({}, 'linear', axeX);
|
|
124
|
-
const linearY = R.propOr({}, 'linear', axeY);
|
|
125
|
-
const tickX = R.propOr({}, 'tick', axeX);
|
|
126
|
-
const pivotX = R.propOr({}, 'pivot', linearX);
|
|
127
|
-
const pivotY = R.propOr({}, 'pivot', linearY);
|
|
128
|
-
const map = R.propOr({}, 'map', props);
|
|
129
|
-
return ({
|
|
130
|
-
...options,
|
|
131
|
-
axis: {
|
|
132
|
-
...axis,
|
|
133
|
-
x: {
|
|
134
|
-
...axeX,
|
|
135
|
-
tick: {
|
|
136
|
-
...tickX,
|
|
137
|
-
step: getFreqStepOption(props, state)
|
|
138
|
-
},
|
|
139
|
-
linear: {
|
|
140
|
-
...linearX,
|
|
141
|
-
max: toOption(state.maxX, linearX.max),
|
|
142
|
-
min: toOption(state.minX, linearX.min),
|
|
143
|
-
pivot: {
|
|
144
|
-
value: toOption(state.pivotX, pivotX.value)
|
|
145
|
-
},
|
|
146
|
-
step: toOption(
|
|
147
|
-
props.type === TIMELINE ? 1 : state.stepX,
|
|
148
|
-
linearX.step
|
|
149
|
-
),
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
y: {
|
|
153
|
-
...axeY,
|
|
154
|
-
linear: {
|
|
155
|
-
...linearY,
|
|
156
|
-
max: toOption(state.maxY, linearY.max),
|
|
157
|
-
min: toOption(state.minY, linearY.min),
|
|
158
|
-
pivot: {
|
|
159
|
-
value: toOption(state.pivotY, pivotY.value)
|
|
160
|
-
},
|
|
161
|
-
step: toOption(state.stepY, linearY.step),
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
},
|
|
165
|
-
map: R.pick(['projection', 'scale'], map),
|
|
166
|
-
base: {
|
|
167
|
-
...base,
|
|
168
|
-
height: toOption(state.fixedHeight, base.height),
|
|
169
|
-
width: toOption(state.fixedWidth, base.width),
|
|
170
|
-
},
|
|
171
|
-
});
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
export const initialState = {
|
|
175
|
-
highlight: [],
|
|
176
|
-
baseline: [],
|
|
177
|
-
fixedWidth: undefined,
|
|
178
|
-
fixedHeight: undefined,
|
|
179
|
-
freqStep: undefined,
|
|
180
|
-
responsiveWidth: undefined,
|
|
181
|
-
responsiveHeight: undefined,
|
|
182
|
-
scatterDimension: undefined,
|
|
183
|
-
scatterX: undefined,
|
|
184
|
-
scatterY: undefined,
|
|
185
|
-
symbolDimension: undefined,
|
|
186
|
-
stackedDimension: undefined,
|
|
187
|
-
stackedMode: undefined,
|
|
188
|
-
id: undefined,
|
|
189
|
-
type: undefined,
|
|
190
|
-
...linearInitialState,
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
export const stateFromNewProps = (props, state) => {
|
|
194
|
-
const focusState = sampleFocusStateFromNewProps(props, state);
|
|
195
|
-
const scatterState = scatterStateFromNewProps(props, state);
|
|
196
|
-
const symbolState = symbolStateFromNewProps(props, state);
|
|
197
|
-
const stackedState = stackedStateFromNewProps(props, state);
|
|
198
|
-
const linearState = linearStateFromNewProps(props.type);
|
|
199
|
-
return ({
|
|
200
|
-
...focusState,
|
|
201
|
-
...scatterState,
|
|
202
|
-
...symbolState,
|
|
203
|
-
...stackedState,
|
|
204
|
-
...linearState,
|
|
205
|
-
fixedWidth: R.prop('fixedWidth', state),
|
|
206
|
-
fixedHeight: R.prop('fixedHeight', state),
|
|
207
|
-
responsiveWidth: R.prop('responsiveWidth', state),
|
|
208
|
-
responsiveHeight: R.prop('responsiveHeight', state),
|
|
209
|
-
freqStep: props.type === TIMELINE
|
|
210
|
-
? R.prop('freqStep', state) || '1' : undefined,
|
|
211
|
-
type: R.prop('type', props),
|
|
212
|
-
});
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
const propertiesParsers = {
|
|
216
|
-
highlight: onChangeFocusSelection,
|
|
217
|
-
baseline: onChangeFocusSelection,
|
|
218
|
-
fixedWidth: (value) => isNaturalInt(value) ? value : undefined,
|
|
219
|
-
fixedHeight: (value) => isNaturalInt(value) ? value : undefined,
|
|
220
|
-
responsiveWidth: (value) => isNumber(value) ? value : undefined,
|
|
221
|
-
responsiveHeight: (value) => isNumber(value) ? value : undefined,
|
|
222
|
-
freqStep: (value) => isNaturalInt(value) ? value : undefined,
|
|
223
|
-
title: R.identity,
|
|
224
|
-
subtitle: R.identity,
|
|
225
|
-
sourceLabel: R.identity,
|
|
226
|
-
scatterDimension: optionParser,
|
|
227
|
-
scatterX: optionParser,
|
|
228
|
-
scatterY: optionParser,
|
|
229
|
-
symbolDimension: optionParser,
|
|
230
|
-
stackedDimension: optionParser,
|
|
231
|
-
stackedMode: optionParser,
|
|
232
|
-
maxX: (value) => isNumber(value) ? value : undefined,
|
|
233
|
-
maxY: (value) => isNumber(value) ? value : undefined,
|
|
234
|
-
minX: (value) => isNumber(value) ? value : undefined,
|
|
235
|
-
minY: (value) => isNumber(value) ? value : undefined,
|
|
236
|
-
pivotX: (value) => isNumber(value) ? value : undefined,
|
|
237
|
-
pivotY: (value) => isNumber(value) ? value : undefined,
|
|
238
|
-
stepX: (value) => isNaturalInt(value) ? value : undefined,
|
|
239
|
-
stepY: (value) => isNaturalInt(value) ? value : undefined,
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
export const onChangeProperties = (state, onChange) => (newProperties) => {
|
|
243
|
-
const apply = R.is(Function, onChange) ? onChange : R.identity;
|
|
244
|
-
const refined = R.pipe(
|
|
245
|
-
R.mapObjIndexed((value, key) => {
|
|
246
|
-
const _parser = R.prop(key, propertiesParsers);
|
|
247
|
-
const parser = R.is(Function, _parser) ? _parser : R.identity;
|
|
248
|
-
return parser(value);
|
|
249
|
-
}),
|
|
250
|
-
R.pickBy((value, key) => value !== R.prop(key, state))
|
|
251
|
-
)(newProperties);
|
|
252
|
-
if (R.isEmpty(refined)) {
|
|
253
|
-
return ;
|
|
254
|
-
}
|
|
255
|
-
apply(refined);
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
export const toProperties = (props, state, onChange) => ({
|
|
259
|
-
...toLinearProperties(props, state, onChange),
|
|
260
|
-
highlight: {
|
|
261
|
-
id: 'highlight',
|
|
262
|
-
isActive: hasFocus(props.type),
|
|
263
|
-
onChange: R.pipe(
|
|
264
|
-
onChangeFocusSelection,
|
|
265
|
-
selection => {
|
|
266
|
-
onChange({ highlight: selection });
|
|
267
|
-
}
|
|
268
|
-
),
|
|
269
|
-
options: focusOptions(
|
|
270
|
-
props,
|
|
271
|
-
state,
|
|
272
|
-
'baseline',
|
|
273
|
-
toSingularity(props, state)
|
|
274
|
-
),
|
|
275
|
-
value: R.prop('highlight', state),
|
|
276
|
-
},
|
|
277
|
-
baseline: {
|
|
278
|
-
id: 'baseline',
|
|
279
|
-
isActive: hasFocus(props.type),
|
|
280
|
-
onChange: R.pipe(
|
|
281
|
-
onChangeFocusSelection,
|
|
282
|
-
selection => onChange({ baseline: selection })
|
|
283
|
-
),
|
|
284
|
-
options: focusOptions(
|
|
285
|
-
props,
|
|
286
|
-
state,
|
|
287
|
-
'highlight',
|
|
288
|
-
toSingularity(props, state)
|
|
289
|
-
),
|
|
290
|
-
value: R.prop('baseline', state),
|
|
291
|
-
},
|
|
292
|
-
width: {
|
|
293
|
-
id: 'width',
|
|
294
|
-
isActive: isChart(props.type),
|
|
295
|
-
onChange: (value) => onChange({
|
|
296
|
-
fixedWidth: isNaturalInt(value) ? value : undefined
|
|
297
|
-
}),
|
|
298
|
-
placeholder: R.when(R.complement(R.isNil), (value) => String(Math.floor(Number(value))))(state.responsiveWidth),
|
|
299
|
-
value: R.prop('fixedWidth', state),
|
|
300
|
-
},
|
|
301
|
-
height: {
|
|
302
|
-
id: 'height',
|
|
303
|
-
isActive: isChart(props.type),
|
|
304
|
-
onChange: (value) => onChange({
|
|
305
|
-
fixedHeight: isNaturalInt(value) ? value : undefined
|
|
306
|
-
}),
|
|
307
|
-
placeholder: R.when(R.complement(R.isNil), (value) => String(Math.floor(Number(value))))(state.responsiveHeight),
|
|
308
|
-
},
|
|
309
|
-
freqStep: {
|
|
310
|
-
id: 'freqStep',
|
|
311
|
-
isActive: props.type === TIMELINE,
|
|
312
|
-
onChange: (value) => onChange({
|
|
313
|
-
freqStep: isNaturalInt(value) ? String(value) : undefined
|
|
314
|
-
}),
|
|
315
|
-
value: R.prop('freqStep', state),
|
|
316
|
-
},
|
|
317
|
-
title: {
|
|
318
|
-
id: 'title',
|
|
319
|
-
isActive: isChart(props.type),
|
|
320
|
-
isDefault: R.isNil(state.title),
|
|
321
|
-
onChange: (value) => onChange({ title: value }),
|
|
322
|
-
value: R.isNil(state.title) || R.isEmpty(state.title)
|
|
323
|
-
? R.pathOr('', ['title', 'label'], props) : state.title,
|
|
324
|
-
onReset: R.isNil(state.title)
|
|
325
|
-
? null : () => onChange({ title: null })
|
|
326
|
-
},
|
|
327
|
-
subtitle: {
|
|
328
|
-
id: 'subtitle',
|
|
329
|
-
isActive: isChart(props.type),
|
|
330
|
-
isDefault: R.isNil(state.subtitle),
|
|
331
|
-
onChange: (value) => onChange({ subtitle: value }),
|
|
332
|
-
value: R.isNil(state.subtitle) || R.isEmpty(state.subtitle)
|
|
333
|
-
? stringifySubtitle(props.subtitle || []) : state.subtitle,
|
|
334
|
-
onReset: R.isNil(state.subtitle)
|
|
335
|
-
? null : () => onChange({ subtitle: null })
|
|
336
|
-
},
|
|
337
|
-
source: {
|
|
338
|
-
id: 'source',
|
|
339
|
-
isActive: isChart(props.type),
|
|
340
|
-
isDefault: R.isNil(state.sourceLabel),
|
|
341
|
-
onChange: (value) => onChange({ sourceLabel: value }),
|
|
342
|
-
value: getSourceLabel(props, state),
|
|
343
|
-
onReset: R.isNil(state.sourceLabel)
|
|
344
|
-
? null : () => onChange({ sourceLabel: null })
|
|
345
|
-
},
|
|
346
|
-
scatterDimension: {
|
|
347
|
-
id: 'scatterDimension',
|
|
348
|
-
isActive: isScatter(props.type),
|
|
349
|
-
onChange: R.pipe(
|
|
350
|
-
optionParser,
|
|
351
|
-
onChangeScatterDim(props, state),
|
|
352
|
-
onChange
|
|
353
|
-
),
|
|
354
|
-
options: chartDimensionOptions(props, isScatter),
|
|
355
|
-
value: chartDimensionToOption('scatterDimension')(props, state),
|
|
356
|
-
},
|
|
357
|
-
scatterX: {
|
|
358
|
-
id: 'scatterX',
|
|
359
|
-
isActive: isScatter(props.type),
|
|
360
|
-
onChange: R.pipe(
|
|
361
|
-
optionParser,
|
|
362
|
-
onChangeScatterVal(props, state, 'scatterX', 'scatterY'),
|
|
363
|
-
onChange
|
|
364
|
-
),
|
|
365
|
-
options: scatterValueOptions(props, state),
|
|
366
|
-
value: scatterStateValueToOption('scatterX', props, state),
|
|
367
|
-
},
|
|
368
|
-
scatterY: {
|
|
369
|
-
id: 'scatterY',
|
|
370
|
-
isActive: isScatter(props.type),
|
|
371
|
-
onChange: R.pipe(
|
|
372
|
-
optionParser,
|
|
373
|
-
onChangeScatterVal(props, state, 'scatterY', 'scatterX'),
|
|
374
|
-
onChange
|
|
375
|
-
),
|
|
376
|
-
options: scatterValueOptions(props, state),
|
|
377
|
-
value: scatterStateValueToOption('scatterY', props, state),
|
|
378
|
-
},
|
|
379
|
-
symbolDimension: {
|
|
380
|
-
id: 'symbolDimension',
|
|
381
|
-
isActive: isSymbol(props.type),
|
|
382
|
-
options: chartDimensionOptions(props, isSymbol),
|
|
383
|
-
onChange: R.pipe(
|
|
384
|
-
optionParser,
|
|
385
|
-
onChangeSymbolDim(props),
|
|
386
|
-
onChange
|
|
387
|
-
),
|
|
388
|
-
value: chartDimensionToOption('symbolDimension')(props, state)
|
|
389
|
-
},
|
|
390
|
-
stackedDimension: {
|
|
391
|
-
id: 'stackedDimension',
|
|
392
|
-
isActive: isStackedDimActive(props),
|
|
393
|
-
options: chartDimensionOptions(props, isStacked),
|
|
394
|
-
onChange: R.pipe(
|
|
395
|
-
optionParser,
|
|
396
|
-
onChangeStackedDimension(props, state),
|
|
397
|
-
onChange,
|
|
398
|
-
),
|
|
399
|
-
value: chartDimensionToOption('stackedDimension')(props, state)
|
|
400
|
-
},
|
|
401
|
-
stackedMode: {
|
|
402
|
-
id: 'stackedMode',
|
|
403
|
-
isActive: isStacked(props.type),
|
|
404
|
-
options: stackedModeOptions,
|
|
405
|
-
onChange: R.pipe(
|
|
406
|
-
optionParser,
|
|
407
|
-
onChangeStackedMode,
|
|
408
|
-
onChange
|
|
409
|
-
),
|
|
410
|
-
value: R.prop('stackedMode', state)
|
|
411
|
-
},
|
|
412
|
-
logo: {
|
|
413
|
-
id: 'logo',
|
|
414
|
-
isActive: isChart(props.type),
|
|
415
|
-
checked: !state.withLogo,
|
|
416
|
-
onChange: () => onChange({ withLogo: !state.withLogo })
|
|
417
|
-
},
|
|
418
|
-
copyright: {
|
|
419
|
-
id: 'copyright',
|
|
420
|
-
isActive: isChart(props.type),
|
|
421
|
-
checked: !state.withCopyright,
|
|
422
|
-
onChange: () => onChange({ withCopyright: !state.withCopyright })
|
|
423
|
-
}
|
|
424
|
-
});
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { is, isEmpty, isNil, map, not, of, path, pipe, prop, length, split, when } from 'ramda';
|
|
2
|
-
import {
|
|
3
|
-
defaultSubtitle,
|
|
4
|
-
extractSdmxArtefacts,
|
|
5
|
-
headerUprsLabel,
|
|
6
|
-
parseDisplay,
|
|
7
|
-
uprAttributes,
|
|
8
|
-
uprAttributesWithOneRelevantValue,
|
|
9
|
-
} from '../';
|
|
10
|
-
|
|
11
|
-
import { dimensionValueDisplay } from '../dimension-utils';
|
|
12
|
-
|
|
13
|
-
export const initialState = {
|
|
14
|
-
subtitle: undefined,
|
|
15
|
-
title: undefined,
|
|
16
|
-
sourceLabel: undefined,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export const informationStateFromNewProps = (props, state) => {
|
|
20
|
-
const { id } = extractSdmxArtefacts(props.data);
|
|
21
|
-
if (id !== state.id) {
|
|
22
|
-
return initialState;
|
|
23
|
-
}
|
|
24
|
-
return ({});
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const getDataflowCode = (url) => {
|
|
28
|
-
if (isNil(url) || isEmpty(url)) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
const match = url.match(/[\w\/]+\/data\/([^\/]+)\//);
|
|
32
|
-
if (!is(Array, match)) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
//v8 case: 'AGENCY,CODE,VERSION'
|
|
36
|
-
const id = match[1];
|
|
37
|
-
const splitId = split(',', id);
|
|
38
|
-
if ((length(splitId) === 1)) {
|
|
39
|
-
return splitId[0];
|
|
40
|
-
}
|
|
41
|
-
return splitId[1];
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const defaultTitle = (props, display) => {
|
|
45
|
-
const name = path(['data', 'structure', 'name'], props);
|
|
46
|
-
const code = getDataflowCode(props.sdmxUrl);
|
|
47
|
-
return dimensionValueDisplay(display)({ id: code, name });
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const defaultSourceLabel = (props, title) => {
|
|
51
|
-
const propsLabel = path(['source', 'label'], props);
|
|
52
|
-
return (isNil(propsLabel) || isEmpty(propsLabel))
|
|
53
|
-
? title : propsLabel;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export const toHeader = (props, state) => {
|
|
57
|
-
const display = parseDisplay(props.display);
|
|
58
|
-
const stateTitle = prop('title', state);
|
|
59
|
-
const stateSubtitle = prop('subtitle', state);
|
|
60
|
-
const stateSourceLabel = prop('sourceLabel', state);
|
|
61
|
-
const propsSourceLink = path(['source', 'link'], props);
|
|
62
|
-
const title = (isNil(stateTitle) || isEmpty(stateTitle))
|
|
63
|
-
? defaultTitle(props, display) : stateTitle;
|
|
64
|
-
const subtitle = (isNil(stateSubtitle) || isEmpty(stateSubtitle))
|
|
65
|
-
? defaultSubtitle(props.data, display) : stateSubtitle;
|
|
66
|
-
const sourceLink = (isNil(propsSourceLink) || isEmpty(propsSourceLink))
|
|
67
|
-
? props.sdmxUrl : propsSourceLink;
|
|
68
|
-
const sourceLabel = (isNil(stateSourceLabel) || isEmpty(stateSourceLabel))
|
|
69
|
-
? defaultSourceLabel(props, title) : stateSourceLabel;
|
|
70
|
-
return ({
|
|
71
|
-
footnotes: { source: sourceLink, sourceLabel },
|
|
72
|
-
title: { label: title },
|
|
73
|
-
subtitle: pipe(
|
|
74
|
-
when(pipe(is(Array), not), of),
|
|
75
|
-
map(entry => ({ label: entry }))
|
|
76
|
-
)(subtitle),
|
|
77
|
-
uprs: pipe(
|
|
78
|
-
extractSdmxArtefacts,
|
|
79
|
-
({ attributes }) => uprAttributes(attributes),
|
|
80
|
-
uprAttributesWithOneRelevantValue,
|
|
81
|
-
headerUprsLabel(display),
|
|
82
|
-
)(props.data)
|
|
83
|
-
});
|
|
84
|
-
};
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
import {
|
|
3
|
-
BAR,
|
|
4
|
-
H_SYMBOL,
|
|
5
|
-
ROW,
|
|
6
|
-
SCATTER,
|
|
7
|
-
STACKED_BAR,
|
|
8
|
-
STACKED_ROW,
|
|
9
|
-
TIMELINE,
|
|
10
|
-
V_SYMBOL,
|
|
11
|
-
} from '../constants';
|
|
12
|
-
import { isNumber, isPositiveNumber } from './utils';
|
|
13
|
-
import { isStacked } from './stacked';
|
|
14
|
-
|
|
15
|
-
const hasXLinear = (type) => R.includes(type, [H_SYMBOL, ROW, SCATTER, STACKED_ROW]);
|
|
16
|
-
|
|
17
|
-
const hasYLinear = (type) => R.includes(type, [BAR, SCATTER, STACKED_BAR, TIMELINE, V_SYMBOL]);
|
|
18
|
-
|
|
19
|
-
const hasXPivot = (type) => R.equals(ROW, type);
|
|
20
|
-
const hasYPivot = (type) => R.equals(BAR, type);
|
|
21
|
-
|
|
22
|
-
const xInitialState = {
|
|
23
|
-
computedMaxX: undefined,
|
|
24
|
-
computedMinX: undefined,
|
|
25
|
-
computedStepX: undefined,
|
|
26
|
-
computedPivotX: undefined,
|
|
27
|
-
maxX: undefined,
|
|
28
|
-
minX: undefined,
|
|
29
|
-
pivotX: undefined,
|
|
30
|
-
stepX: undefined,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const yInitialState = {
|
|
34
|
-
computedMaxY: undefined,
|
|
35
|
-
computedMinY: undefined,
|
|
36
|
-
computedStepY: undefined,
|
|
37
|
-
computedPivotY: undefined,
|
|
38
|
-
maxY: undefined,
|
|
39
|
-
minY: undefined,
|
|
40
|
-
pivotY: undefined,
|
|
41
|
-
stepY: undefined,
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export const initialState = { ...xInitialState, ...yInitialState };
|
|
45
|
-
|
|
46
|
-
export const linearStateFromNewProps = (type) => {
|
|
47
|
-
const xLinearState = hasXLinear(type) ? {} : xInitialState;
|
|
48
|
-
const YLinearState = hasYLinear(type) ? {} : yInitialState;
|
|
49
|
-
return ({
|
|
50
|
-
...xLinearState,
|
|
51
|
-
...R.when(
|
|
52
|
-
R.always(isStacked(type)),
|
|
53
|
-
R.assoc('pivotY', 0)
|
|
54
|
-
)(YLinearState),
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export const toProperties = (props, state, onChange) => ({
|
|
59
|
-
maxX: {
|
|
60
|
-
id: 'maxX',
|
|
61
|
-
isActive: hasXLinear(props.type),
|
|
62
|
-
onChange: (value) => onChange({
|
|
63
|
-
maxX: isNumber(value) ? value : undefined
|
|
64
|
-
}),
|
|
65
|
-
value: R.isNil(state.maxX) ? String(state.computedMaxX) : state.maxX
|
|
66
|
-
},
|
|
67
|
-
maxY: {
|
|
68
|
-
id: 'maxY',
|
|
69
|
-
isActive: hasYLinear(props.type),
|
|
70
|
-
onChange: (value) => onChange({
|
|
71
|
-
maxY: isNumber(value) ? value : undefined
|
|
72
|
-
}),
|
|
73
|
-
value: R.isNil(state.maxY) ? String(state.computedMaxY) : state.maxY
|
|
74
|
-
},
|
|
75
|
-
minX: {
|
|
76
|
-
id: 'minX',
|
|
77
|
-
isActive: hasXLinear(props.type),
|
|
78
|
-
onChange: (value) => onChange({
|
|
79
|
-
minX: isNumber(value) ? value : undefined
|
|
80
|
-
}),
|
|
81
|
-
value: R.isNil(state.minX) ? String(state.computedMinX) : state.minX
|
|
82
|
-
},
|
|
83
|
-
minY: {
|
|
84
|
-
id: 'minY',
|
|
85
|
-
isActive: hasYLinear(props.type),
|
|
86
|
-
onChange: (value) => onChange({
|
|
87
|
-
minY: isNumber(value) ? value : undefined
|
|
88
|
-
}),
|
|
89
|
-
value: R.isNil(state.minY) ? String(state.computedMinY) : state.minY
|
|
90
|
-
},
|
|
91
|
-
pivotX: {
|
|
92
|
-
id: 'pivotX',
|
|
93
|
-
isActive: hasXPivot(props.type),
|
|
94
|
-
onChange: (value) => onChange({
|
|
95
|
-
pivotX: isNumber(value) ? value : undefined
|
|
96
|
-
}),
|
|
97
|
-
value: R.when(
|
|
98
|
-
v => R.isNil(v) && (R.propEq('type', ROW)(props) || R.propEq('type', STACKED_ROW)(props)),
|
|
99
|
-
R.always(0)
|
|
100
|
-
)(R.isNil(state.pivotX) ? String(state.computedPivotX) : state.pivotX)
|
|
101
|
-
},
|
|
102
|
-
pivotY: {
|
|
103
|
-
id: 'pivotY',
|
|
104
|
-
isActive: hasYPivot(props.type),
|
|
105
|
-
onChange: (value) => onChange({
|
|
106
|
-
pivotY: isNumber(value) ? value : undefined
|
|
107
|
-
}),
|
|
108
|
-
value: R.when(
|
|
109
|
-
v => R.isNil(v) && (R.propEq('type', BAR)(props) || R.propEq('type', STACKED_BAR)(props)),
|
|
110
|
-
R.always(0)
|
|
111
|
-
)(R.isNil(state.pivotY) ? String(state.computedPivotY) : state.pivotY)
|
|
112
|
-
},
|
|
113
|
-
stepX: {
|
|
114
|
-
id: 'stepX',
|
|
115
|
-
isActive: hasXLinear(props.type),
|
|
116
|
-
onChange: (value) => onChange({
|
|
117
|
-
stepX: isPositiveNumber(value) ? value : undefined
|
|
118
|
-
}),
|
|
119
|
-
value: R.isNil(state.stepX) ? String(state.computedStepX) : state.stepX
|
|
120
|
-
},
|
|
121
|
-
stepY: {
|
|
122
|
-
id: 'stepY',
|
|
123
|
-
isActive: hasYLinear(props.type),
|
|
124
|
-
onChange: (value) => onChange({
|
|
125
|
-
stepY: isPositiveNumber(value) ? value : undefined
|
|
126
|
-
}),
|
|
127
|
-
value: R.isNil(state.stepY) ? String(state.computedStepY) : state.stepY
|
|
128
|
-
},
|
|
129
|
-
});
|