@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,258 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
import numeral from 'numeral';
|
|
3
|
-
import dateFns from 'date-fns';
|
|
4
|
-
import isMonday from 'date-fns/is_monday';
|
|
5
|
-
import isTuesday from 'date-fns/is_tuesday';
|
|
6
|
-
import isWednesday from 'date-fns/is_wednesday';
|
|
7
|
-
import isThursday from 'date-fns/is_thursday';
|
|
8
|
-
import isFriday from 'date-fns/is_friday';
|
|
9
|
-
import isSaturday from 'date-fns/is_saturday';
|
|
10
|
-
import isSunday from 'date-fns/is_sunday';
|
|
11
|
-
import getISOWeek from 'date-fns/get_iso_week';
|
|
12
|
-
import { getLocale, dateWithoutTZ } from '../date';
|
|
13
|
-
import {
|
|
14
|
-
BAR,
|
|
15
|
-
CHORO,
|
|
16
|
-
H_SYMBOL,
|
|
17
|
-
ROW,
|
|
18
|
-
SCATTER,
|
|
19
|
-
STACKED_BAR,
|
|
20
|
-
STACKED_ROW,
|
|
21
|
-
TIMELINE,
|
|
22
|
-
V_SYMBOL
|
|
23
|
-
} from '../constants';
|
|
24
|
-
|
|
25
|
-
const defaultTimeFormats = {
|
|
26
|
-
A: 'YYYY',
|
|
27
|
-
S: 'YYYY-[S][SEMESTER]',
|
|
28
|
-
Q: 'YYYY-[Q]Q',
|
|
29
|
-
M: 'YYYY-MMM',
|
|
30
|
-
W: 'YYYY-[W]WW',
|
|
31
|
-
B: 'YYYY-[W]WW',
|
|
32
|
-
D: 'YYYY-MM-DD',
|
|
33
|
-
H: 'YYYY-MM-DD[T]HH:mm:ss',
|
|
34
|
-
N: 'YYYY-MM-DD[T]HH:mm:ss',
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const getTimeProc = (frequency, timeFormats = {}, locale) => {
|
|
38
|
-
if (frequency === 'W' || frequency === 'B') {
|
|
39
|
-
return datum => {
|
|
40
|
-
const isoWeek = getISOWeek(datum);
|
|
41
|
-
if (isoWeek !== 1) {
|
|
42
|
-
return dateFns.format(datum, 'YYYY-[W]WW', { locale: getLocale(locale) })
|
|
43
|
-
}
|
|
44
|
-
const seventhDay = dateFns.endOfWeek(datum, { weekStartsOn: 1 });
|
|
45
|
-
return dateFns.format(seventhDay, 'YYYY-[W]WW', { locale: getLocale(locale) })
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
const format = R.pipe(
|
|
49
|
-
R.mergeRight(defaultTimeFormats),
|
|
50
|
-
R.ifElse(
|
|
51
|
-
R.has(frequency),
|
|
52
|
-
R.prop(frequency),
|
|
53
|
-
R.prop('A')
|
|
54
|
-
)
|
|
55
|
-
)(timeFormats);
|
|
56
|
-
return datum => dateFns.format(dateWithoutTZ(new Date(datum)), format, { locale: getLocale(locale) });
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const getTimeFrequency = (data) => {
|
|
60
|
-
const frequency = R.prop('frequency', data);
|
|
61
|
-
if (frequency === 'W' || frequency === 'B') {
|
|
62
|
-
const date = R.pathOr(['series', 0, 'datapoints', 'x']);
|
|
63
|
-
return R.cond([
|
|
64
|
-
[isMonday, R.always('monday')],
|
|
65
|
-
[isTuesday, R.always('tueday')],
|
|
66
|
-
[isWednesday, R.always('wednesday')],
|
|
67
|
-
[isThursday, R.always('thursday')],
|
|
68
|
-
[isFriday, R.always('friday')],
|
|
69
|
-
[isSaturday, R.always('saturday')],
|
|
70
|
-
[isSunday, R.always('sunday')],
|
|
71
|
-
[R.T, R.always('monday')],
|
|
72
|
-
])(date);
|
|
73
|
-
}
|
|
74
|
-
return R.cond([
|
|
75
|
-
[R.equals('A'), R.always('year')],
|
|
76
|
-
[R.equals('S'), R.always('month')],
|
|
77
|
-
[R.equals('Q'), R.always('month')],
|
|
78
|
-
[R.equals('M'), R.always('month')],
|
|
79
|
-
[R.equals('D'), R.always('day')],
|
|
80
|
-
[R.equals('H'), R.always('hour')],
|
|
81
|
-
[R.equals('N'), R.always('minute')],
|
|
82
|
-
[R.T, R.always('year')],
|
|
83
|
-
])(frequency);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const getTimeStep = R.cond([
|
|
87
|
-
[R.equals('A'), R.always(1)],
|
|
88
|
-
[R.equals('S'), R.always(6)],
|
|
89
|
-
[R.equals('Q'), R.always(3)],
|
|
90
|
-
[R.equals('M'), R.always(1)],
|
|
91
|
-
[R.equals('W'), R.always(1)],
|
|
92
|
-
[R.equals('B'), R.always(1)],
|
|
93
|
-
[R.equals('D'), R.always(1)],
|
|
94
|
-
[R.equals('H'), R.always(1)],
|
|
95
|
-
[R.equals('N'), R.always(1)],
|
|
96
|
-
[R.T, R.always(1)],
|
|
97
|
-
]);
|
|
98
|
-
|
|
99
|
-
export const getAxisOptions = (data, type, options, timeFormats, locale) => {
|
|
100
|
-
|
|
101
|
-
const axis = {
|
|
102
|
-
linear: { pivot: { color: 'white' } },
|
|
103
|
-
ordinal: { gap: .3, padding: .3 },
|
|
104
|
-
thickness: 0,
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const linearProc = d => numeral(d).format('0,0.[00]');
|
|
108
|
-
|
|
109
|
-
return R.pipe(
|
|
110
|
-
R.propOr({}, 'axis'),
|
|
111
|
-
R.mergeDeepRight({ x: axis, y: axis }),
|
|
112
|
-
R.cond([
|
|
113
|
-
[
|
|
114
|
-
R.always(R.equals(BAR, type)),
|
|
115
|
-
R.pipe(
|
|
116
|
-
R.mergeDeepRight({
|
|
117
|
-
x: { format: { proc: R.identity }, tick: { thickness: 0, size: 0 } },
|
|
118
|
-
y: {
|
|
119
|
-
font: { baseline: 'ideographic' },
|
|
120
|
-
format: { proc: linearProc },
|
|
121
|
-
padding: 10,
|
|
122
|
-
tick: { thickness: 0 },
|
|
123
|
-
}
|
|
124
|
-
}),
|
|
125
|
-
R.over(R.lensPath(['y', 'linear', 'pivot', 'value']), R.when(R.isNil, R.always(0)))
|
|
126
|
-
)
|
|
127
|
-
],
|
|
128
|
-
[
|
|
129
|
-
R.always(R.equals(ROW, type)),
|
|
130
|
-
R.pipe(
|
|
131
|
-
R.mergeDeepRight({
|
|
132
|
-
x: {
|
|
133
|
-
format: { proc: linearProc },
|
|
134
|
-
orient: 'top',
|
|
135
|
-
padding: 10,
|
|
136
|
-
tick: { thickness: 0 },
|
|
137
|
-
},
|
|
138
|
-
y: {
|
|
139
|
-
format: { proc: R.identity },
|
|
140
|
-
ordinal: { minDisplaySize: 300 },
|
|
141
|
-
tick: { thickness: 0, size: 0 },
|
|
142
|
-
}
|
|
143
|
-
}),
|
|
144
|
-
R.over(R.lensPath(['x', 'linear', 'pivot', 'value']), R.when(R.isNil, R.always(0)))
|
|
145
|
-
)
|
|
146
|
-
],
|
|
147
|
-
[
|
|
148
|
-
R.always(R.equals(SCATTER, type)),
|
|
149
|
-
R.mergeDeepRight({
|
|
150
|
-
x: {
|
|
151
|
-
format: { proc: linearProc },
|
|
152
|
-
tick: { thickness: 0, size: 0 },
|
|
153
|
-
},
|
|
154
|
-
y: {
|
|
155
|
-
font: { baseline: 'ideographic' },
|
|
156
|
-
format: { proc: linearProc },
|
|
157
|
-
padding: 10,
|
|
158
|
-
tick: { thickness: 0 },
|
|
159
|
-
}
|
|
160
|
-
})
|
|
161
|
-
],
|
|
162
|
-
[
|
|
163
|
-
R.always(R.equals(TIMELINE, type)),
|
|
164
|
-
R.pipe(
|
|
165
|
-
R.mergeDeepRight({
|
|
166
|
-
x: {
|
|
167
|
-
format: {
|
|
168
|
-
isTime: true,
|
|
169
|
-
pattern: null,
|
|
170
|
-
proc: getTimeProc(R.prop('frequency', data), timeFormats, locale)
|
|
171
|
-
},
|
|
172
|
-
tick: { size: -6, minorSize: -3, thickness: 2, minorThickness: 2, color: 'white' },
|
|
173
|
-
},
|
|
174
|
-
y: {
|
|
175
|
-
font: { baseline: 'ideographic' },
|
|
176
|
-
format: { proc: d => numeral(d).format('0,0.[00]') },
|
|
177
|
-
padding: 10,
|
|
178
|
-
tick: { thickness: 0 },
|
|
179
|
-
}
|
|
180
|
-
}),
|
|
181
|
-
R.evolve({
|
|
182
|
-
x: R.pipe(
|
|
183
|
-
R.set(R.lensPath(['linear', 'frequency']), getTimeFrequency(data)),
|
|
184
|
-
R.set(R.lensPath(['linear', 'step']), getTimeStep(R.prop('frequency', data))),
|
|
185
|
-
R.over(
|
|
186
|
-
R.lensPath(['tick', 'step']),
|
|
187
|
-
R.pipe(R.when(R.isNil, R.always(1)), R.multiply(getTimeStep(R.prop('frequency', data))))
|
|
188
|
-
)
|
|
189
|
-
)
|
|
190
|
-
})
|
|
191
|
-
)
|
|
192
|
-
],
|
|
193
|
-
[
|
|
194
|
-
R.always(R.equals(H_SYMBOL, type)),
|
|
195
|
-
R.mergeDeepRight({
|
|
196
|
-
x: {
|
|
197
|
-
format: { proc: linearProc },
|
|
198
|
-
orient: 'top',
|
|
199
|
-
padding: 10,
|
|
200
|
-
tick: { thickness: 0 },
|
|
201
|
-
},
|
|
202
|
-
y: {
|
|
203
|
-
format: { proc: R.identity },
|
|
204
|
-
ordinal: { minDisplaySize: 300 },
|
|
205
|
-
tick: { thickness: 0, size: 5 },
|
|
206
|
-
}
|
|
207
|
-
})
|
|
208
|
-
],
|
|
209
|
-
[
|
|
210
|
-
R.always(R.equals(V_SYMBOL, type)),
|
|
211
|
-
R.mergeDeepRight({
|
|
212
|
-
x: { format: { proc: R.identity }, tick: { thickness: 0, size: 0 } },
|
|
213
|
-
y: {
|
|
214
|
-
font: { baseline: 'ideographic' },
|
|
215
|
-
format: { proc: linearProc },
|
|
216
|
-
padding: 10,
|
|
217
|
-
tick: { thickness: 0 },
|
|
218
|
-
}
|
|
219
|
-
})
|
|
220
|
-
],
|
|
221
|
-
[
|
|
222
|
-
R.always(R.equals(STACKED_BAR, type)),
|
|
223
|
-
R.pipe(
|
|
224
|
-
R.mergeDeepRight({
|
|
225
|
-
x: { format: { proc: R.identity }, tick: { thickness: 0, size: 0 } },
|
|
226
|
-
y: {
|
|
227
|
-
font: { baseline: 'ideographic' },
|
|
228
|
-
format: { proc: linearProc },
|
|
229
|
-
padding: 10,
|
|
230
|
-
tick: { thickness: 0 },
|
|
231
|
-
}
|
|
232
|
-
}),
|
|
233
|
-
R.over(R.lensPath(['y', 'linear', 'pivot', 'value']), R.when(R.isNil, R.always(0)))
|
|
234
|
-
)
|
|
235
|
-
],
|
|
236
|
-
[
|
|
237
|
-
R.always(R.equals(STACKED_ROW, type)),
|
|
238
|
-
R.pipe(
|
|
239
|
-
R.mergeDeepRight({
|
|
240
|
-
x: {
|
|
241
|
-
format: { proc: linearProc },
|
|
242
|
-
orient: 'top',
|
|
243
|
-
padding: 10,
|
|
244
|
-
tick: { thickness: 0 },
|
|
245
|
-
},
|
|
246
|
-
y: {
|
|
247
|
-
format: { proc: R.identity },
|
|
248
|
-
ordinal: { minDisplaySize: 300 },
|
|
249
|
-
tick: { thickness: 0, size: 0 }
|
|
250
|
-
}
|
|
251
|
-
}),
|
|
252
|
-
R.over(R.lensPath(['x', 'linear', 'pivot', 'value']), R.when(R.isNil, R.always(0)))
|
|
253
|
-
)
|
|
254
|
-
],
|
|
255
|
-
[R.T, R.identity]
|
|
256
|
-
])
|
|
257
|
-
)(options);
|
|
258
|
-
};
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
import {
|
|
3
|
-
BAR,
|
|
4
|
-
CHORO,
|
|
5
|
-
H_SYMBOL,
|
|
6
|
-
ROW,
|
|
7
|
-
SCATTER,
|
|
8
|
-
STACKED_BAR,
|
|
9
|
-
STACKED_ROW,
|
|
10
|
-
TIMELINE,
|
|
11
|
-
V_SYMBOL
|
|
12
|
-
} from '../constants';
|
|
13
|
-
|
|
14
|
-
export const getBaseOptions = (type, options) => R.pipe(
|
|
15
|
-
R.propOr({}, 'base'),
|
|
16
|
-
R.cond([
|
|
17
|
-
[
|
|
18
|
-
R.always(R.equals(BAR, type)),
|
|
19
|
-
R.mergeDeepRight({
|
|
20
|
-
minDisplayHeight: 100,
|
|
21
|
-
minDisplayWidth: 300,
|
|
22
|
-
padding: { top: 20 },
|
|
23
|
-
innerPadding: { left: 20, right: 20, bottom: 10 }
|
|
24
|
-
})
|
|
25
|
-
],
|
|
26
|
-
[
|
|
27
|
-
R.always(R.equals(ROW, type)),
|
|
28
|
-
R.mergeDeepRight({
|
|
29
|
-
minDisplayHeight: 300,
|
|
30
|
-
minDisplayWidth: 100,
|
|
31
|
-
padding: { top: 10, left: 10, right: 20 }
|
|
32
|
-
})
|
|
33
|
-
],
|
|
34
|
-
[
|
|
35
|
-
R.always(R.equals(SCATTER, type)),
|
|
36
|
-
R.mergeDeepRight({
|
|
37
|
-
minDisplayHeight: 100,
|
|
38
|
-
minDisplayWidth: 100,
|
|
39
|
-
padding: { top: 40, right: 10 }
|
|
40
|
-
})
|
|
41
|
-
],
|
|
42
|
-
[
|
|
43
|
-
R.always(R.equals(TIMELINE, type)),
|
|
44
|
-
R.mergeDeepRight({
|
|
45
|
-
minDisplayHeight: 300,
|
|
46
|
-
minDisplayWidth: 100,
|
|
47
|
-
isAnnotated: false,
|
|
48
|
-
padding: { top: 20 },
|
|
49
|
-
innerPadding: { left: 40, right: 40 }
|
|
50
|
-
})
|
|
51
|
-
],
|
|
52
|
-
[
|
|
53
|
-
R.always(R.equals(H_SYMBOL, type)),
|
|
54
|
-
R.mergeDeepRight({
|
|
55
|
-
minDisplayHeight: 300,
|
|
56
|
-
minDisplayWidth: 100,
|
|
57
|
-
padding: { top: 10, left: 10, right: 20 }
|
|
58
|
-
})
|
|
59
|
-
],
|
|
60
|
-
[
|
|
61
|
-
R.always(R.equals(V_SYMBOL, type)),
|
|
62
|
-
R.mergeDeepRight({
|
|
63
|
-
minDisplayHeight: 100,
|
|
64
|
-
minDisplayWidth: 300,
|
|
65
|
-
padding: { top: 20 },
|
|
66
|
-
innerPadding: { left: 20, right: 20, bottom: 10 }
|
|
67
|
-
})
|
|
68
|
-
],
|
|
69
|
-
[
|
|
70
|
-
R.always(R.equals(STACKED_BAR, type)),
|
|
71
|
-
R.mergeDeepRight({
|
|
72
|
-
minDisplayHeight: 100,
|
|
73
|
-
minDisplayWidth: 300,
|
|
74
|
-
padding: { top: 20 },
|
|
75
|
-
innerPadding: { left: 20, right: 20, bottom: 10 }
|
|
76
|
-
})
|
|
77
|
-
],
|
|
78
|
-
[
|
|
79
|
-
R.always(R.equals(STACKED_ROW, type)),
|
|
80
|
-
R.mergeDeepRight({ padding: { top: 10, left: 10, right: 20 } })
|
|
81
|
-
],
|
|
82
|
-
[R.T, R.identity]
|
|
83
|
-
])
|
|
84
|
-
)(options);
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
import numeral from 'numeral';
|
|
3
|
-
import { getAxisOptions } from './getAxisOptions';
|
|
4
|
-
import { getBaseOptions } from './getBaseOptions';
|
|
5
|
-
import { getGridOptions } from './getGridOptions';
|
|
6
|
-
import { getTooltipOptions } from './getTooltipOptions';
|
|
7
|
-
import { SCATTER, STACKED_BAR, STACKED_ROW, TIMELINE } from '../constants';
|
|
8
|
-
|
|
9
|
-
export const FOCUS_COLORS = {
|
|
10
|
-
highlightColors: ['#E73741', '#0F8FD9', '#993484', '#DF521E', '#719E24', '#E1B400', '#32A674', '#0B68AF'],
|
|
11
|
-
baselineColors: ['#0B1E2D']
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const symbolMarkers = () => {
|
|
15
|
-
const paths = {
|
|
16
|
-
circle: size => {
|
|
17
|
-
const r = Math.sqrt(size) / 2;
|
|
18
|
-
return `M0,${r} A${r},${r} 0 1,1 0,${-r} A${r},${r} 0 1,1 0,${r} Z`;
|
|
19
|
-
},
|
|
20
|
-
square: size => {
|
|
21
|
-
const r = Math.sqrt(size) / 2;
|
|
22
|
-
return `M${-r},${-r} L${r},${-r} ${r},${r} ${-r},${r} Z`;
|
|
23
|
-
},
|
|
24
|
-
cross: size => {
|
|
25
|
-
const r = Math.sqrt(size) / 2;
|
|
26
|
-
return `M${-r},${r} L${r},${-r} M${r},${r} L${-r},${-r}`;
|
|
27
|
-
},
|
|
28
|
-
'triangle': size => {
|
|
29
|
-
const rx = Math.sqrt(size) / Math.sqrt(3);
|
|
30
|
-
const ry = Math.sqrt(size) / 2;
|
|
31
|
-
return `M0,${-ry} L${rx},${ry} ${-rx},${ry} Z`;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return ([
|
|
35
|
-
{ style: { stroke: '#39617D', fill: '#39617D' }, path: paths.circle },
|
|
36
|
-
{ style: { stroke: '#39617D', fill: '#DBEBF2' }, rotate: 45, path: paths.square },
|
|
37
|
-
{ style: { stroke: '#39617D', fill: '#39617D', strokeWidth: 2 }, path: paths.cross },
|
|
38
|
-
{ style: { stroke: '#39617D', fill: '#DBEBF2' }, path: paths.square },
|
|
39
|
-
{ style: { stroke: '#39617D', fill: '#39617D' }, path: paths.triangle }
|
|
40
|
-
]);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const getAnnotationOptions = (type, options) => R.pipe(
|
|
44
|
-
R.pathOr({}, ['serie', 'annotation']),
|
|
45
|
-
R.mergeRight({
|
|
46
|
-
format: {
|
|
47
|
-
datapoint: { proc: d => numeral(d).format('0,0.[00]') }
|
|
48
|
-
}
|
|
49
|
-
}),
|
|
50
|
-
R.cond([
|
|
51
|
-
[
|
|
52
|
-
R.always(R.equals(SCATTER, type)),
|
|
53
|
-
R.mergeRight({ display: 'never' })
|
|
54
|
-
],
|
|
55
|
-
[
|
|
56
|
-
R.always(R.equals(TIMELINE, type)),
|
|
57
|
-
R.mergeDeepRight({ format: { datapoint: { pattern: '.2f' } } })
|
|
58
|
-
],
|
|
59
|
-
[R.T, R.identity]
|
|
60
|
-
])
|
|
61
|
-
)(options);
|
|
62
|
-
|
|
63
|
-
export const getChartOptions = (data, type, options, tooltipFonts, timeFormats, locale) => {
|
|
64
|
-
const defaultSerieColors = R.ifElse(
|
|
65
|
-
R.anyPass([R.equals(STACKED_BAR), R.equals(STACKED_ROW)]),
|
|
66
|
-
R.always(['#607D8B']),
|
|
67
|
-
R.always(['#8EA4B1'])
|
|
68
|
-
)(type);
|
|
69
|
-
|
|
70
|
-
return ({
|
|
71
|
-
axis: getAxisOptions(data, type, options, timeFormats, locale),
|
|
72
|
-
background: R.pipe(
|
|
73
|
-
R.propOr({}, 'background'),
|
|
74
|
-
R.mergeRight({ color: '#DBEBF2' })
|
|
75
|
-
)(options),
|
|
76
|
-
base: getBaseOptions(type, options),
|
|
77
|
-
grid: getGridOptions(type, options),
|
|
78
|
-
map: R.pipe(
|
|
79
|
-
R.propOr({}, 'map'),
|
|
80
|
-
R.mergeRight({ intBoundariesColor: '#8EA4B1' })
|
|
81
|
-
)(options),
|
|
82
|
-
serie: {
|
|
83
|
-
...R.propOr({}, 'serie', options),
|
|
84
|
-
annotation: getAnnotationOptions(type, options),
|
|
85
|
-
choropleth: R.pipe(
|
|
86
|
-
R.pathOr({}, ['serie', 'choropleth']),
|
|
87
|
-
R.mergeRight({
|
|
88
|
-
divisions: 4,
|
|
89
|
-
domain: 'YlorRd',
|
|
90
|
-
invert: false,
|
|
91
|
-
labelDisplay: 'none',
|
|
92
|
-
})
|
|
93
|
-
)(options),
|
|
94
|
-
stacked: R.pipe(
|
|
95
|
-
R.pathOr({}, ['serie', 'stacked']),
|
|
96
|
-
R.mergeRight({ strokeThickness: 1, strokeColor: '#F8FAFC' })
|
|
97
|
-
)(options),
|
|
98
|
-
symbol: R.pipe(
|
|
99
|
-
R.pathOr({}, ['serie', 'symbol']),
|
|
100
|
-
R.mergeRight({
|
|
101
|
-
markers: symbolMarkers(),
|
|
102
|
-
markerDefaultSize: 60,
|
|
103
|
-
markerDefaultStrokeWidth: 1,
|
|
104
|
-
gapMinMaxColor: '#607D8B',
|
|
105
|
-
gapMinMaxThickness: 1,
|
|
106
|
-
gapAxisMinColor: 'white',
|
|
107
|
-
gapAxisMinThickness: 1
|
|
108
|
-
})
|
|
109
|
-
)(options),
|
|
110
|
-
colors: R.pathOr(defaultSerieColors, ['serie', 'colors'], options),
|
|
111
|
-
overColors: R.pathOr(['#39617D'], ['serie', 'overColors'], options),
|
|
112
|
-
highlightColors: R.pathOr(FOCUS_COLORS.highlightColors, ['serie', 'highlightColors'], options),
|
|
113
|
-
baselineColors: R.pathOr(FOCUS_COLORS.baselineColors, ['serie', 'baselineColors'], options),
|
|
114
|
-
tooltip: getTooltipOptions(data, type, options, tooltipFonts, timeFormats, locale)
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
};
|
|
118
|
-
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
import {
|
|
3
|
-
BAR,
|
|
4
|
-
CHORO,
|
|
5
|
-
H_SYMBOL,
|
|
6
|
-
ROW,
|
|
7
|
-
STACKED_BAR,
|
|
8
|
-
STACKED_ROW,
|
|
9
|
-
TIMELINE,
|
|
10
|
-
V_SYMBOL
|
|
11
|
-
} from '../constants';
|
|
12
|
-
|
|
13
|
-
export const getGridOptions = (type, options) => {
|
|
14
|
-
const grid = { baselines: [0], color: 'white' };
|
|
15
|
-
const hideGrid = R.assoc('thickness', 0);
|
|
16
|
-
|
|
17
|
-
return R.pipe(
|
|
18
|
-
R.propOr({}, 'grid'),
|
|
19
|
-
R.mergeDeepRight({ x: grid, y: grid }),
|
|
20
|
-
R.cond([
|
|
21
|
-
[
|
|
22
|
-
R.always(R.equals(BAR, type)),
|
|
23
|
-
R.mergeDeepRight({ x: { thickness: 0 } })
|
|
24
|
-
],
|
|
25
|
-
[
|
|
26
|
-
R.always(R.equals(ROW, type)),
|
|
27
|
-
R.mergeDeepRight({ y: { thickness: 0 } })
|
|
28
|
-
],
|
|
29
|
-
[
|
|
30
|
-
R.always(R.equals(TIMELINE, type)),
|
|
31
|
-
R.mergeDeepRight({ x: { thickness: 0 } })
|
|
32
|
-
],
|
|
33
|
-
[
|
|
34
|
-
R.always(R.equals(H_SYMBOL, type)),
|
|
35
|
-
R.mergeDeepRight({ y: { thickness: 0 } })
|
|
36
|
-
],
|
|
37
|
-
[
|
|
38
|
-
R.always(R.equals(V_SYMBOL, type)),
|
|
39
|
-
R.mergeDeepRight({ x: { thickness: 0 } })
|
|
40
|
-
],
|
|
41
|
-
[
|
|
42
|
-
R.always(R.equals(STACKED_BAR, type)),
|
|
43
|
-
R.mergeDeepRight({ x: { thickness: 0 } })
|
|
44
|
-
],
|
|
45
|
-
[
|
|
46
|
-
R.always(R.equals(STACKED_ROW, type)),
|
|
47
|
-
R.mergeDeepRight({ y: { thickness: 0 } })
|
|
48
|
-
],
|
|
49
|
-
[R.T, R.identity]
|
|
50
|
-
])
|
|
51
|
-
)(options);
|
|
52
|
-
};
|