@sis-cc/dotstatsuite-components 8.11.1 → 8.14.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/lib/app.js +13 -5
- package/lib/rules/src/chart/getChartOptions.js +8 -4
- package/lib/rules/src/factories/stacked-dimension.js +17 -23
- package/lib/rules/src/factories/stacked-series.js +82 -158
- package/lib/rules/src/index.js +3 -6
- package/lib/rules/src/properties/index.js +2 -1
- package/lib/rules/src/properties/stacked.js +35 -11
- package/lib/rules/src/properties/utils.js +7 -1
- package/lib/rules-driver/src/app.js +116 -167
- package/lib/viewer/src/chartUtils/series.js +4 -0
- package/lib/viewer/src/legends/SeriesLegend.js +3 -1
- package/package.json +2 -2
- package/src/app.js +10 -5
- package/src/rules/src/chart/getChartOptions.js +1 -0
- package/src/rules/src/factories/stacked-dimension.js +14 -10
- package/src/rules/src/factories/stacked-series.js +102 -94
- package/src/rules/src/index.js +1 -2
- package/src/rules/src/properties/index.js +3 -1
- package/src/rules/src/properties/stacked.js +23 -7
- package/src/rules/src/properties/utils.js +8 -3
- package/src/rules-driver/src/app.js +116 -132
- package/src/rules-driver/src/mocks/data1.json +332 -0
- package/src/rules-driver/src/mocks/data2.json +309 -0
- package/src/viewer/src/chartUtils/series.js +4 -0
- package/src/viewer/src/legends/SeriesLegend.js +4 -1
- package/lib/rules-driver/src/app/chart.js +0 -52
- package/lib/rules-driver/src/app/config-axis.js +0 -95
- package/lib/rules-driver/src/app/config-buttons.js +0 -47
- package/lib/rules-driver/src/app/config-input.js +0 -51
- package/lib/rules-driver/src/app/config-select.js +0 -57
- package/lib/rules-driver/src/app/config-t4size.js +0 -61
- package/lib/rules-driver/src/app/config1.js +0 -148
- package/lib/rules-driver/src/app/menu.js +0 -44
- package/lib/rules-driver/src/app/viewer1.js +0 -39
- package/lib/rules-driver/src/app/viewer2.js +0 -115
- package/src/rules-driver/src/app/chart.js +0 -18
- package/src/rules-driver/src/app/config-axis.js +0 -54
- package/src/rules-driver/src/app/config-buttons.js +0 -27
- package/src/rules-driver/src/app/config-input.js +0 -35
- package/src/rules-driver/src/app/config-select.js +0 -25
- package/src/rules-driver/src/app/config-t4size.js +0 -50
- package/src/rules-driver/src/app/config1.js +0 -120
- package/src/rules-driver/src/app/menu.js +0 -27
- package/src/rules-driver/src/app/viewer1.js +0 -18
- package/src/rules-driver/src/app/viewer2.js +0 -77
- package/src/rules-driver/src/mocks/ecb.json +0 -2069
- package/src/rules-driver/src/mocks/ins.json +0 -264
- package/src/rules-driver/src/mocks/oecd-time.json +0 -864
- package/src/rules-driver/src/mocks/oecd.json +0 -372
- package/src/rules-driver/src/mocks/tunisia.json +0 -333
|
@@ -1,139 +1,144 @@
|
|
|
1
|
-
import { find, get, groupBy, has, head, isUndefined, join, keyBy, map, reduce, split, sortBy, sumBy, take } from 'lodash';
|
|
2
1
|
import { isTimePeriodDimension } from '@sis-cc/dotstatsuite-sdmxjs';
|
|
3
2
|
import { dimensionValueDisplay } from '../dimension-utils';
|
|
4
3
|
import { getObservationFormater } from '../observation-formater';
|
|
4
|
+
import * as R from 'ramda';
|
|
5
5
|
|
|
6
6
|
const flatDatapoints = (observations, dimensions, dimensionsWithValuesIndexedById, serieDimensionId, display, formaterAttrs) => {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
|
|
8
|
+
const datapoints = R.mapObjIndexed(
|
|
9
9
|
(observationValue, observationKey) => {
|
|
10
10
|
let x = null;
|
|
11
|
-
const y = Number(head(observationValue));
|
|
11
|
+
const y = Number(R.head(observationValue));
|
|
12
12
|
const formater = getObservationFormater(observationValue, formaterAttrs);
|
|
13
|
-
const splittedKey = split(
|
|
13
|
+
const splittedKey = R.split(':', observationKey);
|
|
14
14
|
let layerKey = [];
|
|
15
|
-
const layerDimensions = reduce(
|
|
16
|
-
splittedKey,
|
|
15
|
+
const layerDimensions = R.addIndex(R.reduce)(
|
|
17
16
|
(memo, dimensionValueIndex, dimensionIndex) => {
|
|
18
|
-
const dimension =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
17
|
+
const dimension = R.nth(dimensionIndex, dimensions);
|
|
18
|
+
const _dimensionValue = R.pathOr({}, ['values', Number(dimensionValueIndex)], dimension);
|
|
19
|
+
const label = dimensionValueDisplay(display)(_dimensionValue);
|
|
20
|
+
const dimensionValue = {
|
|
21
|
+
..._dimensionValue,
|
|
22
|
+
index: Number(dimensionValueIndex),
|
|
23
|
+
label
|
|
24
|
+
};
|
|
25
|
+
if (dimension.id === serieDimensionId) {
|
|
26
|
+
x = dimensionValue;
|
|
27
|
+
}
|
|
28
|
+
else if (R.has(dimension.id, dimensionsWithValuesIndexedById)) {
|
|
29
|
+
memo.push(dimensionValue);
|
|
30
|
+
layerKey.push(dimensionValueIndex);
|
|
32
31
|
}
|
|
33
32
|
return memo;
|
|
34
33
|
},
|
|
35
|
-
[]
|
|
34
|
+
[],
|
|
35
|
+
splittedKey
|
|
36
36
|
);
|
|
37
|
-
return ({ formater, x, y, layerDimensions, layerKey: join(
|
|
38
|
-
}
|
|
37
|
+
return ({ formater, x, y, layerDimensions, layerKey: R.join(':', layerKey) });
|
|
38
|
+
},
|
|
39
|
+
observations
|
|
39
40
|
);
|
|
41
|
+
|
|
42
|
+
return R.values(datapoints);
|
|
40
43
|
};
|
|
41
44
|
|
|
42
45
|
const serie = (observations, dimensions, dimensionsWithValuesIndexedById, serieDimensionId, display, formaterAttrs) => {
|
|
43
|
-
const serieDimension = find(
|
|
44
|
-
if (
|
|
45
|
-
return [];
|
|
46
|
+
const serieDimension = R.find(R.propEq('id', serieDimensionId), dimensions);
|
|
47
|
+
if (R.isNil(serieDimension)) {
|
|
48
|
+
return { datapoints: [], layerSeries: [] };
|
|
46
49
|
}
|
|
47
50
|
const _flatDatapoints = flatDatapoints(observations, dimensions, dimensionsWithValuesIndexedById, serieDimensionId, display, formaterAttrs);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
|
|
52
|
+
const layeredDatapoints = R.groupBy(
|
|
53
|
+
R.prop('layerKey'),
|
|
54
|
+
_flatDatapoints
|
|
51
55
|
); // { [layeredKey]: [dps] }
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
|
|
57
|
+
const layerFullSeries = R.map(
|
|
58
|
+
datapoints => ({
|
|
59
|
+
layerDimensions: R.prop('layerDimensions', R.head(datapoints)),
|
|
60
|
+
layerKey: R.prop('layerKey', R.head(datapoints))
|
|
61
|
+
}),
|
|
62
|
+
R.values(layeredDatapoints)
|
|
55
63
|
); // [{ layerDimensions, layerKey }]
|
|
56
|
-
const layerSeries = take(
|
|
57
|
-
const layeredDatapointsKeyedByX =
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const dps = keyBy(layerDps, dp => get(dp, 'x.id', ''));
|
|
61
|
-
return ({
|
|
62
|
-
...memo,
|
|
63
|
-
[`${key}`]: dps
|
|
64
|
-
});
|
|
65
|
-
},
|
|
66
|
-
{}
|
|
64
|
+
const layerSeries = R.take(5, R.sortBy(R.prop('layerKey'), layerFullSeries));
|
|
65
|
+
const layeredDatapointsKeyedByX = R.mapObjIndexed(
|
|
66
|
+
R.indexBy(R.path(['x', 'id'])),
|
|
67
|
+
layeredDatapoints
|
|
67
68
|
); // { [layeredKey]: { [x.id]: dp } }
|
|
68
|
-
const datapoints = map(
|
|
69
|
-
serieDimension.values,
|
|
69
|
+
const datapoints = R.addIndex(R.map)(
|
|
70
70
|
(serieValue, index) => {
|
|
71
71
|
const serieValueId = serieValue.id;
|
|
72
72
|
const x = dimensionValueDisplay(display)(serieValue);
|
|
73
|
-
const y = map(
|
|
73
|
+
const y = R.map(
|
|
74
|
+
({ layerKey }) => R.pathOr(null, [layerKey, serieValueId, 'y'], layeredDatapointsKeyedByX),
|
|
74
75
|
layerSeries,
|
|
75
|
-
({ layerKey }) => get(layeredDatapointsKeyedByX, `${layerKey}.${serieValueId}.y`, null)
|
|
76
76
|
);
|
|
77
|
-
const formaters = map(
|
|
77
|
+
const formaters = R.map(
|
|
78
|
+
({ layerKey }) => R.pathOr(null, [layerKey, serieValueId, 'formater'], layeredDatapointsKeyedByX),
|
|
78
79
|
layerSeries,
|
|
79
|
-
({ layerKey }) => get(layeredDatapointsKeyedByX, `${layerKey}.${serieValueId}.formater`, null)
|
|
80
80
|
);
|
|
81
81
|
return ({ category: x, formaters, index, x, y, key: serieValueId });
|
|
82
|
-
}
|
|
82
|
+
},
|
|
83
|
+
serieDimension.values,
|
|
84
|
+
);
|
|
85
|
+
const _datapoints = R.when(
|
|
86
|
+
R.pipe(R.length, R.equals(1)),
|
|
87
|
+
R.pipe(
|
|
88
|
+
R.set(R.lensPath([0, 'category']), ''),
|
|
89
|
+
R.set(R.lensPath([0, 'x']), ''),
|
|
90
|
+
),
|
|
91
|
+
datapoints
|
|
83
92
|
);
|
|
84
93
|
return ({
|
|
85
|
-
datapoints,
|
|
86
|
-
layerSeries: map(
|
|
87
|
-
layerSeries,
|
|
94
|
+
datapoints: _datapoints,
|
|
95
|
+
layerSeries: R.map(
|
|
88
96
|
layer => ({
|
|
89
|
-
id:
|
|
90
|
-
label:
|
|
91
|
-
})
|
|
97
|
+
id: R.pipe(R.prop('layerDimensions'), R.pluck('id'), R.join(' - '))(layer),
|
|
98
|
+
label: R.pipe(R.prop('layerDimensions'), R.pluck('label'), R.join(' - '))(layer),
|
|
99
|
+
}),
|
|
100
|
+
layerSeries
|
|
92
101
|
)
|
|
93
102
|
});
|
|
94
103
|
};
|
|
95
104
|
|
|
96
|
-
const percentSerie = (
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (!total) {
|
|
104
|
-
return dp;
|
|
105
|
-
}
|
|
106
|
-
return ({
|
|
107
|
-
...dp,
|
|
108
|
-
y: map(dp.y, value => (Math.abs(value) / total) * 100),
|
|
109
|
-
formaters: null,
|
|
110
|
-
});
|
|
105
|
+
const percentSerie = R.pipe(
|
|
106
|
+
R.over(
|
|
107
|
+
R.lensProp('datapoints'),
|
|
108
|
+
R.map(dp => {
|
|
109
|
+
const total = R.pipe(R.map(v => Math.abs(v)), R.sum)(dp.y);
|
|
110
|
+
if (!total) {
|
|
111
|
+
return dp;
|
|
111
112
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
return ({
|
|
114
|
+
...dp,
|
|
115
|
+
y: R.map(v => (Math.abs(v) / total) * 100, dp.y),
|
|
116
|
+
formaters: null,
|
|
117
|
+
});
|
|
118
|
+
})
|
|
119
|
+
),
|
|
120
|
+
R.of
|
|
121
|
+
);
|
|
115
122
|
|
|
116
|
-
const serieSortedByTotal = (
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}];
|
|
124
|
-
};
|
|
123
|
+
const serieSortedByTotal = R.pipe(
|
|
124
|
+
R.over(
|
|
125
|
+
R.lensProp('datapoints'),
|
|
126
|
+
R.sortBy(R.pipe(R.prop('y'), R.map(v => v > 0 ? R.negate(v) : 0), R.sum))
|
|
127
|
+
),
|
|
128
|
+
R.of
|
|
129
|
+
);
|
|
125
130
|
|
|
126
|
-
const serieSortedByDataOrder = (
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
const serieSortedByDataOrder = R.pipe(
|
|
132
|
+
R.over(
|
|
133
|
+
R.lensProp('datapoints'),
|
|
134
|
+
R.sortBy(R.prop('index'))
|
|
135
|
+
),
|
|
136
|
+
R.of
|
|
137
|
+
);
|
|
133
138
|
|
|
134
139
|
export default ({ observations, dimensions }, dimensionsWithValuesIndexedById, singularity, display, formaterAttrs) => {
|
|
135
|
-
const mode =
|
|
136
|
-
const serieDimensionId =
|
|
140
|
+
const mode = R.propOr('values', 'mode', singularity);
|
|
141
|
+
const serieDimensionId = R.propOr(null, 'id', singularity);
|
|
137
142
|
const _serie = serie(observations, dimensions, dimensionsWithValuesIndexedById, serieDimensionId, display, formaterAttrs);
|
|
138
143
|
if (mode === 'percent') {
|
|
139
144
|
return percentSerie(_serie);
|
|
@@ -141,5 +146,8 @@ export default ({ observations, dimensions }, dimensionsWithValuesIndexedById, s
|
|
|
141
146
|
else if (isTimePeriodDimension({ id: serieDimensionId })) {
|
|
142
147
|
return serieSortedByDataOrder(_serie);
|
|
143
148
|
}
|
|
144
|
-
|
|
149
|
+
//console.log('raw serie', _serie);
|
|
150
|
+
const res = serieSortedByTotal(_serie);
|
|
151
|
+
//console.log('serie', res);
|
|
152
|
+
return res;
|
|
145
153
|
};
|
package/src/rules/src/index.js
CHANGED
|
@@ -129,8 +129,7 @@ const _symbolDimension = (data, ids) => {
|
|
|
129
129
|
export const symbolDimension = memoizee(_symbolDimension);
|
|
130
130
|
|
|
131
131
|
const _stackedDimension = (data, singularity) => {
|
|
132
|
-
|
|
133
|
-
return __stackedDimension(values, singularity);
|
|
132
|
+
return __stackedDimension(splitDimensions(data), singularity);
|
|
134
133
|
}
|
|
135
134
|
export const stackedDimension = memoizee(_stackedDimension);
|
|
136
135
|
|
|
@@ -40,6 +40,7 @@ import {
|
|
|
40
40
|
} from './symbol';
|
|
41
41
|
import {
|
|
42
42
|
isStacked,
|
|
43
|
+
isStackedDimActive,
|
|
43
44
|
onChangeStackedDimension,
|
|
44
45
|
onChangeStackedMode,
|
|
45
46
|
stackedModeOptions,
|
|
@@ -205,6 +206,7 @@ export const initialState = {
|
|
|
205
206
|
};
|
|
206
207
|
|
|
207
208
|
export const stateFromNewProps = (props, state) => {
|
|
209
|
+
if (R.isNil(props.data)) return state; // don't reset state
|
|
208
210
|
const focusState = sampleFocusStateFromNewProps(props, state);
|
|
209
211
|
const scatterState = scatterStateFromNewProps(props, state);
|
|
210
212
|
const symbolState = symbolStateFromNewProps(props, state);
|
|
@@ -403,7 +405,7 @@ export const toProperties = (props, state, onChange) => ({
|
|
|
403
405
|
},
|
|
404
406
|
stackedDimension: {
|
|
405
407
|
id: 'stackedDimension',
|
|
406
|
-
isActive:
|
|
408
|
+
isActive: isStackedDimActive(props),
|
|
407
409
|
options: chartDimensionOptions(props, isStacked),
|
|
408
410
|
onChange: R.pipe(
|
|
409
411
|
optionParser,
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
getPropertyDimension,
|
|
7
7
|
toState
|
|
8
8
|
} from './utils';
|
|
9
|
+
import { splitDimensions } from '../';
|
|
9
10
|
import { focusStateFromNewProps } from './focus';
|
|
10
11
|
|
|
11
12
|
const getStackedDimension = getPropertyDimension('stackedDimension');
|
|
@@ -38,6 +39,15 @@ export const onChangeStackedDimension = ({ data }, state) => (value) => {
|
|
|
38
39
|
|
|
39
40
|
export const stackedModeOptions = [{ value: VALUES }, { value: PERCENT }];
|
|
40
41
|
|
|
42
|
+
export const isStackedDimActive = ({ data, type }) => {
|
|
43
|
+
const { values } = splitDimensions(data);
|
|
44
|
+
if (R.length(values) < 2) {
|
|
45
|
+
console.log('niet');
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
return isStacked(type);
|
|
49
|
+
};
|
|
50
|
+
|
|
41
51
|
export const onChangeStackedMode = (value) => R.has(value, stackedModes)
|
|
42
52
|
? ({ stackedMode: value })
|
|
43
53
|
: ({});
|
|
@@ -54,15 +64,21 @@ export const stackedStateFromNewProps = (props, state) => {
|
|
|
54
64
|
|
|
55
65
|
let dimension = getStackedDimension(data, state);
|
|
56
66
|
if (R.isNil(dimension)) {
|
|
57
|
-
const {
|
|
58
|
-
if (
|
|
59
|
-
dimension = R.head(
|
|
60
|
-
}
|
|
61
|
-
else if (!R.isNil(time) && !R.isEmpty(time)) {
|
|
62
|
-
dimension = R.head(time)
|
|
67
|
+
const { value, values } = splitDimensions(data);
|
|
68
|
+
if (R.length(values) === 1) {
|
|
69
|
+
dimension = R.head(value);
|
|
63
70
|
}
|
|
64
71
|
else {
|
|
65
|
-
|
|
72
|
+
const { area, time, other } = getGroupedDimensions(data);
|
|
73
|
+
if (!R.isNil(area) && !R.isEmpty(area)) {
|
|
74
|
+
dimension = R.head(area);
|
|
75
|
+
}
|
|
76
|
+
else if (!R.isNil(time) && !R.isEmpty(time)) {
|
|
77
|
+
dimension = R.head(time)
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
dimension = R.head(other);
|
|
81
|
+
}
|
|
66
82
|
}
|
|
67
83
|
}
|
|
68
84
|
const _mode = R.prop('stackedMode', state);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
equals,
|
|
3
3
|
find,
|
|
4
|
+
groupBy,
|
|
4
5
|
has,
|
|
5
6
|
head,
|
|
6
7
|
is,
|
|
7
8
|
isNil,
|
|
9
|
+
length,
|
|
8
10
|
map,
|
|
9
11
|
not,
|
|
10
12
|
omit,
|
|
@@ -15,7 +17,7 @@ import {
|
|
|
15
17
|
} from 'ramda';
|
|
16
18
|
import { isRefAreaDimension, isTimePeriodDimension } from '@sis-cc/dotstatsuite-sdmxjs';
|
|
17
19
|
import { extractSdmxArtefacts, parseDisplay, splitDimensions } from '../';
|
|
18
|
-
import { CHORO, H_SYMBOL, SCATTER, TYPES, V_SYMBOL } from '../constants';
|
|
20
|
+
import { CHORO, H_SYMBOL, SCATTER, STACKED, TYPES, V_SYMBOL } from '../constants';
|
|
19
21
|
import { dimensionValueDisplay } from '../dimension-utils';
|
|
20
22
|
|
|
21
23
|
export const isNumber = (input) => {
|
|
@@ -44,7 +46,7 @@ export const toState = (artefact) => prop('id', artefact);
|
|
|
44
46
|
|
|
45
47
|
export const getPropertyDimension = (property) => (data, state) => {
|
|
46
48
|
const statePropertyDimensionId = prop(property, state);
|
|
47
|
-
const dimensions =
|
|
49
|
+
const { dimensions } = extractSdmxArtefacts(data);
|
|
48
50
|
return find(
|
|
49
51
|
propEq('id', statePropertyDimensionId),
|
|
50
52
|
dimensions
|
|
@@ -99,6 +101,9 @@ export const chartDimensionOptions = ({ data, type, display }, typeValidator) =>
|
|
|
99
101
|
return [];
|
|
100
102
|
}
|
|
101
103
|
const dimensions = prop('values', splitDimensions(data));
|
|
104
|
+
if (equals(type, STACKED) && length(dimensions) === 1) {
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
102
107
|
return map(
|
|
103
108
|
artefactToOption(display),
|
|
104
109
|
dimensions
|
|
@@ -1,139 +1,123 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import '@blueprintjs/core/dist/blueprint.css';
|
|
5
|
-
import { find, prop, propEq } from 'ramda';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import * as R from 'ramda';
|
|
3
|
+
import { ChartsConfig } from '@sis-cc/dotstatsuite-visions';
|
|
6
4
|
import RulesDriver from './';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import Viewer1 from './app/viewer1';
|
|
11
|
-
import Viewer2 from './app/viewer2';
|
|
5
|
+
import data1 from './mocks/data1.json';
|
|
6
|
+
import data2 from './mocks/data2.json';
|
|
7
|
+
import { Viewer } from '../../';
|
|
12
8
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
this.onChangeData = this.onChangeData.bind(this);
|
|
54
|
-
this.onChangeType = this.onChangeType.bind(this);
|
|
55
|
-
this.onChangeViewer = this.onChangeViewer.bind(this);
|
|
56
|
-
this.onChangeDisplay = this.onChangeDisplay.bind(this);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
onChangeData(source) {
|
|
60
|
-
this.setState({ data: this.availableDatas[source], source });
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
onChangeType(type) {
|
|
64
|
-
this.setState({ type });
|
|
9
|
+
const labels = {
|
|
10
|
+
focus: 'Chart Focus',
|
|
11
|
+
highlight: 'Highlights',
|
|
12
|
+
baseline: 'Baseline',
|
|
13
|
+
select: 'Select',
|
|
14
|
+
size: 'Chart Size',
|
|
15
|
+
width: 'Width',
|
|
16
|
+
height: 'Height',
|
|
17
|
+
series: 'Chart Series',
|
|
18
|
+
scatterDimension: 'Scatter Dimension',
|
|
19
|
+
scatterX: 'Scatter X',
|
|
20
|
+
scatterY: 'Scatter Y',
|
|
21
|
+
symbolDimension: 'Symbol Dimension',
|
|
22
|
+
stackedDimension: 'Stacked Dimension',
|
|
23
|
+
stackedMode: 'Stacked Mode',
|
|
24
|
+
stackedModeOptions: {
|
|
25
|
+
values: 'Values',
|
|
26
|
+
percent: 'Percent',
|
|
27
|
+
},
|
|
28
|
+
axisX: 'Chart X Axis',
|
|
29
|
+
axisY: 'Chart Y Axis',
|
|
30
|
+
max: 'Max',
|
|
31
|
+
min: 'Min',
|
|
32
|
+
pivot: 'Pivot',
|
|
33
|
+
step: 'Step',
|
|
34
|
+
frequency: 'Frequency',
|
|
35
|
+
freqStep: 'Frequency Step',
|
|
36
|
+
logo: 'Remove logo',
|
|
37
|
+
copyright: 'Remove copyright',
|
|
38
|
+
title: 'Title',
|
|
39
|
+
subtitle: 'Subtitle',
|
|
40
|
+
source: 'Source',
|
|
41
|
+
information: 'Information',
|
|
42
|
+
reset: 'reset label',
|
|
43
|
+
uniqFocusOption: 'serie',
|
|
44
|
+
display: 'Display',
|
|
45
|
+
displayOptions: {
|
|
46
|
+
name: 'Name',
|
|
47
|
+
code: 'Code',
|
|
48
|
+
both: 'Both'
|
|
65
49
|
}
|
|
50
|
+
};
|
|
66
51
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
52
|
+
const renameKey = R.curry((oldKey, newKey, obj) =>
|
|
53
|
+
R.assoc(newKey, R.prop(oldKey, obj), R.dissoc(oldKey, obj)),
|
|
54
|
+
);
|
|
70
55
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
56
|
+
const renameProperties = (keys = []) =>
|
|
57
|
+
R.map(
|
|
58
|
+
R.ifElse(
|
|
59
|
+
R.pipe(R.prop('id'), R.flip(R.includes)(keys)),
|
|
60
|
+
renameKey('onChange', 'onSubmit'),
|
|
61
|
+
R.identity,
|
|
62
|
+
),
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const propertiesKeys = [
|
|
66
|
+
'width',
|
|
67
|
+
'height',
|
|
68
|
+
'freqStep',
|
|
69
|
+
'maxX',
|
|
70
|
+
'minX',
|
|
71
|
+
'pivotX',
|
|
72
|
+
'stepX',
|
|
73
|
+
'maxY',
|
|
74
|
+
'minY',
|
|
75
|
+
'pivotY',
|
|
76
|
+
'stepY',
|
|
77
|
+
'title',
|
|
78
|
+
'subtitle',
|
|
79
|
+
'source',
|
|
80
|
+
];
|
|
74
81
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
<span className="pt-navbar-divider"></span>
|
|
110
|
-
<Menu
|
|
111
|
-
align="right"
|
|
112
|
-
iconName="import"
|
|
113
|
-
items={this.sources}
|
|
114
|
-
onChange={this.onChangeData}
|
|
115
|
-
selected={source}
|
|
116
|
-
/>
|
|
117
|
-
</nav>
|
|
118
|
-
<RulesDriver
|
|
119
|
-
data={data}
|
|
120
|
-
dataflowCode={dataflowCode}
|
|
121
|
-
display={display}
|
|
122
|
-
options={{ base: { height: 500 } }}
|
|
123
|
-
type={type}
|
|
124
|
-
render={
|
|
125
|
-
({ chartData, chartOptions, onChange, properties }) => (
|
|
126
|
-
<Viewer
|
|
127
|
-
chartData={chartData}
|
|
128
|
-
chartOptions={chartOptions}
|
|
129
|
-
onChange={onChange}
|
|
130
|
-
properties={{ ...properties, ...displayProperties }}
|
|
131
|
-
type={type}
|
|
132
|
-
/>
|
|
133
|
-
)
|
|
82
|
+
const App = () => {
|
|
83
|
+
const [toggle, setToggle] = useState(true);
|
|
84
|
+
const dataflow = { id: "DF_KEI_21760", name: "Harmonised Unemployment Rate" };
|
|
85
|
+
const display = 'label';
|
|
86
|
+
const type = 'BarChart';
|
|
87
|
+
const props = { dataflow, display, type }
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<div>
|
|
91
|
+
<button onClick={() => setToggle(prev => !prev)} style={{ marginBottom: '10px' }}>Toggle Selection</button>
|
|
92
|
+
<RulesDriver
|
|
93
|
+
data={toggle ? data1 : data2}
|
|
94
|
+
{...props}
|
|
95
|
+
display={display}
|
|
96
|
+
type={type}
|
|
97
|
+
render={
|
|
98
|
+
({ properties, ...parsedProps }) => {
|
|
99
|
+
return (
|
|
100
|
+
<div>
|
|
101
|
+
<ChartsConfig
|
|
102
|
+
properties={R.pipe(
|
|
103
|
+
renameProperties(propertiesKeys),
|
|
104
|
+
)(properties)}
|
|
105
|
+
labels={labels}
|
|
106
|
+
/>
|
|
107
|
+
<Viewer
|
|
108
|
+
{...parsedProps}
|
|
109
|
+
chartData={R.pick(['series', 'frequency'])(parsedProps.chartData)}
|
|
110
|
+
properties={R.tap(console.log)(R.over(R.lensProp('baseline'), R.omit(['onChange']), properties))}
|
|
111
|
+
type='BarChart'
|
|
112
|
+
locale='en'
|
|
113
|
+
/>
|
|
114
|
+
</div>
|
|
115
|
+
);
|
|
134
116
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
117
|
+
}
|
|
118
|
+
/>
|
|
119
|
+
</div>
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export default App;
|