@sis-cc/dotstatsuite-components 16.7.0 → 16.8.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/viewer/src/chart.js +30 -34
- package/lib/viewer/src/index.js +32 -43
- package/package.json +5 -5
- package/src/viewer/src/chart.js +28 -28
- package/src/viewer/src/index.js +28 -43
package/lib/viewer/src/chart.js
CHANGED
|
@@ -4,12 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
+
var _extends2 = require('babel-runtime/helpers/extends');
|
|
8
|
+
|
|
9
|
+
var _extends3 = _interopRequireDefault(_extends2);
|
|
10
|
+
|
|
7
11
|
var _react = require('react');
|
|
8
12
|
|
|
9
13
|
var _react2 = _interopRequireDefault(_react);
|
|
10
14
|
|
|
11
|
-
var _recompose = require('recompose');
|
|
12
|
-
|
|
13
15
|
var _ramda = require('ramda');
|
|
14
16
|
|
|
15
17
|
var R = _interopRequireWildcard(_ramda);
|
|
@@ -54,36 +56,30 @@ var Chart = function Chart(_ref) {
|
|
|
54
56
|
);
|
|
55
57
|
};
|
|
56
58
|
|
|
57
|
-
|
|
58
|
-
var
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
59
|
+
var ChartWrapper = function ChartWrapper() {
|
|
60
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
61
|
+
|
|
62
|
+
var options = R.over( // adjust svg height regarding header and footer height
|
|
63
|
+
R.lensPath(['base', 'height']), R.pipe(function (h) {
|
|
64
|
+
return h - props.heightOffsets.header - props.heightOffsets.footer - 2;
|
|
65
|
+
}, R.when(R.gt(0), R.always(300))), // 2 = borders
|
|
66
|
+
props.options);
|
|
67
|
+
|
|
68
|
+
if ((0, _utils.isChartNoData)((0, _extends3.default)({}, props, { options: options }))) {
|
|
69
|
+
if (R.isNil(props.fixedHeight)) return _react2.default.createElement(_dotstatsuiteVisions.NoData, { message: props.noData || 'No Data' });
|
|
70
|
+
|
|
71
|
+
var height = R.path(['base', 'height'], options);
|
|
72
|
+
var style = R.equals(0, height) ? { height: 'auto' } : { height: height };
|
|
73
|
+
return _react2.default.createElement(
|
|
74
|
+
'div',
|
|
75
|
+
{ style: style },
|
|
76
|
+
_react2.default.createElement(_dotstatsuiteVisions.NoData, { message: props.noData || 'No Data' })
|
|
77
|
+
);
|
|
74
78
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
})), (0, _recompose.withProps)(function (_ref4) {
|
|
83
|
-
var data = _ref4.data,
|
|
84
|
-
options = _ref4.options,
|
|
85
|
-
type = _ref4.type;
|
|
86
|
-
return {
|
|
87
|
-
series: (0, _series2.default)(data.series, type, options) // responsive rule only display highlighted data
|
|
88
|
-
};
|
|
89
|
-
}))(Chart);
|
|
79
|
+
|
|
80
|
+
return _react2.default.createElement(Chart, (0, _extends3.default)({}, props, {
|
|
81
|
+
series: (0, _series2.default)(props.data.series, props.type, options) // responsive rule only display highlighted data
|
|
82
|
+
}));
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
exports.default = ChartWrapper;
|
package/lib/viewer/src/index.js
CHANGED
|
@@ -4,6 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
+
var _slicedToArray2 = require('babel-runtime/helpers/slicedToArray');
|
|
8
|
+
|
|
9
|
+
var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);
|
|
10
|
+
|
|
7
11
|
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
|
|
8
12
|
|
|
9
13
|
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
|
|
@@ -28,8 +32,6 @@ var _classnames = require('classnames');
|
|
|
28
32
|
|
|
29
33
|
var _classnames2 = _interopRequireDefault(_classnames);
|
|
30
34
|
|
|
31
|
-
var _recompose = require('recompose');
|
|
32
|
-
|
|
33
35
|
var _reactSizeme = require('react-sizeme');
|
|
34
36
|
|
|
35
37
|
var _reactSizeme2 = _interopRequireDefault(_reactSizeme);
|
|
@@ -165,50 +167,37 @@ var Viewer = function Viewer(_ref4) {
|
|
|
165
167
|
);
|
|
166
168
|
};
|
|
167
169
|
|
|
168
|
-
|
|
169
|
-
var
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
170
|
+
var ViewerWrapper = function ViewerWrapper(_ref5) {
|
|
171
|
+
var chartOptions = _ref5.chartOptions,
|
|
172
|
+
type = _ref5.type,
|
|
173
|
+
props = (0, _objectWithoutProperties3.default)(_ref5, ['chartOptions', 'type']);
|
|
174
|
+
|
|
175
|
+
var theme = (0, _styles.useTheme)();
|
|
176
|
+
|
|
177
|
+
var _useState = (0, _react.useState)({ footer: 0, header: 0 }),
|
|
178
|
+
_useState2 = (0, _slicedToArray3.default)(_useState, 2),
|
|
179
|
+
heightOffsets = _useState2[0],
|
|
180
|
+
setHeightOffsets = _useState2[1];
|
|
181
|
+
|
|
182
|
+
if (type === 'table') return _react2.default.createElement(Viewer, (0, _extends3.default)({}, props, { chartOptions: chartOptions, type: type }));
|
|
183
|
+
|
|
184
|
+
var preparedChartOptions = R.pipe(R.over(R.lensPath(['base', 'width']), R.when(R.anyPass([R.isNil, isNaN]), R.always(props.size.width || 0))), R.over(R.lensPath(['base', 'height']), R.when(R.anyPass([R.isNil, isNaN]), R.always(0))), function (chartOptions) {
|
|
185
|
+
return (0, _options2.default)(chartOptions, props.chartData, type, theme, props.timeFormats, props.locale);
|
|
186
|
+
})(chartOptions);
|
|
187
|
+
|
|
188
|
+
return _react2.default.createElement(Viewer, (0, _extends3.default)({}, props, {
|
|
189
|
+
chartOptions: preparedChartOptions,
|
|
190
|
+
fixedWidth: R.path(['base', 'width'], chartOptions),
|
|
191
|
+
fixedHeight: R.path(['base', 'height'], chartOptions),
|
|
192
|
+
heightOffsets: heightOffsets,
|
|
176
193
|
setFooterOffset: function setFooterOffset(offset) {
|
|
177
194
|
return setHeightOffsets(R.assoc('footer', offset));
|
|
178
195
|
},
|
|
179
196
|
setHeaderOffset: function setHeaderOffset(offset) {
|
|
180
197
|
return setHeightOffsets(R.assoc('header', offset));
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
})
|
|
184
|
-
|
|
185
|
-
var chartOptions = _ref6.chartOptions,
|
|
186
|
-
heightOffsets = _ref6.heightOffsets,
|
|
187
|
-
size = _ref6.size,
|
|
188
|
-
type = _ref6.type;
|
|
189
|
-
|
|
190
|
-
if (type === 'table') {
|
|
191
|
-
return {};
|
|
192
|
-
}
|
|
193
|
-
var offsets = heightOffsets.header + heightOffsets.footer;
|
|
194
|
-
return {
|
|
195
|
-
chartOptions: R.pipe(R.over(R.lensPath(['base', 'width']), R.when(R.anyPass([R.isNil, isNaN]), R.always(size.width || 0))), R.over(R.lensPath(['base', 'height']), R.when(R.anyPass([R.isNil, isNaN]), R.always(0))))(chartOptions),
|
|
196
|
-
fixedWidth: R.path(['base', 'width'], chartOptions),
|
|
197
|
-
fixedHeight: R.path(['base', 'height'], chartOptions)
|
|
198
|
-
};
|
|
199
|
-
}), (0, _recompose.withProps)( // compute all chart options regarding oecd design
|
|
200
|
-
function (_ref7) {
|
|
201
|
-
var chartData = _ref7.chartData,
|
|
202
|
-
chartOptions = _ref7.chartOptions,
|
|
203
|
-
timeFormats = _ref7.timeFormats,
|
|
204
|
-
type = _ref7.type,
|
|
205
|
-
locale = _ref7.locale;
|
|
198
|
+
},
|
|
199
|
+
type: type
|
|
200
|
+
}));
|
|
201
|
+
};
|
|
206
202
|
|
|
207
|
-
|
|
208
|
-
return {};
|
|
209
|
-
}
|
|
210
|
-
var theme = (0, _styles.useTheme)();
|
|
211
|
-
return {
|
|
212
|
-
chartOptions: (0, _options2.default)(chartOptions, chartData, type, theme, timeFormats, locale)
|
|
213
|
-
};
|
|
214
|
-
}))(Viewer);
|
|
203
|
+
exports.default = (0, _reactSizeme2.default)({ noPlaceholder: true, monitorWidth: true, monitorHeight: true })(ViewerWrapper);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sis-cc/dotstatsuite-components",
|
|
3
3
|
"description": "Set components based on React.",
|
|
4
|
-
"version": "16.
|
|
4
|
+
"version": "16.8.0",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"author": "OECD",
|
|
7
7
|
"license": "MIT",
|
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@blueprintjs/core": "^1.22.0",
|
|
16
|
+
"@material-ui/core": "^4.12.3",
|
|
16
17
|
"@sis-cc/dotstatsuite-sdmxjs": "*",
|
|
17
18
|
"@sis-cc/dotstatsuite-visions": "*",
|
|
18
|
-
"@material-ui/core": "^4.12.3",
|
|
19
19
|
"react": "^16.11.0",
|
|
20
|
+
"react-addons-css-transition-group": "^15.6.2",
|
|
20
21
|
"react-helmet": "^5.2.1",
|
|
21
22
|
"web-component-env": "^2.0.0"
|
|
22
23
|
},
|
|
@@ -31,13 +32,12 @@
|
|
|
31
32
|
"prop-types": "^15.6.2",
|
|
32
33
|
"ramda": "^0.26.1",
|
|
33
34
|
"react-dom": "^16.5.2",
|
|
34
|
-
"react-sizeme": "^2.3.6"
|
|
35
|
-
"recompose": "^0.30.0"
|
|
35
|
+
"react-sizeme": "^2.3.6"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@material-ui/core": "^4.x",
|
|
39
|
-
"@sis-cc/dotstatsuite-visions": "^7.x",
|
|
40
39
|
"@sis-cc/dotstatsuite-sdmxjs": "^8.x",
|
|
40
|
+
"@sis-cc/dotstatsuite-visions": "^7.x",
|
|
41
41
|
"react": "16.x"
|
|
42
42
|
}
|
|
43
43
|
}
|
package/src/viewer/src/chart.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { branch, compose, renderComponent, withProps } from 'recompose';
|
|
3
2
|
import * as R from 'ramda';
|
|
4
3
|
import { NoData } from '@sis-cc/dotstatsuite-visions';
|
|
5
4
|
import * as charts from '../../bridge-d3-react/src';
|
|
@@ -25,30 +24,31 @@ const Chart = ({ options, series, type, width, getAxisOptions }) => {
|
|
|
25
24
|
);
|
|
26
25
|
};
|
|
27
26
|
|
|
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
|
-
|
|
54
|
-
|
|
27
|
+
const ChartWrapper = (props = {}) => {
|
|
28
|
+
const options = R.over( // adjust svg height regarding header and footer height
|
|
29
|
+
R.lensPath(['base', 'height']),
|
|
30
|
+
R.pipe(h => h - props.heightOffsets.header - props.heightOffsets.footer - 2, R.when(R.gt(0), R.always(300))), // 2 = borders
|
|
31
|
+
props.options
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
if (isChartNoData({...props, options })) {
|
|
35
|
+
if (R.isNil(props.fixedHeight)) return <NoData message={props.noData || 'No Data'} />;
|
|
36
|
+
|
|
37
|
+
const height = R.path(['base', 'height'], options);
|
|
38
|
+
const style = R.equals(0, height) ? { height: 'auto' } : { height };
|
|
39
|
+
return (
|
|
40
|
+
<div style={style}>
|
|
41
|
+
<NoData message={props.noData || 'No Data'} />
|
|
42
|
+
</div>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<Chart
|
|
48
|
+
{...props}
|
|
49
|
+
series={filterSeriesRegardingDimensions(props.data.series, props.type, options)} // responsive rule only display highlighted data
|
|
50
|
+
/>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default ChartWrapper;
|
package/src/viewer/src/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import * as R from 'ramda';
|
|
3
3
|
import cx from 'classnames';
|
|
4
|
-
import { compose, withState, withProps } from 'recompose';
|
|
5
4
|
import sizeMe from 'react-sizeme';
|
|
6
5
|
import { Loading, NoData, TableHtml5 } from '@sis-cc/dotstatsuite-visions';
|
|
7
6
|
import { useTheme, makeStyles } from '@material-ui/core/styles';
|
|
@@ -95,44 +94,30 @@ const Viewer = ({ getResponsiveSize, setFooterOffset, setHeaderOffset, size, typ
|
|
|
95
94
|
);
|
|
96
95
|
};
|
|
97
96
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
fixedHeight: R.path(['base', 'height'], chartOptions),
|
|
126
|
-
});
|
|
127
|
-
}),
|
|
128
|
-
withProps( // compute all chart options regarding oecd design
|
|
129
|
-
({ chartData, chartOptions, timeFormats, type, locale }) => {
|
|
130
|
-
if (type === 'table') {
|
|
131
|
-
return ({});
|
|
132
|
-
}
|
|
133
|
-
const theme = useTheme();
|
|
134
|
-
return ({
|
|
135
|
-
chartOptions: getChartOptions(chartOptions, chartData, type, theme, timeFormats, locale)
|
|
136
|
-
});
|
|
137
|
-
})
|
|
138
|
-
)(Viewer);
|
|
97
|
+
const ViewerWrapper = ({ chartOptions, type, ...props }) => {
|
|
98
|
+
const theme = useTheme();
|
|
99
|
+
const [heightOffsets, setHeightOffsets] = useState({ footer: 0, header: 0 });
|
|
100
|
+
|
|
101
|
+
if (type === 'table') return <Viewer {...props} chartOptions={chartOptions} type={type} />;
|
|
102
|
+
|
|
103
|
+
const preparedChartOptions = R.pipe(
|
|
104
|
+
R.over(R.lensPath(['base', 'width']), R.when(R.anyPass([R.isNil, isNaN]), R.always(props.size.width || 0))),
|
|
105
|
+
R.over(R.lensPath(['base', 'height']), R.when(R.anyPass([R.isNil, isNaN]), R.always(0))),
|
|
106
|
+
chartOptions => getChartOptions(chartOptions, props.chartData, type, theme, props.timeFormats, props.locale),
|
|
107
|
+
)(chartOptions);
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<Viewer
|
|
111
|
+
{...props}
|
|
112
|
+
chartOptions={preparedChartOptions}
|
|
113
|
+
fixedWidth={R.path(['base', 'width'], chartOptions)}
|
|
114
|
+
fixedHeight={R.path(['base', 'height'], chartOptions)}
|
|
115
|
+
heightOffsets={heightOffsets}
|
|
116
|
+
setFooterOffset={offset => setHeightOffsets(R.assoc('footer', offset))}
|
|
117
|
+
setHeaderOffset={offset => setHeightOffsets(R.assoc('header', offset))}
|
|
118
|
+
type={type}
|
|
119
|
+
/>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export default sizeMe({ noPlaceholder: true, monitorWidth: true, monitorHeight: true })(ViewerWrapper);
|