@sis-cc/dotstatsuite-components 8.10.0 → 8.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/lib/app.js +13 -5
  2. package/lib/rules/src/chart/getChartOptions.js +1 -1
  3. package/lib/rules/src/properties/index.js +1 -0
  4. package/lib/rules-driver/src/app.js +116 -167
  5. package/lib/viewer/src/app/use-case-3.js +52 -0
  6. package/lib/viewer/src/app.js +9 -0
  7. package/lib/viewer/src/chartUtils/series.js +3 -5
  8. package/lib/viewer/src/index.js +1 -1
  9. package/package.json +2 -2
  10. package/src/app.js +10 -5
  11. package/src/rules/src/chart/getChartOptions.js +2 -2
  12. package/src/rules/src/properties/index.js +1 -0
  13. package/src/rules-driver/src/app.js +116 -132
  14. package/src/rules-driver/src/mocks/data1.json +332 -0
  15. package/src/rules-driver/src/mocks/data2.json +309 -0
  16. package/src/viewer/src/app/use-case-3.js +18 -0
  17. package/src/viewer/src/app.js +6 -0
  18. package/src/viewer/src/chartUtils/series.js +4 -4
  19. package/src/viewer/src/index.js +2 -2
  20. package/lib/rules-driver/src/app/chart.js +0 -52
  21. package/lib/rules-driver/src/app/config-axis.js +0 -95
  22. package/lib/rules-driver/src/app/config-buttons.js +0 -47
  23. package/lib/rules-driver/src/app/config-input.js +0 -51
  24. package/lib/rules-driver/src/app/config-select.js +0 -57
  25. package/lib/rules-driver/src/app/config-t4size.js +0 -61
  26. package/lib/rules-driver/src/app/config1.js +0 -148
  27. package/lib/rules-driver/src/app/menu.js +0 -44
  28. package/lib/rules-driver/src/app/viewer1.js +0 -39
  29. package/lib/rules-driver/src/app/viewer2.js +0 -115
  30. package/src/rules-driver/src/app/chart.js +0 -18
  31. package/src/rules-driver/src/app/config-axis.js +0 -54
  32. package/src/rules-driver/src/app/config-buttons.js +0 -27
  33. package/src/rules-driver/src/app/config-input.js +0 -35
  34. package/src/rules-driver/src/app/config-select.js +0 -25
  35. package/src/rules-driver/src/app/config-t4size.js +0 -50
  36. package/src/rules-driver/src/app/config1.js +0 -120
  37. package/src/rules-driver/src/app/menu.js +0 -27
  38. package/src/rules-driver/src/app/viewer1.js +0 -18
  39. package/src/rules-driver/src/app/viewer2.js +0 -77
  40. package/src/rules-driver/src/mocks/ecb.json +0 -2069
  41. package/src/rules-driver/src/mocks/ins.json +0 -264
  42. package/src/rules-driver/src/mocks/oecd-time.json +0 -864
  43. package/src/rules-driver/src/mocks/oecd.json +0 -372
  44. package/src/rules-driver/src/mocks/tunisia.json +0 -333
@@ -1,139 +1,123 @@
1
- import React, { Component } from 'react';
2
- import { render } from 'react-dom';
3
- import { Button } from '@blueprintjs/core';
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 oecdData from './mocks/oecd.json';
8
- import oecdTimeData from './mocks/oecd-time.json';
9
- import Menu from './app/menu';
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
- export default class App extends Component {
14
- constructor(props) {
15
- super(props);
16
-
17
- this.availableDatas = { oecdData, oecdTimeData };
18
-
19
- this.sources = [
20
- { label: 'oecd', value: 'oecdData', dataflowCode: 'KEI' },
21
- { label: 'oecd quarter', value: 'oecdTimeData', dataflowCode: 'KEI' }
22
- ];
23
-
24
- this.chartTypes = [
25
- { label: 'Bar', value: 'BarChart' },
26
- { label: 'Row', value: 'RowChart' },
27
- { label: 'Scatter', value: 'ScatterChart' },
28
- { label: 'Timeline', value: 'TimelineChart' },
29
- { label: 'H Symbol', value: 'HorizontalSymbolChart' },
30
- { label: 'V Symbol', value: 'VerticalSymbolChart' },
31
- { label: 'Stacked Bar', value: 'StackedBarChart' },
32
- { label: 'Non Chart Type', value: 'NonChartType' }
33
- ];
34
-
35
- this.viewerOptions = [
36
- { label: 'Old Classic OCC View', value: 'Viewer1' },
37
- { label: 'Alternative Split', value: 'Viewer2' },
38
- ];
39
-
40
- this.viewers = {
41
- Viewer1,
42
- Viewer2,
43
- };
44
-
45
- this.state = {
46
- data: oecdData,
47
- display: 'label',
48
- source: 'oecdData',
49
- type: 'BarChart',
50
- viewer: 'Viewer1',
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
- onChangeViewer(viewer) {
68
- this.setState({ viewer });
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
- onChangeDisplay(display) {
72
- this.setState({ display });
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
- render() {
76
- const { data, source, type, viewer, display } = this.state;
77
- const displayOptions = [
78
- { label: 'label', value: 'label' },
79
- { label: 'code', value: 'code' },
80
- { label: 'both', value: 'both' }
81
- ];
82
- const displayProperties = {
83
- display: {
84
- isActive: true,
85
- label: 'Display as',
86
- onChange: this.onChangeDisplay,
87
- options: displayOptions,
88
- value: display,
89
- }
90
- };
91
- const dataflowCode = prop('dataflowCode', find(propEq('value', this.state.source), this.sources));
92
- const Viewer = this.viewers[viewer];
93
- return (
94
- <div>
95
- <nav className="pt-navbar pt-dark">
96
- <Menu
97
- align="left"
98
- items={this.viewerOptions}
99
- onChange={this.onChangeViewer}
100
- selected={viewer}
101
- />
102
- <span className="pt-navbar-divider"></span>
103
- <Menu
104
- align="right"
105
- items={this.chartTypes}
106
- onChange={this.onChangeType}
107
- selected={type}
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
- </div>
137
- );
138
- };
139
- };
117
+ }
118
+ />
119
+ </div>
120
+ )
121
+ }
122
+
123
+ export default App;
@@ -0,0 +1,332 @@
1
+ {
2
+ "header": {
3
+ "schema": "https://raw.githubusercontent.com/sdmx-twg/sdmx-json/master/data-message/tools/schemas/1.0/sdmx-json-data-schema.json",
4
+ "id": "IREF000446",
5
+ "prepared": "2021-09-07T13:44:06Z",
6
+ "test": true,
7
+ "contentLanguages": [
8
+ "en"
9
+ ],
10
+ "sender": {
11
+ "id": "SIS-CC-stable_-_DotStat_v8",
12
+ "name": "unknown",
13
+ "names": {
14
+ "en": "unknown"
15
+ }
16
+ }
17
+ },
18
+ "dataSets": [
19
+ {
20
+ "action": "Information",
21
+ "links": [
22
+ {
23
+ "urn": "urn:sdmx:org.sdmx.infomodel.datastructure.DataStructure=OECD:DSD_KEI(1.0)",
24
+ "rel": "DataStructure"
25
+ }
26
+ ],
27
+ "annotations": [
28
+ 0,
29
+ 1,
30
+ 2,
31
+ 3,
32
+ 4
33
+ ],
34
+ "observations": {
35
+ "0:0:0:0:0": [
36
+ 5.73333333333333
37
+ ],
38
+ "0:1:0:0:0": [
39
+ 8.5
40
+ ],
41
+ "0:2:0:0:0": [
42
+ 6.05642340833333
43
+ ]
44
+ }
45
+ }
46
+ ],
47
+ "structure": {
48
+ "name": "Harmonised Unemployment Rate",
49
+ "names": {
50
+ "en": "Harmonised Unemployment Rate"
51
+ },
52
+ "dimensions": {
53
+ "observation": [
54
+ {
55
+ "id": "SUBJECT",
56
+ "name": "Subject",
57
+ "names": {
58
+ "en": "Subject"
59
+ },
60
+ "keyPosition": 0,
61
+ "roles": [
62
+ "SUBJECT"
63
+ ],
64
+ "values": [
65
+ {
66
+ "id": "LRHUTTTT",
67
+ "order": 75,
68
+ "name": "Harmonised unemployment rate: all persons, s.a.",
69
+ "names": {
70
+ "en": "Harmonised unemployment rate: all persons, s.a."
71
+ },
72
+ "parent": "LR",
73
+ "annotations": [
74
+ 5
75
+ ],
76
+ "__indexPosition": 0,
77
+ "__index": 0
78
+ }
79
+ ],
80
+ "role": "SUBJECT"
81
+ },
82
+ {
83
+ "id": "LOCATION",
84
+ "name": "Country",
85
+ "names": {
86
+ "en": "Country"
87
+ },
88
+ "keyPosition": 1,
89
+ "roles": [
90
+ "LOCATION"
91
+ ],
92
+ "values": [
93
+ {
94
+ "id": "AUS",
95
+ "order": 0,
96
+ "name": "Australia",
97
+ "names": {
98
+ "en": "Australia"
99
+ },
100
+ "annotations": [
101
+ 5
102
+ ],
103
+ "__indexPosition": 0,
104
+ "__index": 2
105
+ },
106
+ {
107
+ "id": "AUT",
108
+ "order": 1,
109
+ "name": "Austria",
110
+ "names": {
111
+ "en": "Austria"
112
+ },
113
+ "annotations": [
114
+ 6
115
+ ],
116
+ "__indexPosition": 1,
117
+ "__index": 0
118
+ },
119
+ {
120
+ "id": "BEL",
121
+ "order": 2,
122
+ "name": "Belgium",
123
+ "names": {
124
+ "en": "Belgium"
125
+ },
126
+ "annotations": [
127
+ 7
128
+ ],
129
+ "__indexPosition": 2,
130
+ "__index": 1
131
+ }
132
+ ],
133
+ "role": "LOCATION"
134
+ },
135
+ {
136
+ "id": "MEASURE",
137
+ "name": "Measure",
138
+ "names": {
139
+ "en": "Measure"
140
+ },
141
+ "keyPosition": 2,
142
+ "roles": [
143
+ "MEASURE"
144
+ ],
145
+ "values": [
146
+ {
147
+ "id": "ST",
148
+ "order": 5,
149
+ "name": "Level, ratio or index",
150
+ "names": {
151
+ "en": "Level, ratio or index"
152
+ },
153
+ "annotations": [
154
+ 7
155
+ ],
156
+ "__indexPosition": 0,
157
+ "__index": 0
158
+ }
159
+ ],
160
+ "role": "MEASURE"
161
+ },
162
+ {
163
+ "id": "FREQUENCY",
164
+ "name": "Frequency",
165
+ "names": {
166
+ "en": "Frequency"
167
+ },
168
+ "keyPosition": 3,
169
+ "roles": [
170
+ "FREQUENCY"
171
+ ],
172
+ "values": [
173
+ {
174
+ "id": "A",
175
+ "order": 0,
176
+ "name": "Annual",
177
+ "names": {
178
+ "en": "Annual"
179
+ },
180
+ "annotations": [
181
+ 8
182
+ ],
183
+ "__indexPosition": 0,
184
+ "__index": 0
185
+ }
186
+ ],
187
+ "role": "FREQUENCY"
188
+ },
189
+ {
190
+ "id": "TIME_PERIOD",
191
+ "name": "Time",
192
+ "names": {
193
+ "en": "Time"
194
+ },
195
+ "keyPosition": 4,
196
+ "roles": [
197
+ "TIME"
198
+ ],
199
+ "values": [
200
+ {
201
+ "start": "2015-01-01T00:00:00Z",
202
+ "end": "2015-12-31T23:59:59Z",
203
+ "id": "2015",
204
+ "name": "2015",
205
+ "names": {
206
+ "en": "2015"
207
+ },
208
+ "__indexPosition": 0,
209
+ "__index": 0
210
+ }
211
+ ],
212
+ "role": "TIME"
213
+ }
214
+ ]
215
+ },
216
+ "attributes": {
217
+ "dataSet": [
218
+ {
219
+ "id": "OBS_STATUS",
220
+ "name": "Observation Status",
221
+ "names": {
222
+ "en": "Observation Status"
223
+ },
224
+ "roles": [
225
+ "OBS_STATUS"
226
+ ],
227
+ "relationship": {
228
+ "none": {}
229
+ },
230
+ "values": []
231
+ },
232
+ {
233
+ "id": "UNIT_MEASURE",
234
+ "name": "Unit of Measures",
235
+ "names": {
236
+ "en": "Unit of Measures"
237
+ },
238
+ "roles": [
239
+ "UNIT_MEASURE"
240
+ ],
241
+ "relationship": {
242
+ "none": {}
243
+ },
244
+ "values": []
245
+ },
246
+ {
247
+ "id": "UNIT_MULT",
248
+ "name": "Multiplier",
249
+ "names": {
250
+ "en": "Multiplier"
251
+ },
252
+ "roles": [
253
+ "UNIT_MULT"
254
+ ],
255
+ "relationship": {
256
+ "none": {}
257
+ },
258
+ "values": []
259
+ },
260
+ {
261
+ "id": "BASE_PER",
262
+ "name": "Base reference period",
263
+ "names": {
264
+ "en": "Base reference period"
265
+ },
266
+ "roles": [
267
+ "BASE_PER"
268
+ ],
269
+ "relationship": {
270
+ "none": {}
271
+ },
272
+ "values": []
273
+ }
274
+ ],
275
+ "series": [],
276
+ "observation": []
277
+ },
278
+ "annotations": [
279
+ {
280
+ "type": "NonProductionDataflow",
281
+ "text": "true",
282
+ "texts": {
283
+ "en": "true"
284
+ }
285
+ },
286
+ {
287
+ "title": "FREQUENCY=A,SUBJECT=LRHUTTTT,TIME_PERIOD_START=2015",
288
+ "type": "DEFAULT"
289
+ },
290
+ {
291
+ "title": "LOCATION",
292
+ "type": "LAYOUT_ROW"
293
+ },
294
+ {
295
+ "title": "TIME_PERIOD",
296
+ "type": "LAYOUT_COLUMN"
297
+ },
298
+ {
299
+ "title": "FREQ",
300
+ "type": "NOT_DISPLAYED"
301
+ },
302
+ {
303
+ "type": "ORDER",
304
+ "text": "1",
305
+ "texts": {
306
+ "en": "1"
307
+ }
308
+ },
309
+ {
310
+ "type": "ORDER",
311
+ "text": "2",
312
+ "texts": {
313
+ "en": "2"
314
+ }
315
+ },
316
+ {
317
+ "type": "ORDER",
318
+ "text": "3",
319
+ "texts": {
320
+ "en": "3"
321
+ }
322
+ },
323
+ {
324
+ "type": "ORDER",
325
+ "text": "0",
326
+ "texts": {
327
+ "en": "0"
328
+ }
329
+ }
330
+ ]
331
+ }
332
+ }