@haniffalab/cherita-react 0.2.0-dev.2024-05-22.5ce64346 → 0.2.0-dev.2024-09-26.f9979478
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/App.scss +58 -24
- package/dist/components/Offcanvas/index.js +9 -6
- package/dist/components/dotplot/Dotplot.js +5 -189
- package/dist/components/dotplot/DotplotControls.js +197 -0
- package/dist/components/heatmap/Heatmap.js +5 -31
- package/dist/components/heatmap/HeatmapControls.js +36 -0
- package/dist/components/matrixplot/Matrixplot.js +5 -59
- package/dist/components/matrixplot/MatrixplotControls.js +65 -0
- package/dist/components/obs-list/ObsList.js +231 -113
- package/dist/components/obs-list/ObsValueList.js +101 -0
- package/dist/components/obsm-list/ObsmList.js +13 -20
- package/dist/components/scatterplot/Legend.js +28 -36
- package/dist/components/scatterplot/Scatterplot.js +302 -124
- package/dist/components/scatterplot/ScatterplotControls.js +93 -0
- package/dist/components/scatterplot/SpatialControls.js +68 -17
- package/dist/components/scatterplot/Toolbox.js +14 -18
- package/dist/components/search-bar/SearchBar.js +2 -2
- package/dist/components/search-bar/SearchResults.js +2 -2
- package/dist/components/var-list/VarList.js +51 -24
- package/dist/components/violin/Violin.js +7 -46
- package/dist/components/violin/ViolinControls.js +50 -0
- package/dist/constants/colorscales.js +28 -0
- package/dist/constants/constants.js +11 -43
- package/dist/context/DatasetContext.js +122 -23
- package/dist/helpers/color-helper.js +54 -21
- package/dist/helpers/zarr-helper.js +39 -17
- package/dist/index.js +17 -11
- package/dist/utils/LoadingIndicators.js +33 -0
- package/dist/utils/requests.js +1 -1
- package/dist/utils/search.js +4 -3
- package/package.json +10 -4
- package/dist/utils/LoadingSpinner.js +0 -44
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.HeatmapControls = HeatmapControls;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
|
+
var _reactBootstrap = require("react-bootstrap");
|
|
10
|
+
var _colorscales = require("../../constants/colorscales");
|
|
11
|
+
var _DatasetContext = require("../../context/DatasetContext");
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
function HeatmapControls() {
|
|
15
|
+
const dataset = (0, _DatasetContext.useDataset)();
|
|
16
|
+
const dispatch = (0, _DatasetContext.useDatasetDispatch)();
|
|
17
|
+
const colormapList = _lodash.default.keys(_colorscales.COLORSCALES).map(key => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Item, {
|
|
18
|
+
active: dataset.controls.colorScale === key,
|
|
19
|
+
onClick: () => {
|
|
20
|
+
dispatch({
|
|
21
|
+
type: "set.controls.colorScale",
|
|
22
|
+
colorScale: key
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
children: key
|
|
26
|
+
}, key));
|
|
27
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Dropdown, {
|
|
28
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Toggle, {
|
|
29
|
+
id: "dropdownColorscale",
|
|
30
|
+
variant: "light",
|
|
31
|
+
children: dataset.controls.colorScale
|
|
32
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Menu, {
|
|
33
|
+
children: colormapList
|
|
34
|
+
})]
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -4,70 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Matrixplot = Matrixplot;
|
|
7
|
-
exports.MatrixplotControls = MatrixplotControls;
|
|
8
|
-
require("bootstrap/dist/css/bootstrap.min.css");
|
|
9
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactBootstrap = require("react-bootstrap");
|
|
10
9
|
var _reactPlotly = _interopRequireDefault(require("react-plotly.js"));
|
|
11
10
|
var _DatasetContext = require("../../context/DatasetContext");
|
|
12
|
-
var
|
|
13
|
-
var _reactBootstrap = require("react-bootstrap");
|
|
11
|
+
var _LoadingIndicators = require("../../utils/LoadingIndicators");
|
|
14
12
|
var _requests = require("../../utils/requests");
|
|
15
|
-
var _LoadingSpinner = require("../../utils/LoadingSpinner");
|
|
16
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
-
function _interopRequireDefault(
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
19
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
20
|
-
function MatrixplotControls() {
|
|
21
|
-
const dataset = (0, _DatasetContext.useDataset)();
|
|
22
|
-
const dispatch = (0, _DatasetContext.useDatasetDispatch)();
|
|
23
|
-
const colorScaleList = _constants.PLOTLY_COLORSCALES.map(item => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Item, {
|
|
24
|
-
active: dataset.controls.colorScale === item,
|
|
25
|
-
onClick: () => {
|
|
26
|
-
dispatch({
|
|
27
|
-
type: "set.controls.colorScale",
|
|
28
|
-
colorScale: item
|
|
29
|
-
});
|
|
30
|
-
},
|
|
31
|
-
children: item
|
|
32
|
-
}, item));
|
|
33
|
-
const standardScaleList = _constants.MATRIXPLOT_STANDARDSCALES.map(item => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Item, {
|
|
34
|
-
active: dataset.controls.standardScale === item.name,
|
|
35
|
-
onClick: () => {
|
|
36
|
-
dispatch({
|
|
37
|
-
type: "set.controls.standardScale",
|
|
38
|
-
standardScale: item.value
|
|
39
|
-
});
|
|
40
|
-
},
|
|
41
|
-
children: item.name
|
|
42
|
-
}, item.value));
|
|
43
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.ButtonToolbar, {
|
|
44
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ButtonGroup, {
|
|
45
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Dropdown, {
|
|
46
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Toggle, {
|
|
47
|
-
id: "dropdownColorscale",
|
|
48
|
-
variant: "light",
|
|
49
|
-
children: dataset.controls.colorScale
|
|
50
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Menu, {
|
|
51
|
-
children: colorScaleList
|
|
52
|
-
})]
|
|
53
|
-
})
|
|
54
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ButtonGroup, {
|
|
55
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.InputGroup, {
|
|
56
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.InputGroup.Text, {
|
|
57
|
-
children: "Standard scale"
|
|
58
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Dropdown, {
|
|
59
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Toggle, {
|
|
60
|
-
id: "dropdownStandardScale",
|
|
61
|
-
variant: "light",
|
|
62
|
-
children: dataset.controls.standardScale
|
|
63
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Menu, {
|
|
64
|
-
children: standardScaleList
|
|
65
|
-
})]
|
|
66
|
-
})]
|
|
67
|
-
})
|
|
68
|
-
})]
|
|
69
|
-
});
|
|
70
|
-
}
|
|
16
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
71
17
|
function Matrixplot() {
|
|
72
18
|
const ENDPOINT = "matrixplot";
|
|
73
19
|
const dataset = (0, _DatasetContext.useDataset)();
|
|
@@ -132,7 +78,7 @@ function Matrixplot() {
|
|
|
132
78
|
if (hasSelections) {
|
|
133
79
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
134
80
|
className: "cherita-matrixplot position-relative",
|
|
135
|
-
children: [isPending && /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
81
|
+
children: [isPending && /*#__PURE__*/(0, _jsxRuntime.jsx)(_LoadingIndicators.LoadingSpinner, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactPlotly.default, {
|
|
136
82
|
data: data,
|
|
137
83
|
layout: layout,
|
|
138
84
|
useResizeHandler: true,
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MatrixplotControls = MatrixplotControls;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
|
+
var _reactBootstrap = require("react-bootstrap");
|
|
10
|
+
var _colorscales = require("../../constants/colorscales");
|
|
11
|
+
var _constants = require("../../constants/constants");
|
|
12
|
+
var _DatasetContext = require("../../context/DatasetContext");
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
function MatrixplotControls() {
|
|
16
|
+
const dataset = (0, _DatasetContext.useDataset)();
|
|
17
|
+
const dispatch = (0, _DatasetContext.useDatasetDispatch)();
|
|
18
|
+
const colorScaleList = _lodash.default.keys(_colorscales.COLORSCALES).map(key => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Item, {
|
|
19
|
+
active: dataset.controls.colorScale === key,
|
|
20
|
+
onClick: () => {
|
|
21
|
+
dispatch({
|
|
22
|
+
type: "set.controls.colorScale",
|
|
23
|
+
colorScale: key
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
children: key
|
|
27
|
+
}, key));
|
|
28
|
+
const standardScaleList = _constants.MATRIXPLOT_STANDARDSCALES.map(item => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Item, {
|
|
29
|
+
active: dataset.controls.standardScale === item.name,
|
|
30
|
+
onClick: () => {
|
|
31
|
+
dispatch({
|
|
32
|
+
type: "set.controls.standardScale",
|
|
33
|
+
standardScale: item.value
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
children: item.name
|
|
37
|
+
}, item.value));
|
|
38
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.ButtonToolbar, {
|
|
39
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ButtonGroup, {
|
|
40
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Dropdown, {
|
|
41
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Toggle, {
|
|
42
|
+
id: "dropdownColorscale",
|
|
43
|
+
variant: "light",
|
|
44
|
+
children: dataset.controls.colorScale
|
|
45
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Menu, {
|
|
46
|
+
children: colorScaleList
|
|
47
|
+
})]
|
|
48
|
+
})
|
|
49
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ButtonGroup, {
|
|
50
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.InputGroup, {
|
|
51
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.InputGroup.Text, {
|
|
52
|
+
children: "Standard scale"
|
|
53
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Dropdown, {
|
|
54
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Toggle, {
|
|
55
|
+
id: "dropdownStandardScale",
|
|
56
|
+
variant: "light",
|
|
57
|
+
children: dataset.controls.standardScale
|
|
58
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Menu, {
|
|
59
|
+
children: standardScaleList
|
|
60
|
+
})]
|
|
61
|
+
})]
|
|
62
|
+
})
|
|
63
|
+
})]
|
|
64
|
+
});
|
|
65
|
+
}
|
|
@@ -4,21 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ObsColsList = ObsColsList;
|
|
7
|
-
require("bootstrap/dist/css/bootstrap.min.css");
|
|
8
|
-
require("bootstrap/dist/js/bootstrap.bundle.min.js");
|
|
9
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
10
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _freeSolidSvgIcons = require("@fortawesome/free-solid-svg-icons");
|
|
9
|
+
var _reactFontawesome = require("@fortawesome/react-fontawesome");
|
|
10
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
11
|
+
var _reactBootstrap = require("react-bootstrap");
|
|
12
|
+
var _ObsValueList = require("./ObsValueList");
|
|
13
|
+
var _constants = require("../../constants/constants");
|
|
11
14
|
var _DatasetContext = require("../../context/DatasetContext");
|
|
15
|
+
var _colorHelper = require("../../helpers/color-helper");
|
|
16
|
+
var _LoadingIndicators = require("../../utils/LoadingIndicators");
|
|
12
17
|
var _requests = require("../../utils/requests");
|
|
13
|
-
var _chromaJs = _interopRequireDefault(require("chroma-js"));
|
|
14
|
-
var _LoadingSpinner = require("../../utils/LoadingSpinner");
|
|
15
|
-
var _reactBootstrap = require("react-bootstrap");
|
|
16
|
-
var _reactFontawesome = require("@fortawesome/react-fontawesome");
|
|
17
|
-
var _freeSolidSvgIcons = require("@fortawesome/free-solid-svg-icons");
|
|
18
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
20
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
20
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
21
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
22
22
|
const N_BINS = 5;
|
|
23
23
|
function binContinuous(data) {
|
|
24
24
|
let nBins = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : N_BINS;
|
|
@@ -49,17 +49,19 @@ function binDiscrete(data) {
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
function ObsColsList() {
|
|
52
|
-
var _dataset$selectedObs;
|
|
52
|
+
var _dataset$selectedObs, _dataset$selectedObs4, _dataset$selectedObs6;
|
|
53
53
|
const ENDPOINT = "obs/cols";
|
|
54
54
|
const dataset = (0, _DatasetContext.useDataset)();
|
|
55
55
|
const dispatch = (0, _DatasetContext.useDatasetDispatch)();
|
|
56
|
-
const [
|
|
57
|
-
const [
|
|
58
|
-
const [updatedObsColsList, setUpdatedObsColsList] = (0, _react.useState)(false);
|
|
56
|
+
const [obsCols, setObsCols] = (0, _react.useState)({});
|
|
57
|
+
const [updatedObsCols, setupdatedObsCols] = (0, _react.useState)(false);
|
|
59
58
|
const [active, setActive] = (0, _react.useState)((_dataset$selectedObs = dataset.selectedObs) === null || _dataset$selectedObs === void 0 ? void 0 : _dataset$selectedObs.name);
|
|
60
59
|
const [params, setParams] = (0, _react.useState)({
|
|
61
60
|
url: dataset.url
|
|
62
61
|
});
|
|
62
|
+
const {
|
|
63
|
+
getColor
|
|
64
|
+
} = (0, _colorHelper.useColor)();
|
|
63
65
|
(0, _react.useEffect)(() => {
|
|
64
66
|
setParams(p => {
|
|
65
67
|
return {
|
|
@@ -75,66 +77,88 @@ function ObsColsList() {
|
|
|
75
77
|
} = (0, _requests.useFetch)(ENDPOINT, params, {
|
|
76
78
|
refetchOnMount: false
|
|
77
79
|
});
|
|
78
|
-
const validateSelection = (0, _react.useCallback)(
|
|
79
|
-
if (
|
|
80
|
-
|
|
80
|
+
const validateSelection = (0, _react.useCallback)(obs => {
|
|
81
|
+
if (!_lodash.default.isEqual(_lodash.default.omit(obsCols[obs.name], ["omit"]), _lodash.default.omit(obs, ["omit"]))) return false;
|
|
82
|
+
if (!_lodash.default.isEqual(obsCols[obs.name].omit, obs.omit)) {
|
|
83
|
+
setObsCols(o => {
|
|
84
|
+
return {
|
|
85
|
+
...o,
|
|
86
|
+
[obs.name]: {
|
|
87
|
+
...o[obs.name],
|
|
88
|
+
omit: obs.omit
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return true;
|
|
94
|
+
}, [obsCols]);
|
|
95
|
+
(0, _react.useEffect)(() => {
|
|
96
|
+
if (updatedObsCols) {
|
|
97
|
+
if (dataset.selectedObs) {
|
|
98
|
+
if (validateSelection(dataset.selectedObs)) {
|
|
99
|
+
setActive(dataset.selectedObs.name);
|
|
100
|
+
} else {
|
|
101
|
+
dispatch({
|
|
102
|
+
type: "select.obs",
|
|
103
|
+
obs: null
|
|
104
|
+
});
|
|
105
|
+
setActive(null);
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
81
108
|
setActive(null);
|
|
82
|
-
dispatch({
|
|
83
|
-
type: "obsSelected",
|
|
84
|
-
obs: null
|
|
85
|
-
});
|
|
86
109
|
}
|
|
87
110
|
}
|
|
88
|
-
}, [dispatch,
|
|
111
|
+
}, [dataset.selectedObs, dispatch, updatedObsCols, validateSelection]);
|
|
112
|
+
|
|
113
|
+
// @TODO: change api to return all obs and truncate here
|
|
89
114
|
(0, _react.useEffect)(() => {
|
|
90
115
|
if (!isPending && !serverError) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
result[key.name] = {
|
|
94
|
-
type: key.type
|
|
95
|
-
};
|
|
96
|
-
if (key.type === "categorical") {
|
|
97
|
-
result[key.name]["is_truncated"] = key.is_truncated;
|
|
98
|
-
result[key.name]["n_values"] = key.n_values;
|
|
99
|
-
result[key.name]["values"] = key.values;
|
|
100
|
-
result[key.name]["state"] = key.values.map((value, index) => {
|
|
101
|
-
return {
|
|
102
|
-
value: value,
|
|
103
|
-
color: (0, _chromaJs.default)(colors[index]).rgb(),
|
|
104
|
-
checked: true
|
|
105
|
-
};
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
return result;
|
|
109
|
-
}, {}));
|
|
110
|
-
setObsColsList(fetchedData.map(d => {
|
|
111
|
-
if (d.type === "continuous") {
|
|
116
|
+
setObsCols(_lodash.default.keyBy(_lodash.default.map(fetchedData, d => {
|
|
117
|
+
if (d.type === _constants.OBS_TYPES.CONTINUOUS) {
|
|
112
118
|
d = binContinuous(d);
|
|
113
|
-
}
|
|
114
|
-
if (d.type === "discrete") {
|
|
119
|
+
} else if (d.type === _constants.OBS_TYPES.DISCRETE) {
|
|
115
120
|
d = binDiscrete(d);
|
|
116
121
|
}
|
|
117
|
-
return
|
|
118
|
-
|
|
119
|
-
|
|
122
|
+
return {
|
|
123
|
+
...d,
|
|
124
|
+
omit: []
|
|
125
|
+
};
|
|
126
|
+
}), "name"));
|
|
127
|
+
setupdatedObsCols(true);
|
|
120
128
|
}
|
|
121
129
|
}, [fetchedData, isPending, serverError]);
|
|
122
|
-
(0, _react.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
type: "set.obs",
|
|
133
|
-
value: obs
|
|
130
|
+
const toggleAll = (0, _react.useCallback)((item, checked, active) => {
|
|
131
|
+
const omit = checked ? [] : _lodash.default.map(item.values, v => item.codes[v]);
|
|
132
|
+
setObsCols(o => {
|
|
133
|
+
return {
|
|
134
|
+
...o,
|
|
135
|
+
[item.name]: {
|
|
136
|
+
...item,
|
|
137
|
+
omit: omit
|
|
138
|
+
}
|
|
139
|
+
};
|
|
134
140
|
});
|
|
135
|
-
|
|
141
|
+
if (active === item.name) {
|
|
142
|
+
dispatch({
|
|
143
|
+
type: "select.obs",
|
|
144
|
+
obs: {
|
|
145
|
+
...item,
|
|
146
|
+
omit: omit
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}, [dispatch]);
|
|
136
151
|
const categoricalList = (0, _react.useCallback)(function (item) {
|
|
152
|
+
var _dataset$selectedObs2, _dataset$selectedObs3;
|
|
137
153
|
let active = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
154
|
+
const codesMap = _lodash.default.invert(item.codes);
|
|
155
|
+
const inLabelObs = _lodash.default.some(dataset.labelObs, i => _lodash.default.isEqual(i, {
|
|
156
|
+
name: item.name,
|
|
157
|
+
type: item.type,
|
|
158
|
+
codesMap: codesMap
|
|
159
|
+
}));
|
|
160
|
+
const min = _lodash.default.min(_lodash.default.values(item.codes));
|
|
161
|
+
const max = _lodash.default.max(_lodash.default.values(item.codes));
|
|
138
162
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Accordion.Item, {
|
|
139
163
|
eventKey: item.name,
|
|
140
164
|
className: item.name === active ? "cherita-accordion-active" : "",
|
|
@@ -144,81 +168,174 @@ function ObsColsList() {
|
|
|
144
168
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.ListGroup, {
|
|
145
169
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ListGroup.Item, {
|
|
146
170
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
147
|
-
|
|
171
|
+
className: "d-flex",
|
|
148
172
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
149
|
-
|
|
173
|
+
className: "flex-grow-1",
|
|
150
174
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Form.Check, {
|
|
151
175
|
// prettier-ignore
|
|
152
176
|
type: "switch",
|
|
153
177
|
id: "custom-switch",
|
|
154
|
-
label: "Toggle all"
|
|
178
|
+
label: "Toggle all",
|
|
179
|
+
checked: !item.omit.length,
|
|
180
|
+
onChange: () => {
|
|
181
|
+
toggleAll(item, !!item.omit.length, active);
|
|
182
|
+
}
|
|
155
183
|
})
|
|
156
184
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
157
|
-
children: /*#__PURE__*/(0, _jsxRuntime.
|
|
158
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
|
|
159
|
-
variant: "
|
|
185
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.ButtonGroup, {
|
|
186
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
|
|
187
|
+
variant: inLabelObs ? "primary" : "outline-primary",
|
|
160
188
|
size: "sm",
|
|
161
|
-
onClick:
|
|
162
|
-
if (
|
|
189
|
+
onClick: () => {
|
|
190
|
+
if (inLabelObs) {
|
|
163
191
|
dispatch({
|
|
164
|
-
type: "
|
|
165
|
-
|
|
192
|
+
type: "remove.label.obs",
|
|
193
|
+
obsName: item.name
|
|
166
194
|
});
|
|
195
|
+
} else {
|
|
167
196
|
dispatch({
|
|
168
|
-
type: "
|
|
169
|
-
|
|
197
|
+
type: "add.label.obs",
|
|
198
|
+
obs: {
|
|
199
|
+
name: item.name,
|
|
200
|
+
type: item.type,
|
|
201
|
+
codesMap: codesMap
|
|
202
|
+
}
|
|
170
203
|
});
|
|
171
204
|
}
|
|
172
205
|
},
|
|
206
|
+
title: "Add to tooltip",
|
|
207
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
|
|
208
|
+
icon: _freeSolidSvgIcons.faFont
|
|
209
|
+
})
|
|
210
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
|
|
211
|
+
variant: dataset.sliceBy.obs && ((_dataset$selectedObs2 = dataset.selectedObs) === null || _dataset$selectedObs2 === void 0 ? void 0 : _dataset$selectedObs2.name) === item.name ? "primary" : "outline-primary",
|
|
212
|
+
size: "sm",
|
|
213
|
+
onClick: () => {
|
|
214
|
+
dispatch({
|
|
215
|
+
type: "toggle.slice.obs",
|
|
216
|
+
obs: item
|
|
217
|
+
});
|
|
218
|
+
},
|
|
219
|
+
title: "Slice to selected",
|
|
220
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
|
|
221
|
+
icon: _freeSolidSvgIcons.faEye
|
|
222
|
+
})
|
|
223
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
|
|
224
|
+
variant: dataset.colorEncoding === _constants.COLOR_ENCODINGS.OBS && ((_dataset$selectedObs3 = dataset.selectedObs) === null || _dataset$selectedObs3 === void 0 ? void 0 : _dataset$selectedObs3.name) === item.name ? "primary" : "outline-primary",
|
|
225
|
+
size: "sm",
|
|
226
|
+
onClick: () => {
|
|
227
|
+
dispatch({
|
|
228
|
+
type: "select.obs",
|
|
229
|
+
obs: item
|
|
230
|
+
});
|
|
231
|
+
dispatch({
|
|
232
|
+
type: "set.colorEncoding",
|
|
233
|
+
value: "obs"
|
|
234
|
+
});
|
|
235
|
+
},
|
|
236
|
+
title: "Set as color encoding",
|
|
173
237
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
|
|
174
238
|
icon: _freeSolidSvgIcons.faDroplet
|
|
175
239
|
})
|
|
176
|
-
})
|
|
240
|
+
})]
|
|
177
241
|
})
|
|
178
242
|
})]
|
|
179
243
|
})
|
|
180
|
-
}),
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
})]
|
|
207
|
-
})
|
|
208
|
-
}, value))]
|
|
244
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ObsValueList.ObsValueList, {
|
|
245
|
+
item: item,
|
|
246
|
+
onChange: value => {
|
|
247
|
+
const newItem = {
|
|
248
|
+
...item,
|
|
249
|
+
omit: !_lodash.default.includes(item.omit, item.codes[value]) ? [...item.omit, item.codes[value]] : _lodash.default.filter(item.omit, o => o !== item.codes[value])
|
|
250
|
+
};
|
|
251
|
+
setObsCols(o => {
|
|
252
|
+
return {
|
|
253
|
+
...o,
|
|
254
|
+
[item.name]: newItem
|
|
255
|
+
};
|
|
256
|
+
});
|
|
257
|
+
if (active === item.name) {
|
|
258
|
+
dispatch({
|
|
259
|
+
type: "select.obs",
|
|
260
|
+
obs: newItem
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
getFillColor: value => {
|
|
265
|
+
return "rgb(".concat(getColor((item.codes[value] - min) / (max - min), true, _lodash.default.includes(item.omit, item.codes[value]), {
|
|
266
|
+
alpha: 1
|
|
267
|
+
}, "obs"), ")");
|
|
268
|
+
}
|
|
269
|
+
})]
|
|
209
270
|
})
|
|
210
271
|
})]
|
|
211
272
|
}, item.name);
|
|
212
|
-
}, [obs]);
|
|
273
|
+
}, [dataset.labelObs, dataset.sliceBy.obs, (_dataset$selectedObs4 = dataset.selectedObs) === null || _dataset$selectedObs4 === void 0 ? void 0 : _dataset$selectedObs4.name, dataset.colorEncoding, toggleAll, dispatch, getColor]);
|
|
213
274
|
const continuousList = (0, _react.useCallback)(function (item) {
|
|
275
|
+
var _dataset$selectedObs5;
|
|
214
276
|
let active = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
277
|
+
const inLabelObs = _lodash.default.some(dataset.labelObs, i => _lodash.default.isEqual(i, {
|
|
278
|
+
name: item.name,
|
|
279
|
+
type: item.type
|
|
280
|
+
}));
|
|
215
281
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Accordion.Item, {
|
|
216
282
|
eventKey: item.name,
|
|
217
283
|
className: item.name === active ? "cherita-accordion-active" : "",
|
|
218
284
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Accordion.Header, {
|
|
219
285
|
children: item.name
|
|
220
286
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Accordion.Body, {
|
|
221
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.
|
|
287
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ListGroup, {
|
|
288
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ListGroup.Item, {
|
|
289
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
290
|
+
className: "d-flex justify-content-end",
|
|
291
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.ButtonGroup, {
|
|
292
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
|
|
293
|
+
variant: inLabelObs ? "primary" : "outline-primary",
|
|
294
|
+
size: "sm",
|
|
295
|
+
onClick: () => {
|
|
296
|
+
if (inLabelObs) {
|
|
297
|
+
dispatch({
|
|
298
|
+
type: "remove.label.obs",
|
|
299
|
+
obsName: item.name
|
|
300
|
+
});
|
|
301
|
+
} else {
|
|
302
|
+
dispatch({
|
|
303
|
+
type: "add.label.obs",
|
|
304
|
+
obs: {
|
|
305
|
+
name: item.name,
|
|
306
|
+
type: item.type
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
title: "Add to tooltip",
|
|
312
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
|
|
313
|
+
icon: _freeSolidSvgIcons.faFont
|
|
314
|
+
})
|
|
315
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
|
|
316
|
+
variant: dataset.colorEncoding === _constants.COLOR_ENCODINGS.OBS && ((_dataset$selectedObs5 = dataset.selectedObs) === null || _dataset$selectedObs5 === void 0 ? void 0 : _dataset$selectedObs5.name) === item.name ? "primary" : "outline-primary",
|
|
317
|
+
size: "sm",
|
|
318
|
+
onClick: key => {
|
|
319
|
+
if (key != null) {
|
|
320
|
+
dispatch({
|
|
321
|
+
type: "select.obs",
|
|
322
|
+
obs: item
|
|
323
|
+
});
|
|
324
|
+
dispatch({
|
|
325
|
+
type: "set.colorEncoding",
|
|
326
|
+
value: "obs"
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
title: "Set as color encoding",
|
|
331
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
|
|
332
|
+
icon: _freeSolidSvgIcons.faDroplet
|
|
333
|
+
})
|
|
334
|
+
})]
|
|
335
|
+
})
|
|
336
|
+
})
|
|
337
|
+
})
|
|
338
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("p", {
|
|
222
339
|
children: ["Min: ", item.min]
|
|
223
340
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("p", {
|
|
224
341
|
children: ["Max: ", item.max]
|
|
@@ -231,7 +348,7 @@ function ObsColsList() {
|
|
|
231
348
|
})]
|
|
232
349
|
})]
|
|
233
350
|
}, item.name);
|
|
234
|
-
}, []);
|
|
351
|
+
}, [dataset.colorEncoding, dataset.labelObs, (_dataset$selectedObs6 = dataset.selectedObs) === null || _dataset$selectedObs6 === void 0 ? void 0 : _dataset$selectedObs6.name, dispatch]);
|
|
235
352
|
const otherList = (0, _react.useCallback)(function (item) {
|
|
236
353
|
let active = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
237
354
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Accordion.Item, {
|
|
@@ -244,21 +361,22 @@ function ObsColsList() {
|
|
|
244
361
|
})]
|
|
245
362
|
}, item.name);
|
|
246
363
|
}, []);
|
|
247
|
-
const obsList = (0, _react.useMemo)(() =>
|
|
248
|
-
|
|
364
|
+
const obsList = (0, _react.useMemo)(() => _lodash.default.keys(obsCols).map(o => {
|
|
365
|
+
const item = obsCols[o];
|
|
366
|
+
if (item.type === _constants.OBS_TYPES.CATEGORICAL) {
|
|
249
367
|
return categoricalList(item, active);
|
|
250
|
-
} else if (item.type ===
|
|
368
|
+
} else if (item.type === _constants.OBS_TYPES.CONTINUOUS) {
|
|
251
369
|
return continuousList(item, active);
|
|
252
370
|
} else {
|
|
253
371
|
return otherList(item, active);
|
|
254
372
|
}
|
|
255
|
-
}), [
|
|
373
|
+
}), [obsCols, categoricalList, active, continuousList, otherList]);
|
|
256
374
|
if (!serverError) {
|
|
257
375
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
258
|
-
className: "position-relative",
|
|
376
|
+
className: "position-relative h-100",
|
|
259
377
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
260
|
-
className: "list-group overflow-auto",
|
|
261
|
-
children: [isPending && /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
378
|
+
className: "list-group overflow-auto h-100",
|
|
379
|
+
children: [isPending && /*#__PURE__*/(0, _jsxRuntime.jsx)(_LoadingIndicators.LoadingSpinner, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Accordion, {
|
|
262
380
|
flush: true,
|
|
263
381
|
defaultActiveKey: active,
|
|
264
382
|
alwaysOpen: true,
|