@haniffalab/cherita-react 1.3.0-dev.2025-06-06.f1eddad0 → 1.3.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/README.md +1 -1
- package/dist/cjs/components/controls/Controls.js +38 -30
- package/dist/cjs/components/dotplot/Dotplot.js +67 -69
- package/dist/cjs/components/dotplot/DotplotControls.js +103 -83
- package/dist/cjs/components/full-page/FullPage.js +99 -105
- package/dist/cjs/components/full-page/PlotAlert.js +45 -0
- package/dist/cjs/components/full-page/PlotTypeSelector.js +89 -44
- package/dist/cjs/components/heatmap/Heatmap.js +65 -65
- package/dist/cjs/components/heatmap/HeatmapControls.js +6 -3
- package/dist/cjs/components/icons/DotPlotIcon.js +64 -0
- package/dist/cjs/components/icons/HeatmapIcon.js +45 -0
- package/dist/cjs/components/icons/MatrixPlotIcon.1.js +57 -0
- package/dist/cjs/components/icons/MatrixPlotIcon.js +59 -0
- package/dist/cjs/components/icons/ScatterplotIcon.1.js +164 -0
- package/dist/cjs/components/icons/ScatterplotIcon.js +144 -0
- package/dist/cjs/components/icons/ViolinPlotIcon.js +42 -0
- package/dist/cjs/components/matrixplot/Matrixplot.js +65 -66
- package/dist/cjs/components/matrixplot/MatrixplotControls.js +8 -5
- package/dist/cjs/components/obs-list/ObsItem.js +267 -205
- package/dist/cjs/components/obs-list/ObsList.js +161 -129
- package/dist/cjs/components/obs-list/ObsToolbar.js +2 -3
- package/dist/cjs/components/obsm-list/ObsmList.js +67 -28
- package/dist/cjs/components/offcanvas/index.js +62 -27
- package/dist/cjs/components/pseudospatial/Pseudospatial.js +132 -76
- package/dist/cjs/components/pseudospatial/PseudospatialToolbar.js +122 -74
- package/dist/cjs/components/scatterplot/Scatterplot.js +128 -100
- package/dist/cjs/components/scatterplot/ScatterplotControls.js +45 -31
- package/dist/cjs/components/scatterplot/SpatialControls.js +140 -113
- package/dist/cjs/components/scatterplot/Toolbox.js +41 -30
- package/dist/cjs/components/search-bar/SearchBar.js +176 -120
- package/dist/cjs/components/search-bar/SearchInfo.js +76 -50
- package/dist/cjs/components/search-bar/SearchResults.js +93 -71
- package/dist/cjs/components/toolbar/Toolbar.js +46 -37
- package/dist/cjs/components/var-list/VarItem.js +131 -103
- package/dist/cjs/components/var-list/VarList.js +85 -71
- package/dist/cjs/components/var-list/VarListToolbar.js +59 -54
- package/dist/cjs/components/var-list/VarSet.js +126 -108
- package/dist/cjs/components/violin/Violin.js +109 -97
- package/dist/cjs/components/violin/ViolinControls.js +8 -5
- package/dist/cjs/constants/colorscales.js +19 -19
- package/dist/cjs/constants/constants.js +51 -48
- package/dist/cjs/context/DatasetContext.js +26 -17
- package/dist/cjs/context/FilterContext.js +11 -9
- package/dist/cjs/context/SettingsContext.js +271 -88
- package/dist/cjs/context/ZarrDataContext.js +6 -5
- package/dist/cjs/helpers/color-helper.js +2 -2
- package/dist/cjs/helpers/zarr-helper.js +3 -3
- package/dist/cjs/utils/Filter.js +16 -11
- package/dist/cjs/utils/Histogram.js +35 -33
- package/dist/cjs/utils/ImageViewer.js +11 -8
- package/dist/cjs/utils/Legend.js +37 -30
- package/dist/cjs/utils/LoadingIndicators.js +15 -13
- package/dist/cjs/utils/Resolver.js +213 -0
- package/dist/cjs/utils/Skeleton.js +10 -10
- package/dist/cjs/utils/StyledTooltip.js +44 -0
- package/dist/cjs/utils/VirtualizedList.js +36 -29
- package/dist/cjs/utils/errors.js +15 -15
- package/dist/cjs/utils/requests.js +21 -9
- package/dist/cjs/utils/search.js +4 -4
- package/dist/cjs/utils/string.js +6 -6
- package/dist/cjs/utils/zarrData.js +20 -21
- package/dist/css/cherita.css +135 -65
- package/dist/css/cherita.css.map +1 -1
- package/dist/esm/components/controls/Controls.js +43 -35
- package/dist/esm/components/dotplot/Dotplot.js +77 -78
- package/dist/esm/components/dotplot/DotplotControls.js +106 -85
- package/dist/esm/components/full-page/FullPage.js +119 -124
- package/dist/esm/components/full-page/PlotAlert.js +39 -0
- package/dist/esm/components/full-page/PlotTypeSelector.js +90 -45
- package/dist/esm/components/heatmap/Heatmap.js +75 -74
- package/dist/esm/components/heatmap/HeatmapControls.js +8 -4
- package/dist/esm/components/icons/DotPlotIcon.js +58 -0
- package/dist/esm/components/icons/HeatmapIcon.js +39 -0
- package/dist/esm/components/icons/MatrixPlotIcon.1.js +51 -0
- package/dist/esm/components/icons/MatrixPlotIcon.js +53 -0
- package/dist/esm/components/icons/ScatterplotIcon.1.js +158 -0
- package/dist/esm/components/icons/ScatterplotIcon.js +138 -0
- package/dist/esm/components/icons/ViolinPlotIcon.js +36 -0
- package/dist/esm/components/matrixplot/Matrixplot.js +75 -75
- package/dist/esm/components/matrixplot/MatrixplotControls.js +10 -6
- package/dist/esm/components/obs-list/ObsItem.js +282 -217
- package/dist/esm/components/obs-list/ObsList.js +176 -143
- package/dist/esm/components/obs-list/ObsToolbar.js +3 -3
- package/dist/esm/components/obsm-list/ObsmList.js +71 -32
- package/dist/esm/components/offcanvas/index.js +68 -33
- package/dist/esm/components/pseudospatial/Pseudospatial.js +145 -88
- package/dist/esm/components/pseudospatial/PseudospatialToolbar.js +127 -78
- package/dist/esm/components/scatterplot/Scatterplot.js +149 -120
- package/dist/esm/components/scatterplot/ScatterplotControls.js +50 -35
- package/dist/esm/components/scatterplot/SpatialControls.js +153 -125
- package/dist/esm/components/scatterplot/Toolbox.js +44 -32
- package/dist/esm/components/search-bar/SearchBar.js +187 -130
- package/dist/esm/components/search-bar/SearchInfo.js +86 -59
- package/dist/esm/components/search-bar/SearchResults.js +100 -77
- package/dist/esm/components/toolbar/Toolbar.js +49 -39
- package/dist/esm/components/var-list/VarItem.js +142 -113
- package/dist/esm/components/var-list/VarList.js +99 -84
- package/dist/esm/components/var-list/VarListToolbar.js +64 -58
- package/dist/esm/components/var-list/VarSet.js +134 -115
- package/dist/esm/components/violin/Violin.js +121 -108
- package/dist/esm/components/violin/ViolinControls.js +10 -6
- package/dist/esm/constants/colorscales.js +19 -19
- package/dist/esm/constants/constants.js +50 -47
- package/dist/esm/context/DatasetContext.js +33 -23
- package/dist/esm/context/FilterContext.js +11 -8
- package/dist/esm/context/SettingsContext.js +273 -89
- package/dist/esm/context/ZarrDataContext.js +8 -6
- package/dist/esm/helpers/color-helper.js +5 -5
- package/dist/esm/helpers/map-helper.js +2 -2
- package/dist/esm/helpers/zarr-helper.js +6 -6
- package/dist/esm/index.js +22 -22
- package/dist/esm/utils/Filter.js +22 -17
- package/dist/esm/utils/Histogram.js +39 -37
- package/dist/esm/utils/ImageViewer.js +12 -8
- package/dist/esm/utils/Legend.js +44 -36
- package/dist/esm/utils/LoadingIndicators.js +16 -13
- package/dist/esm/utils/Resolver.js +201 -0
- package/dist/esm/utils/Skeleton.js +11 -10
- package/dist/esm/utils/StyledTooltip.js +38 -0
- package/dist/esm/utils/VirtualizedList.js +37 -29
- package/dist/esm/utils/errors.js +15 -15
- package/dist/esm/utils/requests.js +24 -12
- package/dist/esm/utils/search.js +7 -7
- package/dist/esm/utils/string.js +7 -7
- package/dist/esm/utils/zarrData.js +27 -28
- package/package.json +21 -10
- package/scss/cherita-bootstrap.scss +2 -2
- package/scss/cherita.scss +65 -16
- package/scss/components/accordions.scss +15 -2
- package/scss/components/layouts.scss +68 -50
- package/scss/components/lists.scss +16 -5
- package/scss/components/plotly.scss +38 -26
- package/scss/components/plots.scss +14 -1
- package/dist/assets/images/plots/dotplot.svg +0 -152
- package/dist/assets/images/plots/heatmap.svg +0 -193
- package/dist/assets/images/plots/matrixplot.svg +0 -275
- package/dist/assets/images/plots/scatterplot.svg +0 -198
- package/dist/assets/images/plots/violin.svg +0 -50
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Scatterplot = Scatterplot;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = require("react");
|
|
8
8
|
var _layers = require("@deck.gl/layers");
|
|
9
9
|
var _react2 = require("@deck.gl/react");
|
|
10
10
|
var _freeSolidSvgIcons = require("@fortawesome/free-solid-svg-icons");
|
|
@@ -24,10 +24,12 @@ var _colorHelper = require("../../helpers/color-helper");
|
|
|
24
24
|
var _mapHelper = require("../../helpers/map-helper");
|
|
25
25
|
var _Legend = require("../../utils/Legend");
|
|
26
26
|
var _LoadingIndicators = require("../../utils/LoadingIndicators");
|
|
27
|
+
var _Resolver = require("../../utils/Resolver");
|
|
27
28
|
var _string = require("../../utils/string");
|
|
28
29
|
var _zarrData = require("../../utils/zarrData");
|
|
30
|
+
var _PlotAlert = require("../full-page/PlotAlert");
|
|
31
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
29
32
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
30
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
31
33
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
32
34
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
33
35
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
@@ -43,11 +45,13 @@ const INITIAL_VIEW_STATE = {
|
|
|
43
45
|
bearing: 0
|
|
44
46
|
};
|
|
45
47
|
function Scatterplot(_ref) {
|
|
46
|
-
var
|
|
48
|
+
var _features$features2, _obsmData$serverError, _labelObsData$serverE, _settings$selectedVar, _data$positions;
|
|
47
49
|
let {
|
|
48
50
|
radius = null,
|
|
49
51
|
setShowObs,
|
|
50
52
|
setShowVars,
|
|
53
|
+
plotType,
|
|
54
|
+
setPlotType,
|
|
51
55
|
isFullscreen = false
|
|
52
56
|
} = _ref;
|
|
53
57
|
const {
|
|
@@ -74,11 +78,14 @@ function Scatterplot(_ref) {
|
|
|
74
78
|
values: []
|
|
75
79
|
});
|
|
76
80
|
const [coordsError, setCoordsError] = (0, _react.useState)(null);
|
|
81
|
+
const [hasObsm, setHasObsm] = (0, _react.useState)(true);
|
|
82
|
+
const [dataError, setDataError] = (0, _react.useState)(null);
|
|
83
|
+
const selectedObs = (0, _Resolver.useSelectedObs)();
|
|
77
84
|
|
|
78
85
|
// EditableGeoJsonLayer
|
|
79
86
|
const [mode, setMode] = (0, _react.useState)(() => _editModes.ViewMode);
|
|
80
87
|
const [features, setFeatures] = (0, _react.useState)({
|
|
81
|
-
type:
|
|
88
|
+
type: 'FeatureCollection',
|
|
82
89
|
features: settings.polygons[settings.selectedObsm] || []
|
|
83
90
|
});
|
|
84
91
|
const [selectedFeatureIndexes, setSelectedFeatureIndexes] = (0, _react.useState)([]);
|
|
@@ -107,13 +114,25 @@ function Scatterplot(_ref) {
|
|
|
107
114
|
setData(d => {
|
|
108
115
|
let values = d.values;
|
|
109
116
|
if (settings.colorEncoding === _constants.COLOR_ENCODINGS.VAR) {
|
|
110
|
-
|
|
117
|
+
if (!xData.serverError) {
|
|
118
|
+
values = xData.data;
|
|
119
|
+
setDataError(null);
|
|
120
|
+
} else {
|
|
121
|
+
values = [];
|
|
122
|
+
setDataError(xData.serverError);
|
|
123
|
+
}
|
|
111
124
|
} else if (settings.colorEncoding === _constants.COLOR_ENCODINGS.OBS) {
|
|
112
|
-
|
|
125
|
+
if (!obsData.serverError) {
|
|
126
|
+
values = obsData.data;
|
|
127
|
+
setDataError(null);
|
|
128
|
+
} else {
|
|
129
|
+
values = [];
|
|
130
|
+
setDataError(obsData.serverError);
|
|
131
|
+
}
|
|
113
132
|
}
|
|
114
133
|
if (!obsmData.serverError && obsmData.data) {
|
|
115
134
|
if (obsmData.data[0].length !== 2) {
|
|
116
|
-
setCoordsError(
|
|
135
|
+
setCoordsError('Invalid coordinates. Expected 2D coordinates');
|
|
117
136
|
return {
|
|
118
137
|
positions: [],
|
|
119
138
|
values: []
|
|
@@ -154,7 +173,7 @@ function Scatterplot(_ref) {
|
|
|
154
173
|
});
|
|
155
174
|
});
|
|
156
175
|
}
|
|
157
|
-
}, [
|
|
176
|
+
}, [getRadiusScale, obsmData.data, obsmData.isPending, obsmData.serverError, data.positions]);
|
|
158
177
|
const getBounds = (0, _react.useCallback)(() => {
|
|
159
178
|
var _deckRef$current3, _deckRef$current4;
|
|
160
179
|
const {
|
|
@@ -182,8 +201,7 @@ function Scatterplot(_ref) {
|
|
|
182
201
|
getOriginalIndex,
|
|
183
202
|
sortedIndexMap
|
|
184
203
|
} = (0, _react.useMemo)(() => {
|
|
185
|
-
|
|
186
|
-
if ((settings.colorEncoding === _constants.COLOR_ENCODINGS.VAR || settings.colorEncoding === _constants.COLOR_ENCODINGS.OBS && ((_settings$selectedObs = settings.selectedObs) === null || _settings$selectedObs === void 0 ? void 0 : _settings$selectedObs.type) === _constants.OBS_TYPES.CONTINUOUS) && data.positions && data.values && data.positions.length === data.values.length) {
|
|
204
|
+
if ((settings.colorEncoding === _constants.COLOR_ENCODINGS.VAR || settings.colorEncoding === _constants.COLOR_ENCODINGS.OBS && (selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.type) === _constants.OBS_TYPES.CONTINUOUS) && data.positions && data.values && data.positions.length === data.values.length) {
|
|
187
205
|
const sortedIndices = _lodash.default.map(data.values, (_v, i) => i).sort((a, b) => data.values[a] - data.values[b]);
|
|
188
206
|
const sortedIndexMap = new Map(_lodash.default.map(sortedIndices, (originalIndex, sortedIndex) => [originalIndex, sortedIndex]));
|
|
189
207
|
return {
|
|
@@ -200,24 +218,17 @@ function Scatterplot(_ref) {
|
|
|
200
218
|
// return original index
|
|
201
219
|
sortedIndexMap: identitySortedIndexMap // return original index
|
|
202
220
|
};
|
|
203
|
-
}, [data, identityGetOriginalIndex, identitySortedIndexMap,
|
|
221
|
+
}, [data, identityGetOriginalIndex, identitySortedIndexMap, selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.type, settings.colorEncoding]);
|
|
204
222
|
const sortedObsIndices = (0, _react.useMemo)(() => {
|
|
205
223
|
return obsIndices ? new Set(Array.from(obsIndices, i => sortedIndexMap.get(i))) : obsIndices;
|
|
206
224
|
}, [obsIndices, sortedIndexMap]);
|
|
207
225
|
const isCategorical = (0, _react.useMemo)(() => {
|
|
208
226
|
if (settings.colorEncoding === _constants.COLOR_ENCODINGS.OBS) {
|
|
209
|
-
|
|
210
|
-
return ((_settings$selectedObs3 = settings.selectedObs) === null || _settings$selectedObs3 === void 0 ? void 0 : _settings$selectedObs3.type) === _constants.OBS_TYPES.CATEGORICAL || ((_settings$selectedObs4 = settings.selectedObs) === null || _settings$selectedObs4 === void 0 ? void 0 : _settings$selectedObs4.type) === _constants.OBS_TYPES.BOOLEAN;
|
|
227
|
+
return (selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.type) === _constants.OBS_TYPES.CATEGORICAL || (selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.type) === _constants.OBS_TYPES.BOOLEAN;
|
|
211
228
|
} else {
|
|
212
229
|
return false;
|
|
213
230
|
}
|
|
214
|
-
}, [settings.colorEncoding,
|
|
215
|
-
(0, _react.useEffect)(() => {
|
|
216
|
-
dispatch({
|
|
217
|
-
type: "set.controls.valueRange",
|
|
218
|
-
valueRange: [valueMin, valueMax]
|
|
219
|
-
});
|
|
220
|
-
}, [dispatch, valueMax, valueMin]);
|
|
231
|
+
}, [settings.colorEncoding, selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.type]);
|
|
221
232
|
const {
|
|
222
233
|
min,
|
|
223
234
|
max
|
|
@@ -226,7 +237,6 @@ function Scatterplot(_ref) {
|
|
|
226
237
|
max: settings.controls.range[1] * (valueMax - valueMin) + valueMin
|
|
227
238
|
};
|
|
228
239
|
const getFillColor = (0, _react.useCallback)((_d, _ref2) => {
|
|
229
|
-
var _settings$selectedObs6, _settings$selectedObs7;
|
|
230
240
|
let {
|
|
231
241
|
index
|
|
232
242
|
} = _ref2;
|
|
@@ -235,10 +245,10 @@ function Scatterplot(_ref) {
|
|
|
235
245
|
value: (sortedData.values[index] - min) / (max - min),
|
|
236
246
|
categorical: isCategorical,
|
|
237
247
|
grayOut: grayOut
|
|
238
|
-
}, useUnsColors && settings.colorEncoding === _constants.COLOR_ENCODINGS.OBS &&
|
|
239
|
-
colorscale:
|
|
248
|
+
}, useUnsColors && settings.colorEncoding === _constants.COLOR_ENCODINGS.OBS && selectedObs !== null && selectedObs !== void 0 && selectedObs.colors ? {
|
|
249
|
+
colorscale: selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.colors
|
|
240
250
|
} : {})) || [0, 0, 0, 100];
|
|
241
|
-
}, [isPending, sortedObsIndices, getColor, sortedData.values, min, max, isCategorical, useUnsColors, settings.colorEncoding,
|
|
251
|
+
}, [isPending, sortedObsIndices, getColor, sortedData.values, min, max, isCategorical, useUnsColors, settings.colorEncoding, selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.colors]);
|
|
242
252
|
|
|
243
253
|
// @TODO: add support for pseudospatial hover to reflect in radius
|
|
244
254
|
const getRadius = (0, _react.useCallback)((_d, _ref3) => {
|
|
@@ -250,7 +260,7 @@ function Scatterplot(_ref) {
|
|
|
250
260
|
}, [sortedObsIndices]);
|
|
251
261
|
const memoizedLayers = (0, _react.useMemo)(() => {
|
|
252
262
|
return [new _layers.ScatterplotLayer({
|
|
253
|
-
id:
|
|
263
|
+
id: 'cherita-layer-scatterplot',
|
|
254
264
|
pickable: true,
|
|
255
265
|
data: sortedData.positions,
|
|
256
266
|
radiusScale: radiusScale,
|
|
@@ -263,7 +273,7 @@ function Scatterplot(_ref) {
|
|
|
263
273
|
getRadius: getRadius
|
|
264
274
|
}
|
|
265
275
|
}), new _layers2.EditableGeoJsonLayer({
|
|
266
|
-
id:
|
|
276
|
+
id: 'cherita-layer-draw',
|
|
267
277
|
data: features,
|
|
268
278
|
mode: mode,
|
|
269
279
|
selectedFeatureIndexes,
|
|
@@ -275,7 +285,7 @@ function Scatterplot(_ref) {
|
|
|
275
285
|
} = _ref4;
|
|
276
286
|
setFeatures(updatedData);
|
|
277
287
|
let updatedSelectedFeatureIndexes = selectedFeatureIndexes;
|
|
278
|
-
if (editType ===
|
|
288
|
+
if (editType === 'addFeature') {
|
|
279
289
|
const {
|
|
280
290
|
featureIndexes
|
|
281
291
|
} = editContext;
|
|
@@ -303,13 +313,13 @@ function Scatterplot(_ref) {
|
|
|
303
313
|
var _features$features;
|
|
304
314
|
if (!(features !== null && features !== void 0 && (_features$features = features.features) !== null && _features$features !== void 0 && _features$features.length)) {
|
|
305
315
|
dispatch({
|
|
306
|
-
type:
|
|
316
|
+
type: 'disable.slice.polygons'
|
|
307
317
|
});
|
|
308
318
|
}
|
|
309
319
|
}, [dispatch, features === null || features === void 0 || (_features$features2 = features.features) === null || _features$features2 === void 0 ? void 0 : _features$features2.length]);
|
|
310
320
|
(0, _react.useEffect)(() => {
|
|
311
321
|
dispatch({
|
|
312
|
-
type:
|
|
322
|
+
type: 'set.polygons',
|
|
313
323
|
obsm: settings.selectedObsm,
|
|
314
324
|
polygons: (features === null || features === void 0 ? void 0 : features.features) || []
|
|
315
325
|
});
|
|
@@ -319,7 +329,7 @@ function Scatterplot(_ref) {
|
|
|
319
329
|
// don't change selection while editing
|
|
320
330
|
return;
|
|
321
331
|
}
|
|
322
|
-
setSelectedFeatureIndexes(f => info.object ? info.layer.id ===
|
|
332
|
+
setSelectedFeatureIndexes(f => info.object ? info.layer.id === 'cherita-layer-draw' ? [info.index] : f : []);
|
|
323
333
|
}
|
|
324
334
|
const getLabel = function (o, v) {
|
|
325
335
|
let isVar = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
@@ -334,13 +344,11 @@ function Scatterplot(_ref) {
|
|
|
334
344
|
object,
|
|
335
345
|
index
|
|
336
346
|
} = _ref5;
|
|
337
|
-
if (!object || (object === null || object === void 0 ? void 0 : object.type) ===
|
|
347
|
+
if (!object || (object === null || object === void 0 ? void 0 : object.type) === 'Feature') return;
|
|
338
348
|
const text = [];
|
|
339
|
-
if (settings.colorEncoding === _constants.COLOR_ENCODINGS.OBS &&
|
|
340
|
-
name: settings.selectedObs.name
|
|
341
|
-
})) {
|
|
349
|
+
if (settings.colorEncoding === _constants.COLOR_ENCODINGS.OBS && selectedObs && !_lodash.default.includes(settings.labelObs, selectedObs.name)) {
|
|
342
350
|
var _data$values;
|
|
343
|
-
text.push(getLabel(
|
|
351
|
+
text.push(getLabel(selectedObs, (_data$values = data.values) === null || _data$values === void 0 ? void 0 : _data$values[getOriginalIndex(index)]));
|
|
344
352
|
}
|
|
345
353
|
if (settings.colorEncoding === _constants.COLOR_ENCODINGS.VAR && settings.selectedVar) {
|
|
346
354
|
var _data$values2;
|
|
@@ -348,82 +356,102 @@ function Scatterplot(_ref) {
|
|
|
348
356
|
}
|
|
349
357
|
if (settings.labelObs.length) {
|
|
350
358
|
text.push(..._lodash.default.map(labelObsData.data, (v, k) => {
|
|
351
|
-
const labelObs =
|
|
359
|
+
const labelObs = settings.data.obs[k];
|
|
352
360
|
return getLabel(labelObs, v[getOriginalIndex(index)]);
|
|
353
361
|
}));
|
|
354
362
|
}
|
|
355
363
|
if (!text.length) return;
|
|
356
364
|
const grayOut = sortedObsIndices && !sortedObsIndices.has(index);
|
|
357
365
|
return {
|
|
358
|
-
text: text.length ? _lodash.default.compact(text).join(
|
|
359
|
-
className: grayOut ?
|
|
366
|
+
text: text.length ? _lodash.default.compact(text).join('\n') : null,
|
|
367
|
+
className: grayOut ? 'tooltip-grayout' : 'deck-tooltip',
|
|
360
368
|
style: !grayOut ? {
|
|
361
|
-
|
|
369
|
+
'border-left': "3px solid ".concat((0, _colorHelper.rgbToHex)(getFillColor(null, {
|
|
362
370
|
index
|
|
363
371
|
})))
|
|
364
372
|
} : {
|
|
365
|
-
|
|
373
|
+
'border-left': 'none'
|
|
366
374
|
}
|
|
367
375
|
};
|
|
368
376
|
};
|
|
369
|
-
const error = settings.selectedObsm && ((_obsmData$serverError = obsmData.serverError) === null || _obsmData$serverError === void 0 ? void 0 : _obsmData$serverError.length) ||
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
377
|
+
const error = settings.selectedObsm && ((_obsmData$serverError = obsmData.serverError) === null || _obsmData$serverError === void 0 ? void 0 : _obsmData$serverError.length) || dataError || settings.labelObs.length && ((_labelObsData$serverE = labelObsData.serverError) === null || _labelObsData$serverE === void 0 ? void 0 : _labelObsData$serverE.length) || coordsError;
|
|
378
|
+
if (!hasObsm) {
|
|
379
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_PlotAlert.PlotAlert, {
|
|
380
|
+
variant: "info",
|
|
381
|
+
heading: "Scatterplot unavailable for this dataset",
|
|
382
|
+
plotType: plotType,
|
|
383
|
+
setPlotType: setPlotType,
|
|
384
|
+
children: "This dataset does not include any embeddings, so a scatterplot cannot be displayed. Please choose a different plot type to explore the data."
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
388
|
+
className: "cherita-container-scatterplot",
|
|
389
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
390
|
+
className: "cherita-scatterplot",
|
|
391
|
+
children: [obsmData.isPending && /*#__PURE__*/(0, _jsxRuntime.jsx)(_LoadingIndicators.LoadingSpinner, {
|
|
392
|
+
disableShrink: true
|
|
393
|
+
}), isPending && /*#__PURE__*/(0, _jsxRuntime.jsx)(_LoadingIndicators.LoadingLinear, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.DeckGL, {
|
|
394
|
+
viewState: viewState,
|
|
395
|
+
onViewStateChange: e => setViewState(e.viewState),
|
|
396
|
+
controller: {
|
|
397
|
+
doubleClickZoom: mode === _editModes.ViewMode
|
|
398
|
+
},
|
|
399
|
+
layers: layers,
|
|
400
|
+
onClick: onLayerClick,
|
|
401
|
+
getTooltip: getTooltip,
|
|
402
|
+
onAfterRender: () => {
|
|
403
|
+
setIsRendering(false);
|
|
404
|
+
},
|
|
405
|
+
useDevicePixels: false,
|
|
406
|
+
getCursor: _ref6 => {
|
|
407
|
+
let {
|
|
408
|
+
isDragging
|
|
409
|
+
} = _ref6;
|
|
410
|
+
return mode !== _editModes.ViewMode ? 'crosshair' : isDragging ? 'grabbing' : 'grab';
|
|
411
|
+
},
|
|
412
|
+
ref: deckRef
|
|
413
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_SpatialControls.SpatialControls, {
|
|
414
|
+
mode: mode,
|
|
415
|
+
setMode: setMode,
|
|
416
|
+
features: features,
|
|
417
|
+
setFeatures: setFeatures,
|
|
418
|
+
selectedFeatureIndexes: selectedFeatureIndexes,
|
|
419
|
+
resetBounds: () => setViewState(getBounds()),
|
|
420
|
+
increaseZoom: () => setViewState(v => _objectSpread(_objectSpread({}, v), {}, {
|
|
421
|
+
zoom: v.zoom + 1
|
|
422
|
+
})),
|
|
423
|
+
decreaseZoom: () => setViewState(v => _objectSpread(_objectSpread({}, v), {}, {
|
|
424
|
+
zoom: v.zoom - 1
|
|
425
|
+
})),
|
|
426
|
+
setShowObs: setShowObs,
|
|
427
|
+
setShowVars: setShowVars,
|
|
428
|
+
isFullscreen: isFullscreen
|
|
429
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
430
|
+
className: "cherita-spatial-footer",
|
|
431
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
432
|
+
className: "cherita-toolbox-footer",
|
|
433
|
+
children: [!!error && !isRendering && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Alert, {
|
|
434
|
+
variant: "danger",
|
|
435
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Alert.Heading, {
|
|
436
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
|
|
437
|
+
icon: _freeSolidSvgIcons.faTriangleExclamation
|
|
438
|
+
}), "\xA0Error loading data"]
|
|
439
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
440
|
+
className: "mb-0",
|
|
441
|
+
children: error.message
|
|
442
|
+
})]
|
|
443
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Toolbox.Toolbox, {
|
|
444
|
+
mode: settings.colorEncoding === _constants.COLOR_ENCODINGS.VAR ? (_settings$selectedVar = settings.selectedVar) === null || _settings$selectedVar === void 0 ? void 0 : _settings$selectedVar.name : settings.colorEncoding === _constants.COLOR_ENCODINGS.OBS ? selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.name : null,
|
|
445
|
+
obsLength: parseInt((_data$positions = data.positions) === null || _data$positions === void 0 ? void 0 : _data$positions.length),
|
|
446
|
+
slicedLength: parseInt(slicedLength),
|
|
447
|
+
setHasObsm: setHasObsm
|
|
448
|
+
})]
|
|
449
|
+
}), !error && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Legend.Legend, {
|
|
450
|
+
isCategorical: isCategorical,
|
|
451
|
+
min: min,
|
|
452
|
+
max: max
|
|
453
|
+
})]
|
|
454
|
+
})]
|
|
455
|
+
})
|
|
456
|
+
});
|
|
429
457
|
}
|
|
@@ -4,21 +4,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ScatterplotControls = void 0;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = require("react");
|
|
8
8
|
var _material = require("@mui/material");
|
|
9
9
|
var _reactBootstrap = require("react-bootstrap");
|
|
10
10
|
var _constants = require("../../constants/constants");
|
|
11
|
+
var _FilterContext = require("../../context/FilterContext");
|
|
11
12
|
var _SettingsContext = require("../../context/SettingsContext");
|
|
13
|
+
var _Resolver = require("../../utils/Resolver");
|
|
12
14
|
var _Controls = require("../controls/Controls");
|
|
13
|
-
|
|
15
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
16
|
const ScatterplotControls = () => {
|
|
15
|
-
var _settings$selectedObs;
|
|
16
17
|
const settings = (0, _SettingsContext.useSettings)();
|
|
17
18
|
const dispatch = (0, _SettingsContext.useSettingsDispatch)();
|
|
18
|
-
const [sliderValue, setSliderValue] = _react.
|
|
19
|
-
const
|
|
19
|
+
const [sliderValue, setSliderValue] = (0, _react.useState)(settings.controls.range || [0, 1]);
|
|
20
|
+
const {
|
|
21
|
+
valueMin,
|
|
22
|
+
valueMax
|
|
23
|
+
} = (0, _FilterContext.useFilteredData)();
|
|
24
|
+
const selectedObs = (0, _Resolver.useSelectedObs)();
|
|
25
|
+
const isCategorical = settings.colorEncoding === _constants.COLOR_ENCODINGS.OBS ? (selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.type) === _constants.OBS_TYPES.CATEGORICAL : false;
|
|
20
26
|
const valueLabelFormat = value => {
|
|
21
|
-
return (value * (
|
|
27
|
+
return (value * (valueMax - valueMin) + valueMin).toFixed(2);
|
|
22
28
|
};
|
|
23
29
|
const marks = [{
|
|
24
30
|
value: 0,
|
|
@@ -33,36 +39,44 @@ const ScatterplotControls = () => {
|
|
|
33
39
|
const updateRange = (_e, value) => {
|
|
34
40
|
setSliderValue(value);
|
|
35
41
|
dispatch({
|
|
36
|
-
type:
|
|
42
|
+
type: 'set.controls.range',
|
|
37
43
|
range: sliderValue
|
|
38
44
|
});
|
|
39
45
|
};
|
|
40
46
|
(0, _react.useEffect)(() => {
|
|
41
47
|
setSliderValue(settings.controls.range);
|
|
42
48
|
}, [settings.controls.range]);
|
|
43
|
-
const rangeSlider = /*#__PURE__*/
|
|
44
|
-
className: "w-100"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
49
|
+
const rangeSlider = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
50
|
+
className: "w-100",
|
|
51
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
52
|
+
id: "colorscale-range",
|
|
53
|
+
gutterBottom: true,
|
|
54
|
+
children: "Colorscale range"
|
|
55
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
56
|
+
className: "px-4",
|
|
57
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Slider, {
|
|
58
|
+
"aria-labelledby": "colorscale-range",
|
|
59
|
+
min: 0,
|
|
60
|
+
max: 1,
|
|
61
|
+
step: 0.001,
|
|
62
|
+
value: sliderValue,
|
|
63
|
+
onChange: updateSlider,
|
|
64
|
+
onChangeCommitted: updateRange,
|
|
65
|
+
valueLabelDisplay: "auto",
|
|
66
|
+
getAriaValueText: valueLabelFormat,
|
|
67
|
+
valueLabelFormat: valueLabelFormat,
|
|
68
|
+
marks: marks,
|
|
69
|
+
disabled: isCategorical
|
|
70
|
+
})
|
|
71
|
+
})]
|
|
72
|
+
});
|
|
73
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
74
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Form, {
|
|
75
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Controls.ColorscaleSelect, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Form.Group, {
|
|
76
|
+
className: "mb-2",
|
|
77
|
+
children: rangeSlider
|
|
78
|
+
})]
|
|
79
|
+
})
|
|
80
|
+
});
|
|
67
81
|
};
|
|
68
82
|
exports.ScatterplotControls = ScatterplotControls;
|