@sis-cc/dotstatsuite-components 11.0.0 → 12.1.1
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/rules/src/table/factories/getLayoutWithFlags.js +16 -7
- package/lib/rules/src/table/factories/getTableData.js +1 -1
- package/lib/rules/src/table/preparators/prepareData.js +6 -1
- package/lib/rules2/src/constants.js +2 -2
- package/lib/rules2/src/index.js +11 -5
- package/lib/rules2/src/refineMetadataCoordinates.js +4 -4
- package/lib/rules2/src/{json2.0DataFormatPatch.js → sdmx3.0DataFormatPatch.js} +2 -2
- package/lib/viewer/src/chart.js +48 -41
- package/lib/viewer/src/index.js +76 -56
- package/package.json +2 -7
- package/src/rules/src/table/factories/getLayoutWithFlags.js +19 -8
- package/src/rules/src/table/factories/getTableData.js +1 -1
- package/src/rules/src/table/preparators/prepareData.js +6 -1
- package/src/rules2/src/constants.js +2 -2
- package/src/rules2/src/index.js +5 -2
- package/src/rules2/src/refineMetadataCoordinates.js +4 -4
- package/src/rules2/src/{json2.0DataFormatPatch.js → sdmx3.0DataFormatPatch.js} +1 -1
- package/src/viewer/src/chart.js +15 -14
- package/src/viewer/src/index.js +35 -26
- package/test/getLayoutDataWithFlags.test.js +2 -2
|
@@ -25,7 +25,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
25
25
|
|
|
26
26
|
var getLayoutSerieAttributes = exports.getLayoutSerieAttributes = function getLayoutSerieAttributes(layoutSerie, seriesAttributes) {
|
|
27
27
|
var length = R.length(layoutSerie);
|
|
28
|
-
if (length === 0
|
|
28
|
+
if (length === 0) {
|
|
29
29
|
return null;
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -89,18 +89,27 @@ var getCoordinates = function getCoordinates(data, unitsId) {
|
|
|
89
89
|
var getLayoutDataWithFlags = exports.getLayoutDataWithFlags = function getLayoutDataWithFlags(seriesAttributes, display, customAttributes, metadataCoordinates, unitsId) {
|
|
90
90
|
var regularAttrsIds = R.concat(customAttributes.flags || [], customAttributes.footnotes || []);
|
|
91
91
|
var formatSublayout = function formatSublayout(getAttributes) {
|
|
92
|
-
var
|
|
92
|
+
var mCoordinates = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
93
|
+
var supplData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
93
94
|
return function (data) {
|
|
94
95
|
var attributes = getAttributes(data);
|
|
95
96
|
var key = getSerieKey(data);
|
|
96
97
|
var cells = getSublayoutDataCells(display, customAttributes)(data);
|
|
97
98
|
var flags = getFlagsFromSeriesAttributes(display, customAttributes)(attributes);
|
|
98
99
|
var coordinates = getCoordinates(R.concat(supplData, data), unitsId);
|
|
99
|
-
var hasMetadata = (0, _hasCellMetadata.hasCellMetadata)(
|
|
100
|
+
var hasMetadata = (0, _hasCellMetadata.hasCellMetadata)(mCoordinates, coordinates);
|
|
101
|
+
var dataAdvancedAttrs = R.reduce(function (acc, _ref) {
|
|
102
|
+
var dimension = _ref.dimension,
|
|
103
|
+
value = _ref.value;
|
|
104
|
+
|
|
105
|
+
var attrs = (0, _extends3.default)({}, dimension.attributes || {}, value.attributes || {});
|
|
106
|
+
var advAttrs = R.omit(regularAttrsIds, attrs);
|
|
107
|
+
return (0, _extends3.default)({}, acc, advAttrs);
|
|
108
|
+
}, {}, data);
|
|
100
109
|
var advancedAttributesSeries = R.isNil(attributes) ? {} : R.filter(function (serie) {
|
|
101
110
|
return !R.isEmpty(R.omit(regularAttrsIds, R.propOr({}, 'attributes', serie)));
|
|
102
111
|
}, attributes);
|
|
103
|
-
var hasAdvancedAttributes = !R.isEmpty(advancedAttributesSeries);
|
|
112
|
+
var hasAdvancedAttributes = !R.isEmpty(advancedAttributesSeries) || !R.isEmpty(dataAdvancedAttrs);
|
|
104
113
|
var sideProps = hasMetadata || hasAdvancedAttributes ? { hasAdvancedAttributes: hasAdvancedAttributes, hasMetadata: hasMetadata, coordinates: coordinates } : null;
|
|
105
114
|
|
|
106
115
|
return { data: cells, key: key, flags: flags, sideProps: sideProps };
|
|
@@ -110,15 +119,15 @@ var getLayoutDataWithFlags = exports.getLayoutDataWithFlags = function getLayout
|
|
|
110
119
|
return R.evolve({
|
|
111
120
|
headerData: R.map(formatSublayout(function (data) {
|
|
112
121
|
return getLayoutSerieAttributes(data, seriesAttributes);
|
|
113
|
-
})),
|
|
122
|
+
}, metadataCoordinates.header)),
|
|
114
123
|
sectionsData: R.map(function (sectionData) {
|
|
115
124
|
var sectionSerie = R.head(sectionData);
|
|
116
125
|
var sectionAttributes = getLayoutSerieAttributes(sectionSerie, seriesAttributes);
|
|
117
126
|
return [formatSublayout(function () {
|
|
118
127
|
return sectionAttributes;
|
|
119
|
-
})(sectionSerie), R.map(formatSublayout(function (rowData) {
|
|
128
|
+
}, metadataCoordinates.sections)(sectionSerie), R.map(formatSublayout(function (rowData) {
|
|
120
129
|
return getLayoutSerieAttributes(R.concat(sectionSerie, rowData), R.omit(R.keys(sectionAttributes), seriesAttributes));
|
|
121
|
-
}, sectionSerie))(R.last(sectionData))];
|
|
130
|
+
}, metadataCoordinates.rows, sectionSerie))(R.last(sectionData))];
|
|
122
131
|
})
|
|
123
132
|
});
|
|
124
133
|
};
|
|
@@ -96,7 +96,7 @@ var getTableProps = exports.getTableProps = function getTableProps(_ref) {
|
|
|
96
96
|
display: display, unitDimension: unitDimension, unitsDisplay: unitsLevelDisplay, unitsSeries: unitsSeries,
|
|
97
97
|
unitsDefinitionCodes: unitsDefinitionCodes, unitsIndexes: unitsAttachmentIndexesInLayout,
|
|
98
98
|
partialUnitSerieIndexes: partialUnitSerieIndexes, rejectedValueIds: rejectedValueIds, layoutIds: layoutIds
|
|
99
|
-
}), (0, _getLayoutWithFlags.getLayoutDataWithFlags)(seriesAttributesValues, display, customAttributes, refinedMetadataCoordinates
|
|
99
|
+
}), (0, _getLayoutWithFlags.getLayoutDataWithFlags)(seriesAttributesValues, display, customAttributes, refinedMetadataCoordinates, unitDimension.id), (0, _cleanUnitsInLayoutData.cleanUnitsInLayoutData)({ unitsDisplay: unitsLevelDisplay, unitsLayoutIndexes: unitsIndexesInLayout }))(layout, R.propOr({}, 'observations', data));
|
|
100
100
|
|
|
101
101
|
return (0, _extends3.default)({
|
|
102
102
|
cells: (0, _getCuratedCells.getCuratedCells)({ layout: layout, observations: cells, shape: ['header', 'sections', 'rows'] }),
|
|
@@ -112,13 +112,18 @@ var prepareData = exports.prepareData = function prepareData(sdmxJson, customAtt
|
|
|
112
112
|
|
|
113
113
|
var seriesAttributesIds = R.propOr([], 'series', attributesIdsIndexedByTargets);
|
|
114
114
|
var observationsAttributesIds = R.propOr([], 'observations', attributesIdsIndexedByTargets);
|
|
115
|
+
var obsUnitsIds = R.pipe(function (_ref) {
|
|
116
|
+
var attributes = _ref.attributes,
|
|
117
|
+
dimensions = _ref.dimensions;
|
|
118
|
+
return R.merge(attributes.series || {}, dimensions.series || {});
|
|
119
|
+
}, R.values, R.pluck('id'))(unitsArtefacts);
|
|
115
120
|
var options = {
|
|
116
121
|
attachmentSeriesIndexes: attachmentSeriesIndexes,
|
|
117
122
|
customAttributes: customAttributes,
|
|
118
123
|
noDisplayIndexes: noDisplayIndexes,
|
|
119
124
|
notDisplayedCodes: notDisplayedCodes,
|
|
120
125
|
attributesIds: R.concat(seriesAttributesIds, observationsAttributesIds),
|
|
121
|
-
unitsIds:
|
|
126
|
+
unitsIds: obsUnitsIds
|
|
122
127
|
};
|
|
123
128
|
|
|
124
129
|
var _observations = (0, _getObservations.getObservations)(sdmxJson);
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
var
|
|
7
|
-
var
|
|
6
|
+
var SDMX_3_0_JSON_DATA_FORMAT = exports.SDMX_3_0_JSON_DATA_FORMAT = 'application/vnd.sdmx.data+json;version=2.0';
|
|
7
|
+
var SDMX_3_0_CSV_DATA_FORMAT = exports.SDMX_3_0_CSV_DATA_FORMAT = 'application/vnd.sdmx.data+csv;version=2.0';
|
package/lib/rules2/src/index.js
CHANGED
|
@@ -6,10 +6,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
|
|
7
7
|
var _constants = require('./constants');
|
|
8
8
|
|
|
9
|
-
Object.defineProperty(exports, '
|
|
9
|
+
Object.defineProperty(exports, 'SDMX_3_0_JSON_DATA_FORMAT', {
|
|
10
10
|
enumerable: true,
|
|
11
11
|
get: function get() {
|
|
12
|
-
return _constants.
|
|
12
|
+
return _constants.SDMX_3_0_JSON_DATA_FORMAT;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, 'SDMX_3_0_CSV_DATA_FORMAT', {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function get() {
|
|
18
|
+
return _constants.SDMX_3_0_CSV_DATA_FORMAT;
|
|
13
19
|
}
|
|
14
20
|
});
|
|
15
21
|
|
|
@@ -31,11 +37,11 @@ Object.defineProperty(exports, 'parseMetadataSeries', {
|
|
|
31
37
|
}
|
|
32
38
|
});
|
|
33
39
|
|
|
34
|
-
var
|
|
40
|
+
var _sdmx = require('./sdmx3.0DataFormatPatch');
|
|
35
41
|
|
|
36
|
-
Object.defineProperty(exports, '
|
|
42
|
+
Object.defineProperty(exports, 'sdmx_3_0_DataFormatPatch', {
|
|
37
43
|
enumerable: true,
|
|
38
44
|
get: function get() {
|
|
39
|
-
return
|
|
45
|
+
return _sdmx.sdmx_3_0_DataFormatPatch;
|
|
40
46
|
}
|
|
41
47
|
});
|
|
@@ -19,16 +19,16 @@ var refineMetadataCoordinates = exports.refineMetadataCoordinates = function ref
|
|
|
19
19
|
}
|
|
20
20
|
var removedHeaderCodes = R.omit(layoutIds.header, refinedCoord);
|
|
21
21
|
if (R.isEmpty(removedHeaderCodes)) {
|
|
22
|
-
return R.over(R.lensProp('
|
|
22
|
+
return R.over(R.lensProp('header'), R.append(refinedCoord))(acc);
|
|
23
23
|
}
|
|
24
24
|
var removedSectionCodes = R.omit(layoutIds.sections, refinedCoord);
|
|
25
25
|
if (R.isEmpty(removedSectionCodes)) {
|
|
26
|
-
return R.over(R.lensProp('
|
|
26
|
+
return R.over(R.lensProp('sections'), R.append(refinedCoord))(acc);
|
|
27
27
|
}
|
|
28
28
|
var removedRowsCodes = R.omit(layoutIds.rows, removedSectionCodes);
|
|
29
29
|
if (R.isEmpty(removedRowsCodes)) {
|
|
30
|
-
return R.over(R.lensProp('
|
|
30
|
+
return R.over(R.lensProp('rows'), R.append(refinedCoord))(acc);
|
|
31
31
|
}
|
|
32
32
|
return R.over(R.lensProp('cells'), R.append(refinedCoord))(acc);
|
|
33
|
-
}, { cells: [],
|
|
33
|
+
}, { cells: [], header: [], sections: [], rows: [] }, metadataCoordinates);
|
|
34
34
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.sdmx_3_0_DataFormatPatch = undefined;
|
|
7
7
|
|
|
8
8
|
var _ramda = require('ramda');
|
|
9
9
|
|
|
@@ -11,7 +11,7 @@ var R = _interopRequireWildcard(_ramda);
|
|
|
11
11
|
|
|
12
12
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var sdmx_3_0_DataFormatPatch = exports.sdmx_3_0_DataFormatPatch = function sdmx_3_0_DataFormatPatch(sdmxJson) {
|
|
15
15
|
var dataSet = R.pipe(R.pathOr({}, ['data', 'dataSets']), R.head)(sdmxJson);
|
|
16
16
|
var structureIndex = R.prop('structure', dataSet);
|
|
17
17
|
var structure = R.pipe(R.pathOr([], ['data', 'structures']), R.nth(structureIndex))(sdmxJson);
|
package/lib/viewer/src/chart.js
CHANGED
|
@@ -4,6 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
+
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
|
|
8
|
+
|
|
9
|
+
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
|
|
10
|
+
|
|
7
11
|
var _react = require('react');
|
|
8
12
|
|
|
9
13
|
var _react2 = _interopRequireDefault(_react);
|
|
@@ -14,9 +18,11 @@ var _ramda = require('ramda');
|
|
|
14
18
|
|
|
15
19
|
var R = _interopRequireWildcard(_ramda);
|
|
16
20
|
|
|
17
|
-
var
|
|
21
|
+
var _classnames = require('classnames');
|
|
22
|
+
|
|
23
|
+
var _classnames2 = _interopRequireDefault(_classnames);
|
|
18
24
|
|
|
19
|
-
var
|
|
25
|
+
var _styles = require('@material-ui/core/styles');
|
|
20
26
|
|
|
21
27
|
var _dotstatsuiteVisions = require('@sis-cc/dotstatsuite-visions');
|
|
22
28
|
|
|
@@ -40,46 +46,47 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
40
46
|
|
|
41
47
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
42
48
|
|
|
43
|
-
var
|
|
44
|
-
backgroundColor: 'none',
|
|
45
|
-
overflow: 'hidden',
|
|
46
|
-
position: 'relative',
|
|
47
|
-
direction: 'ltr !important'
|
|
48
|
-
}, function (_ref) {
|
|
49
|
-
var type = _ref.type;
|
|
50
|
-
|
|
51
|
-
if (!R.equals(_constants.SCATTER, type)) return {};
|
|
49
|
+
var useStyles = (0, _styles.makeStyles)(function () {
|
|
52
50
|
return {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
container: {
|
|
52
|
+
backgroundColor: 'none',
|
|
53
|
+
overflow: 'hidden',
|
|
54
|
+
position: 'relative',
|
|
55
|
+
direction: 'ltr !important'
|
|
58
56
|
},
|
|
59
|
-
|
|
60
|
-
'& .
|
|
57
|
+
chartContainer: {
|
|
58
|
+
'& .rcw-chart__chart__line--x:last-of-type': {
|
|
61
59
|
visibility: 'hidden'
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
'& .rcw-chart__chart__axis--y': {
|
|
65
|
-
'& .tick:last-of-type': {
|
|
60
|
+
},
|
|
61
|
+
'& .rcw-chart__chart__line--y:last-of-type': {
|
|
66
62
|
visibility: 'hidden'
|
|
63
|
+
},
|
|
64
|
+
'& .rcw-chart__chart__axis--x': {
|
|
65
|
+
'& .tick:last-of-type': {
|
|
66
|
+
visibility: 'hidden'
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
'& .rcw-chart__chart__axis--y': {
|
|
70
|
+
'& .tick:last-of-type': {
|
|
71
|
+
visibility: 'hidden'
|
|
72
|
+
}
|
|
67
73
|
}
|
|
68
74
|
}
|
|
69
75
|
};
|
|
70
76
|
});
|
|
71
77
|
|
|
72
|
-
var Chart = function Chart(
|
|
73
|
-
var options =
|
|
74
|
-
series =
|
|
75
|
-
type =
|
|
76
|
-
width =
|
|
77
|
-
getAxisOptions =
|
|
78
|
+
var Chart = function Chart(_ref) {
|
|
79
|
+
var options = _ref.options,
|
|
80
|
+
series = _ref.series,
|
|
81
|
+
type = _ref.type,
|
|
82
|
+
width = _ref.width,
|
|
83
|
+
getAxisOptions = _ref.getAxisOptions;
|
|
78
84
|
|
|
85
|
+
var classes = useStyles();
|
|
79
86
|
var ChartClass = charts[type];
|
|
80
87
|
return _react2.default.createElement(
|
|
81
|
-
|
|
82
|
-
{
|
|
88
|
+
'div',
|
|
89
|
+
{ className: (0, _classnames2.default)((0, _defineProperty3.default)({}, classes.chartContainer, !R.equals(_constants.SCATTER, type))) },
|
|
83
90
|
_react2.default.createElement(ChartClass, {
|
|
84
91
|
data: series,
|
|
85
92
|
options: options,
|
|
@@ -89,9 +96,9 @@ var Chart = function Chart(_ref2) {
|
|
|
89
96
|
);
|
|
90
97
|
};
|
|
91
98
|
|
|
92
|
-
exports.default = (0, _recompose.compose)((0, _recompose.withProps)(function (
|
|
93
|
-
var heightOffsets =
|
|
94
|
-
options =
|
|
99
|
+
exports.default = (0, _recompose.compose)((0, _recompose.withProps)(function (_ref2) {
|
|
100
|
+
var heightOffsets = _ref2.heightOffsets,
|
|
101
|
+
options = _ref2.options;
|
|
95
102
|
return {
|
|
96
103
|
options: R.over( // adjust svg height regarding header and footer height
|
|
97
104
|
R.lensPath(['base', 'height']), R.pipe(function (h) {
|
|
@@ -99,10 +106,10 @@ exports.default = (0, _recompose.compose)((0, _recompose.withProps)(function (_r
|
|
|
99
106
|
}, R.when(R.gt(0), R.always(300))), // 2 = borders
|
|
100
107
|
options)
|
|
101
108
|
};
|
|
102
|
-
}), (0, _recompose.branch)(_utils.isChartNoData, (0, _recompose.renderComponent)(function (
|
|
103
|
-
var noData =
|
|
104
|
-
options =
|
|
105
|
-
fixedHeight =
|
|
109
|
+
}), (0, _recompose.branch)(_utils.isChartNoData, (0, _recompose.renderComponent)(function (_ref3) {
|
|
110
|
+
var noData = _ref3.noData,
|
|
111
|
+
options = _ref3.options,
|
|
112
|
+
fixedHeight = _ref3.fixedHeight;
|
|
106
113
|
|
|
107
114
|
if (R.isNil(fixedHeight)) {
|
|
108
115
|
return _react2.default.createElement(_dotstatsuiteVisions.NoData, { message: noData || 'No Data' });
|
|
@@ -114,10 +121,10 @@ exports.default = (0, _recompose.compose)((0, _recompose.withProps)(function (_r
|
|
|
114
121
|
{ style: style },
|
|
115
122
|
_react2.default.createElement(_dotstatsuiteVisions.NoData, { message: noData || 'No Data' })
|
|
116
123
|
);
|
|
117
|
-
})), (0, _recompose.withProps)(function (
|
|
118
|
-
var data =
|
|
119
|
-
options =
|
|
120
|
-
type =
|
|
124
|
+
})), (0, _recompose.withProps)(function (_ref4) {
|
|
125
|
+
var data = _ref4.data,
|
|
126
|
+
options = _ref4.options,
|
|
127
|
+
type = _ref4.type;
|
|
121
128
|
return {
|
|
122
129
|
series: (0, _series2.default)(data.series, type, options) // responsive rule only display highlighted data
|
|
123
130
|
};
|
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 _defineProperty2 = require('babel-runtime/helpers/defineProperty');
|
|
8
|
+
|
|
9
|
+
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
|
|
10
|
+
|
|
7
11
|
var _extends2 = require('babel-runtime/helpers/extends');
|
|
8
12
|
|
|
9
13
|
var _extends3 = _interopRequireDefault(_extends2);
|
|
@@ -20,6 +24,10 @@ var _ramda = require('ramda');
|
|
|
20
24
|
|
|
21
25
|
var R = _interopRequireWildcard(_ramda);
|
|
22
26
|
|
|
27
|
+
var _classnames = require('classnames');
|
|
28
|
+
|
|
29
|
+
var _classnames2 = _interopRequireDefault(_classnames);
|
|
30
|
+
|
|
23
31
|
var _recompose = require('recompose');
|
|
24
32
|
|
|
25
33
|
var _reactSizeme = require('react-sizeme');
|
|
@@ -28,10 +36,6 @@ var _reactSizeme2 = _interopRequireDefault(_reactSizeme);
|
|
|
28
36
|
|
|
29
37
|
var _dotstatsuiteVisions = require('@sis-cc/dotstatsuite-visions');
|
|
30
38
|
|
|
31
|
-
var _glamorous = require('glamorous');
|
|
32
|
-
|
|
33
|
-
var _glamorous2 = _interopRequireDefault(_glamorous);
|
|
34
|
-
|
|
35
39
|
var _styles = require('@material-ui/core/styles');
|
|
36
40
|
|
|
37
41
|
var _options = require('./chartUtils/options');
|
|
@@ -54,37 +58,45 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
54
58
|
|
|
55
59
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
56
60
|
|
|
57
|
-
var
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
61
|
+
var useStyles = (0, _styles.makeStyles)(function (theme) {
|
|
62
|
+
return {
|
|
63
|
+
container: {
|
|
64
|
+
borderColor: '#007bc7',
|
|
65
|
+
borderBottomWidth: 1,
|
|
66
|
+
borderLeftWidth: 0,
|
|
67
|
+
borderTopWidth: 1,
|
|
68
|
+
borderRightWidth: 0,
|
|
69
|
+
borderStyle: 'solid',
|
|
70
|
+
'& svg text::selection': {
|
|
71
|
+
background: 'none'
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
tableContainer: {
|
|
75
|
+
minWidth: '100%',
|
|
76
|
+
minHeight: '100%'
|
|
77
|
+
},
|
|
78
|
+
chartContainer: {
|
|
79
|
+
width: function width(_ref) {
|
|
80
|
+
var fixedWidth = _ref.fixedWidth;
|
|
81
|
+
return fixedWidth || '100%';
|
|
82
|
+
},
|
|
83
|
+
height: function height(_ref2) {
|
|
84
|
+
var fixedHeight = _ref2.fixedHeight;
|
|
85
|
+
return fixedHeight || '100%';
|
|
86
|
+
},
|
|
87
|
+
overflow: 'hidden'
|
|
88
|
+
}
|
|
89
|
+
};
|
|
78
90
|
});
|
|
79
91
|
|
|
80
|
-
var ViewContent = function ViewContent(
|
|
81
|
-
var loading =
|
|
82
|
-
|
|
83
|
-
noData =
|
|
84
|
-
type =
|
|
85
|
-
width =
|
|
86
|
-
errorMessage =
|
|
87
|
-
rest = (0, _objectWithoutProperties3.default)(
|
|
92
|
+
var ViewContent = function ViewContent(_ref3) {
|
|
93
|
+
var loading = _ref3.loading,
|
|
94
|
+
_ref3$noData = _ref3.noData,
|
|
95
|
+
noData = _ref3$noData === undefined ? 'No Data' : _ref3$noData,
|
|
96
|
+
type = _ref3.type,
|
|
97
|
+
width = _ref3.width,
|
|
98
|
+
errorMessage = _ref3.errorMessage,
|
|
99
|
+
rest = (0, _objectWithoutProperties3.default)(_ref3, ['loading', 'noData', 'type', 'width', 'errorMessage']);
|
|
88
100
|
|
|
89
101
|
if (loading) return _react2.default.createElement(_dotstatsuiteVisions.Loading, { message: loading });
|
|
90
102
|
if (!width) return _react2.default.createElement(_dotstatsuiteVisions.Loading, { message: loading });
|
|
@@ -109,14 +121,20 @@ var ViewContent = function ViewContent(_ref2) {
|
|
|
109
121
|
});
|
|
110
122
|
};
|
|
111
123
|
|
|
112
|
-
var Viewer = function Viewer(
|
|
113
|
-
var
|
|
114
|
-
setFooterOffset = _ref3.setFooterOffset,
|
|
115
|
-
setHeaderOffset = _ref3.setHeaderOffset,
|
|
116
|
-
size = _ref3.size,
|
|
117
|
-
type = _ref3.type,
|
|
118
|
-
rest = (0, _objectWithoutProperties3.default)(_ref3, ['getResponsiveSize', 'setFooterOffset', 'setHeaderOffset', 'size', 'type']);
|
|
124
|
+
var Viewer = function Viewer(_ref4) {
|
|
125
|
+
var _cx;
|
|
119
126
|
|
|
127
|
+
var getResponsiveSize = _ref4.getResponsiveSize,
|
|
128
|
+
setFooterOffset = _ref4.setFooterOffset,
|
|
129
|
+
setHeaderOffset = _ref4.setHeaderOffset,
|
|
130
|
+
size = _ref4.size,
|
|
131
|
+
type = _ref4.type,
|
|
132
|
+
rest = (0, _objectWithoutProperties3.default)(_ref4, ['getResponsiveSize', 'setFooterOffset', 'setHeaderOffset', 'size', 'type']);
|
|
133
|
+
|
|
134
|
+
var classes = useStyles({
|
|
135
|
+
fixedWidth: rest.fixedWidth,
|
|
136
|
+
fixedHeight: rest.fixedHeight
|
|
137
|
+
});
|
|
120
138
|
(0, _react.useEffect)(function () {
|
|
121
139
|
if (R.is(Function, getResponsiveSize)) {
|
|
122
140
|
getResponsiveSize({
|
|
@@ -127,8 +145,10 @@ var Viewer = function Viewer(_ref3) {
|
|
|
127
145
|
});
|
|
128
146
|
|
|
129
147
|
return _react2.default.createElement(
|
|
130
|
-
|
|
131
|
-
|
|
148
|
+
'div',
|
|
149
|
+
{
|
|
150
|
+
className: (0, _classnames2.default)(classes.container, (_cx = {}, (0, _defineProperty3.default)(_cx, classes.tableContainer, type === 'table'), (0, _defineProperty3.default)(_cx, classes.chartContainer, type !== 'table'), _cx))
|
|
151
|
+
},
|
|
132
152
|
_react2.default.createElement(_header2.default, (0, _extends3.default)({
|
|
133
153
|
onSize: function onSize(size) {
|
|
134
154
|
return setHeaderOffset(size.height);
|
|
@@ -146,9 +166,9 @@ var Viewer = function Viewer(_ref3) {
|
|
|
146
166
|
);
|
|
147
167
|
};
|
|
148
168
|
|
|
149
|
-
exports.default = (0, _recompose.compose)((0, _reactSizeme2.default)({ noPlaceholder: true, monitorWidth: true, monitorHeight: true }), (0, _recompose.withState)('heightOffsets', 'setHeightOffsets', { footer: undefined, header: undefined }), (0, _recompose.withProps)(function (
|
|
150
|
-
var heightOffsets =
|
|
151
|
-
setHeightOffsets =
|
|
169
|
+
exports.default = (0, _recompose.compose)((0, _reactSizeme2.default)({ noPlaceholder: true, monitorWidth: true, monitorHeight: true }), (0, _recompose.withState)('heightOffsets', 'setHeightOffsets', { footer: undefined, header: undefined }), (0, _recompose.withProps)(function (_ref5) {
|
|
170
|
+
var heightOffsets = _ref5.heightOffsets,
|
|
171
|
+
setHeightOffsets = _ref5.setHeightOffsets;
|
|
152
172
|
return {
|
|
153
173
|
heightOffsets: R.evolve({
|
|
154
174
|
footer: R.when(R.isNil, R.always(0)),
|
|
@@ -162,11 +182,11 @@ exports.default = (0, _recompose.compose)((0, _reactSizeme2.default)({ noPlaceho
|
|
|
162
182
|
}
|
|
163
183
|
};
|
|
164
184
|
}), (0, _recompose.withProps)( // inject responsive size if needed for chart
|
|
165
|
-
function (
|
|
166
|
-
var chartOptions =
|
|
167
|
-
heightOffsets =
|
|
168
|
-
size =
|
|
169
|
-
type =
|
|
185
|
+
function (_ref6) {
|
|
186
|
+
var chartOptions = _ref6.chartOptions,
|
|
187
|
+
heightOffsets = _ref6.heightOffsets,
|
|
188
|
+
size = _ref6.size,
|
|
189
|
+
type = _ref6.type;
|
|
170
190
|
|
|
171
191
|
if (type === 'table') {
|
|
172
192
|
return {};
|
|
@@ -178,12 +198,12 @@ function (_ref5) {
|
|
|
178
198
|
fixedHeight: R.path(['base', 'height'], chartOptions)
|
|
179
199
|
};
|
|
180
200
|
}), (0, _recompose.withProps)( // compute all chart options regarding oecd design
|
|
181
|
-
function (
|
|
182
|
-
var chartData =
|
|
183
|
-
chartOptions =
|
|
184
|
-
timeFormats =
|
|
185
|
-
type =
|
|
186
|
-
locale =
|
|
201
|
+
function (_ref7) {
|
|
202
|
+
var chartData = _ref7.chartData,
|
|
203
|
+
chartOptions = _ref7.chartOptions,
|
|
204
|
+
timeFormats = _ref7.timeFormats,
|
|
205
|
+
type = _ref7.type,
|
|
206
|
+
locale = _ref7.locale;
|
|
187
207
|
|
|
188
208
|
if (type === 'table') {
|
|
189
209
|
return {};
|
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": "
|
|
4
|
+
"version": "12.1.1",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"author": "OECD",
|
|
7
7
|
"license": "MIT",
|
|
@@ -24,24 +24,19 @@
|
|
|
24
24
|
"@react-hook/size": "^2.1.1",
|
|
25
25
|
"@sis-cc/dotstatsuite-d3-charts": "^8.0.0",
|
|
26
26
|
"date-fns": "^1.30.1",
|
|
27
|
-
"glamor": "^2.20.40",
|
|
28
|
-
"glamorous": "^4.13.1",
|
|
29
27
|
"lodash": "^4.17.2",
|
|
30
28
|
"lodash.compose": "^2.4.1",
|
|
31
29
|
"memoizee": "^0.4.4",
|
|
32
30
|
"numeral": "^2.0.6",
|
|
33
31
|
"prop-types": "^15.6.2",
|
|
34
|
-
"query-string": "^4.3.2",
|
|
35
32
|
"ramda": "^0.26.1",
|
|
36
|
-
"react-addons-css-transition-group": "^15.6.2",
|
|
37
33
|
"react-dom": "^16.5.2",
|
|
38
|
-
"react-select": "^1.2.1",
|
|
39
34
|
"react-sizeme": "^2.3.6",
|
|
40
35
|
"recompose": "^0.30.0"
|
|
41
36
|
},
|
|
42
37
|
"peerDependencies": {
|
|
43
38
|
"@material-ui/core": "^4.x",
|
|
44
|
-
"@sis-cc/dotstatsuite-visions": "^
|
|
39
|
+
"@sis-cc/dotstatsuite-visions": "^7.x",
|
|
45
40
|
"@sis-cc/dotstatsuite-sdmxjs": "^5.x",
|
|
46
41
|
"react": "16.x"
|
|
47
42
|
}
|
|
@@ -5,7 +5,7 @@ import { hasCellMetadata } from '../../../../rules2/src/hasCellMetadata';
|
|
|
5
5
|
|
|
6
6
|
export const getLayoutSerieAttributes = (layoutSerie, seriesAttributes) => {
|
|
7
7
|
const length = R.length(layoutSerie);
|
|
8
|
-
if (length === 0
|
|
8
|
+
if (length === 0) {
|
|
9
9
|
return null;
|
|
10
10
|
}
|
|
11
11
|
|
|
@@ -88,36 +88,47 @@ const getCoordinates = (data, unitsId) => R.reduce(
|
|
|
88
88
|
|
|
89
89
|
export const getLayoutDataWithFlags = (seriesAttributes, display, customAttributes, metadataCoordinates, unitsId) => {
|
|
90
90
|
const regularAttrsIds = R.concat(customAttributes.flags || [], customAttributes.footnotes || []);
|
|
91
|
-
const formatSublayout = (getAttributes, supplData = []) => data => {
|
|
91
|
+
const formatSublayout = (getAttributes, mCoordinates = [], supplData = []) => data => {
|
|
92
92
|
const attributes = getAttributes(data);
|
|
93
93
|
const key = getSerieKey(data);
|
|
94
94
|
const cells = getSublayoutDataCells(display, customAttributes)(data);
|
|
95
95
|
const flags = getFlagsFromSeriesAttributes(display, customAttributes)(attributes);
|
|
96
96
|
const coordinates = getCoordinates(R.concat(supplData, data), unitsId);
|
|
97
|
-
const hasMetadata = hasCellMetadata(
|
|
97
|
+
const hasMetadata = hasCellMetadata(mCoordinates, coordinates);
|
|
98
|
+
const dataAdvancedAttrs = R.reduce(
|
|
99
|
+
(acc, { dimension, value }) => {
|
|
100
|
+
const attrs = { ...dimension.attributes || {}, ...value.attributes || {}};
|
|
101
|
+
const advAttrs = R.omit(regularAttrsIds, attrs);
|
|
102
|
+
return ({ ...acc, ...advAttrs })
|
|
103
|
+
},
|
|
104
|
+
{},
|
|
105
|
+
data
|
|
106
|
+
);
|
|
98
107
|
const advancedAttributesSeries = R.isNil(attributes)
|
|
99
108
|
? {}
|
|
100
109
|
: R.filter(
|
|
101
110
|
serie => !R.isEmpty(R.omit(regularAttrsIds, R.propOr({}, 'attributes', serie))),
|
|
102
111
|
attributes
|
|
103
112
|
);
|
|
104
|
-
const hasAdvancedAttributes = !R.isEmpty(advancedAttributesSeries);
|
|
113
|
+
const hasAdvancedAttributes = !R.isEmpty(advancedAttributesSeries) || !R.isEmpty(dataAdvancedAttrs);
|
|
105
114
|
const sideProps = hasMetadata || hasAdvancedAttributes ? { hasAdvancedAttributes, hasMetadata, coordinates } : null;
|
|
106
115
|
|
|
107
116
|
return ({ data: cells, key, flags, sideProps });
|
|
108
117
|
};
|
|
109
118
|
|
|
110
119
|
return R.evolve({
|
|
111
|
-
headerData: R.map(formatSublayout(data => getLayoutSerieAttributes(data, seriesAttributes))),
|
|
120
|
+
headerData: R.map(formatSublayout(data => getLayoutSerieAttributes(data, seriesAttributes), metadataCoordinates.header)),
|
|
112
121
|
sectionsData: R.map(
|
|
113
122
|
sectionData => {
|
|
114
123
|
const sectionSerie = R.head(sectionData);
|
|
115
124
|
const sectionAttributes = getLayoutSerieAttributes(sectionSerie, seriesAttributes);
|
|
116
125
|
return ([
|
|
117
|
-
formatSublayout(() => sectionAttributes)(sectionSerie),
|
|
126
|
+
formatSublayout(() => sectionAttributes, metadataCoordinates.sections)(sectionSerie),
|
|
118
127
|
R.map(
|
|
119
|
-
formatSublayout(
|
|
120
|
-
|
|
128
|
+
formatSublayout(
|
|
129
|
+
rowData => getLayoutSerieAttributes(R.concat(sectionSerie, rowData), R.omit(R.keys(sectionAttributes), seriesAttributes)),
|
|
130
|
+
metadataCoordinates.rows,
|
|
131
|
+
sectionSerie)
|
|
121
132
|
)(R.last(sectionData))
|
|
122
133
|
]);
|
|
123
134
|
}
|
|
@@ -97,7 +97,7 @@ export const getTableProps = ({ data, layoutIds, display, customAttributes, limi
|
|
|
97
97
|
unitsDefinitionCodes, unitsIndexes: unitsAttachmentIndexesInLayout,
|
|
98
98
|
partialUnitSerieIndexes, rejectedValueIds, layoutIds
|
|
99
99
|
}),
|
|
100
|
-
getLayoutDataWithFlags(seriesAttributesValues, display, customAttributes, refinedMetadataCoordinates
|
|
100
|
+
getLayoutDataWithFlags(seriesAttributesValues, display, customAttributes, refinedMetadataCoordinates, unitDimension.id),
|
|
101
101
|
cleanUnitsInLayoutData({ unitsDisplay: unitsLevelDisplay, unitsLayoutIndexes: unitsIndexesInLayout }),
|
|
102
102
|
)(layout, R.propOr({}, 'observations', data));
|
|
103
103
|
|
|
@@ -79,13 +79,18 @@ export const prepareData = (sdmxJson, customAttributes, unitsProps={}) => {
|
|
|
79
79
|
|
|
80
80
|
const seriesAttributesIds = R.propOr([], 'series', attributesIdsIndexedByTargets);
|
|
81
81
|
const observationsAttributesIds = R.propOr([], 'observations', attributesIdsIndexedByTargets);
|
|
82
|
+
const obsUnitsIds = R.pipe(
|
|
83
|
+
({ attributes, dimensions }) => R.merge(attributes.series || {}, dimensions.series || {}),
|
|
84
|
+
R.values,
|
|
85
|
+
R.pluck('id')
|
|
86
|
+
)(unitsArtefacts);
|
|
82
87
|
const options = {
|
|
83
88
|
attachmentSeriesIndexes,
|
|
84
89
|
customAttributes,
|
|
85
90
|
noDisplayIndexes,
|
|
86
91
|
notDisplayedCodes,
|
|
87
92
|
attributesIds: R.concat(seriesAttributesIds, observationsAttributesIds),
|
|
88
|
-
unitsIds:
|
|
93
|
+
unitsIds: obsUnitsIds
|
|
89
94
|
};
|
|
90
95
|
|
|
91
96
|
const _observations = getObservations(sdmxJson);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const
|
|
2
|
-
export const
|
|
1
|
+
export const SDMX_3_0_JSON_DATA_FORMAT = 'application/vnd.sdmx.data+json;version=2.0';
|
|
2
|
+
export const SDMX_3_0_CSV_DATA_FORMAT = 'application/vnd.sdmx.data+csv;version=2.0';
|
package/src/rules2/src/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {
|
|
2
|
+
SDMX_3_0_JSON_DATA_FORMAT,
|
|
3
|
+
SDMX_3_0_CSV_DATA_FORMAT
|
|
4
|
+
} from './constants';
|
|
2
5
|
|
|
3
6
|
export { getSidebarData } from './getSidebarData';
|
|
4
7
|
export { parseMetadataSeries } from './parseMetadataSeries';
|
|
5
|
-
export {
|
|
8
|
+
export { sdmx_3_0_DataFormatPatch } from './sdmx3.0DataFormatPatch';
|
|
@@ -9,19 +9,19 @@ export const refineMetadataCoordinates = (metadataCoordinates, layoutIds, header
|
|
|
9
9
|
}
|
|
10
10
|
const removedHeaderCodes = R.omit(layoutIds.header, refinedCoord);
|
|
11
11
|
if (R.isEmpty(removedHeaderCodes)) {
|
|
12
|
-
return R.over(R.lensProp('
|
|
12
|
+
return R.over(R.lensProp('header'), R.append(refinedCoord))(acc);
|
|
13
13
|
}
|
|
14
14
|
const removedSectionCodes = R.omit(layoutIds.sections, refinedCoord);
|
|
15
15
|
if (R.isEmpty(removedSectionCodes)) {
|
|
16
|
-
return R.over(R.lensProp('
|
|
16
|
+
return R.over(R.lensProp('sections'), R.append(refinedCoord))(acc);
|
|
17
17
|
}
|
|
18
18
|
const removedRowsCodes = R.omit(layoutIds.rows, removedSectionCodes);
|
|
19
19
|
if (R.isEmpty(removedRowsCodes)) {
|
|
20
|
-
return R.over(R.lensProp('
|
|
20
|
+
return R.over(R.lensProp('rows'), R.append(refinedCoord))(acc);
|
|
21
21
|
}
|
|
22
22
|
return R.over(R.lensProp('cells'), R.append(refinedCoord))(acc);
|
|
23
23
|
},
|
|
24
|
-
{ cells: [],
|
|
24
|
+
{ cells: [], header: [], sections: [], rows: [] },
|
|
25
25
|
metadataCoordinates
|
|
26
26
|
);
|
|
27
27
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const sdmx_3_0_DataFormatPatch = (sdmxJson) => {
|
|
4
4
|
const dataSet = R.pipe(R.pathOr({}, ['data', 'dataSets']), R.head)(sdmxJson);
|
|
5
5
|
const structureIndex = R.prop('structure', dataSet);
|
|
6
6
|
const structure = R.pipe(R.pathOr([], ['data', 'structures']), R.nth(structureIndex))(sdmxJson);
|
package/src/viewer/src/chart.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { branch, compose, renderComponent, withProps } from 'recompose';
|
|
3
3
|
import * as R from 'ramda';
|
|
4
|
-
import
|
|
4
|
+
import cx from 'classnames';
|
|
5
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
5
6
|
import { NoData } from '@sis-cc/dotstatsuite-visions';
|
|
6
7
|
import * as charts from '../../bridge-d3-react/src';
|
|
7
8
|
import { SCATTER } from '../../rules/src/constants';
|
|
@@ -9,15 +10,14 @@ import filterSeriesRegardingDimensions from './chartUtils/series';
|
|
|
9
10
|
import AxisLegend from './legends/AxisLegend';
|
|
10
11
|
import { isChartNoData } from './utils';
|
|
11
12
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return ({
|
|
13
|
+
const useStyles = makeStyles(() => ({
|
|
14
|
+
container: {
|
|
15
|
+
backgroundColor: 'none',
|
|
16
|
+
overflow: 'hidden',
|
|
17
|
+
position: 'relative',
|
|
18
|
+
direction: 'ltr !important',
|
|
19
|
+
},
|
|
20
|
+
chartContainer: {
|
|
21
21
|
'& .rcw-chart__chart__line--x:last-of-type': {
|
|
22
22
|
visibility: 'hidden',
|
|
23
23
|
},
|
|
@@ -34,13 +34,14 @@ const Container = glamorous.div({
|
|
|
34
34
|
visibility: 'hidden',
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
}
|
|
38
|
-
});
|
|
37
|
+
}
|
|
38
|
+
}));
|
|
39
39
|
|
|
40
40
|
const Chart = ({ options, series, type, width, getAxisOptions }) => {
|
|
41
|
+
const classes = useStyles();
|
|
41
42
|
const ChartClass = charts[type];
|
|
42
43
|
return (
|
|
43
|
-
<
|
|
44
|
+
<div className={cx({ [classes.chartContainer]: !R.equals(SCATTER, type) })}>
|
|
44
45
|
<ChartClass
|
|
45
46
|
data={series}
|
|
46
47
|
options={options}
|
|
@@ -51,7 +52,7 @@ const Chart = ({ options, series, type, width, getAxisOptions }) => {
|
|
|
51
52
|
? null
|
|
52
53
|
: <AxisLegend axis="y" data={{ series }} type={type} />
|
|
53
54
|
}
|
|
54
|
-
</
|
|
55
|
+
</div>
|
|
55
56
|
);
|
|
56
57
|
};
|
|
57
58
|
|
package/src/viewer/src/index.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
import React, { useEffect } from 'react';
|
|
2
2
|
import * as R from 'ramda';
|
|
3
|
+
import cx from 'classnames';
|
|
3
4
|
import { compose, withState, withProps } from 'recompose';
|
|
4
5
|
import sizeMe from 'react-sizeme';
|
|
5
6
|
import { Loading, NoData, TableHtml5 } from '@sis-cc/dotstatsuite-visions';
|
|
6
|
-
import
|
|
7
|
-
import { useTheme } from '@material-ui/core/styles';
|
|
7
|
+
import { useTheme, makeStyles } from '@material-ui/core/styles';
|
|
8
8
|
import getChartOptions from './chartUtils/options';
|
|
9
9
|
import Header from './header';
|
|
10
10
|
import Chart from './chart';
|
|
11
11
|
import Footer from './footer';
|
|
12
12
|
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
);
|
|
13
|
+
const useStyles = makeStyles(theme => ({
|
|
14
|
+
container: {
|
|
15
|
+
borderColor: '#007bc7',
|
|
16
|
+
borderBottomWidth: 1,
|
|
17
|
+
borderLeftWidth: 0,
|
|
18
|
+
borderTopWidth: 1,
|
|
19
|
+
borderRightWidth: 0,
|
|
20
|
+
borderStyle: 'solid',
|
|
21
|
+
'& svg text::selection': {
|
|
22
|
+
background: 'none'
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
tableContainer: {
|
|
26
|
+
minWidth: '100%',
|
|
27
|
+
minHeight: '100%'
|
|
28
|
+
},
|
|
29
|
+
chartContainer: {
|
|
30
|
+
width: ({ fixedWidth }) => fixedWidth || '100%',
|
|
31
|
+
height: ({ fixedHeight }) => fixedHeight || '100%',
|
|
32
|
+
overflow: 'hidden'
|
|
33
|
+
}
|
|
34
|
+
}));
|
|
35
35
|
|
|
36
36
|
const ViewContent = ({ loading, noData = 'No Data', type, width, errorMessage, ...rest }) => {
|
|
37
37
|
if (loading) return <Loading message={loading} />;
|
|
@@ -60,6 +60,10 @@ const ViewContent = ({ loading, noData = 'No Data', type, width, errorMessage, .
|
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
const Viewer = ({ getResponsiveSize, setFooterOffset, setHeaderOffset, size, type, ...rest }) => {
|
|
63
|
+
const classes = useStyles({
|
|
64
|
+
fixedWidth: rest.fixedWidth,
|
|
65
|
+
fixedHeight: rest.fixedHeight
|
|
66
|
+
});
|
|
63
67
|
useEffect(() => {
|
|
64
68
|
if (R.is(Function, getResponsiveSize)) {
|
|
65
69
|
getResponsiveSize({
|
|
@@ -70,7 +74,12 @@ const Viewer = ({ getResponsiveSize, setFooterOffset, setHeaderOffset, size, typ
|
|
|
70
74
|
});
|
|
71
75
|
|
|
72
76
|
return (
|
|
73
|
-
<
|
|
77
|
+
<div
|
|
78
|
+
className={cx(classes.container, {
|
|
79
|
+
[classes.tableContainer]: type === 'table',
|
|
80
|
+
[classes.chartContainer]: type !== 'table'
|
|
81
|
+
})}
|
|
82
|
+
>
|
|
74
83
|
<Header
|
|
75
84
|
onSize={size => setHeaderOffset(size.height)}
|
|
76
85
|
{...R.propOr({}, 'headerProps', rest)}
|
|
@@ -83,7 +92,7 @@ const Viewer = ({ getResponsiveSize, setFooterOffset, setHeaderOffset, size, typ
|
|
|
83
92
|
chartOptions={R.prop('chartOptions', rest)}
|
|
84
93
|
{...R.prop('footerProps', rest)}
|
|
85
94
|
/>
|
|
86
|
-
</
|
|
95
|
+
</div>
|
|
87
96
|
);
|
|
88
97
|
};
|
|
89
98
|
|
|
@@ -134,9 +134,9 @@ const expected = {
|
|
|
134
134
|
|
|
135
135
|
describe('getLayoutDataWithFlags test', () => {
|
|
136
136
|
it('empty', () => {
|
|
137
|
-
expect(getLayoutDataWithFlags({}, 'label', {})({ headerData: [], sectionsData: [] })).to.deep.equal({ headerData: [], sectionsData: [] });
|
|
137
|
+
expect(getLayoutDataWithFlags({}, 'label', {}, {}, [])({ headerData: [], sectionsData: [] })).to.deep.equal({ headerData: [], sectionsData: [] });
|
|
138
138
|
});
|
|
139
139
|
it('multi cases', () => {
|
|
140
|
-
expect(getLayoutDataWithFlags(attributesValues, 'code', customAttributes,
|
|
140
|
+
expect(getLayoutDataWithFlags(attributesValues, 'code', customAttributes, {}, [])(layoutData)).to.deep.equal(expected);
|
|
141
141
|
});
|
|
142
142
|
});
|