@haniffalab/cherita-react 1.4.1 → 1.4.2-dev.2025-10-29.e8bbb191
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 +100 -74
- 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 +258 -210
- package/dist/cjs/components/obs-list/ObsList.js +161 -133
- package/dist/cjs/components/obs-list/ObsToolbar.js +2 -3
- package/dist/cjs/components/obsm-list/ObsmList.js +53 -38
- package/dist/cjs/components/offcanvas/index.js +61 -31
- 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 +127 -99
- 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 +168 -121
- 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 +115 -88
- package/dist/cjs/components/var-list/VarList.js +85 -69
- 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 -107
- package/dist/cjs/components/violin/ViolinControls.js +8 -5
- package/dist/cjs/constants/colorscales.js +19 -19
- package/dist/cjs/constants/constants.js +47 -47
- package/dist/cjs/context/DatasetContext.js +24 -16
- package/dist/cjs/context/FilterContext.js +11 -9
- package/dist/cjs/context/SettingsContext.js +255 -89
- 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 +34 -27
- 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 +64 -42
- 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 +120 -93
- 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 +273 -222
- package/dist/esm/components/obs-list/ObsList.js +176 -147
- package/dist/esm/components/obs-list/ObsToolbar.js +3 -3
- package/dist/esm/components/obsm-list/ObsmList.js +60 -44
- package/dist/esm/components/offcanvas/index.js +67 -37
- 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 +148 -119
- 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 +180 -132
- 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 +126 -98
- package/dist/esm/components/var-list/VarList.js +99 -82
- 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 -118
- package/dist/esm/components/violin/ViolinControls.js +10 -6
- package/dist/esm/constants/colorscales.js +19 -19
- package/dist/esm/constants/constants.js +47 -47
- package/dist/esm/context/DatasetContext.js +31 -22
- package/dist/esm/context/FilterContext.js +11 -8
- package/dist/esm/context/SettingsContext.js +257 -90
- 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 +35 -27
- 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 -9
- package/scss/cherita-bootstrap.scss +2 -2
- package/scss/cherita.scss +43 -17
- package/scss/components/accordions.scss +4 -1
- package/scss/components/layouts.scss +15 -33
- package/scss/components/lists.scss +8 -4
- 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
|
@@ -3,28 +3,31 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
3
3
|
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; }
|
|
4
4
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
5
5
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
|
-
import
|
|
7
|
-
import { ScatterplotLayer } from
|
|
8
|
-
import { DeckGL } from
|
|
9
|
-
import { faTriangleExclamation } from
|
|
10
|
-
import { FontAwesomeIcon } from
|
|
11
|
-
import { ViewMode } from
|
|
12
|
-
import { EditableGeoJsonLayer } from
|
|
13
|
-
import _ from
|
|
14
|
-
import { Alert } from
|
|
15
|
-
import { SpatialControls } from
|
|
16
|
-
import { Toolbox } from
|
|
17
|
-
import { COLOR_ENCODINGS, OBS_TYPES, SELECTED_POLYGON_FILLCOLOR, UNSELECTED_POLYGON_FILLCOLOR } from
|
|
18
|
-
import { useDataset } from
|
|
19
|
-
import { useFilteredData } from
|
|
20
|
-
import { useSettings, useSettingsDispatch } from
|
|
21
|
-
import { useZarrData } from
|
|
22
|
-
import { rgbToHex, useColor } from
|
|
23
|
-
import { MapHelper } from
|
|
24
|
-
import { Legend } from
|
|
25
|
-
import { LoadingLinear, LoadingSpinner } from
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
6
|
+
import { useCallback, useDeferredValue, useEffect, useMemo, useRef, useState } from 'react';
|
|
7
|
+
import { ScatterplotLayer } from '@deck.gl/layers';
|
|
8
|
+
import { DeckGL } from '@deck.gl/react';
|
|
9
|
+
import { faTriangleExclamation } from '@fortawesome/free-solid-svg-icons';
|
|
10
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
11
|
+
import { ViewMode } from '@nebula.gl/edit-modes';
|
|
12
|
+
import { EditableGeoJsonLayer } from '@nebula.gl/layers';
|
|
13
|
+
import _ from 'lodash';
|
|
14
|
+
import { Alert } from 'react-bootstrap';
|
|
15
|
+
import { SpatialControls } from './SpatialControls';
|
|
16
|
+
import { Toolbox } from './Toolbox';
|
|
17
|
+
import { COLOR_ENCODINGS, OBS_TYPES, SELECTED_POLYGON_FILLCOLOR, UNSELECTED_POLYGON_FILLCOLOR } from '../../constants/constants';
|
|
18
|
+
import { useDataset } from '../../context/DatasetContext';
|
|
19
|
+
import { useFilteredData } from '../../context/FilterContext';
|
|
20
|
+
import { useSettings, useSettingsDispatch } from '../../context/SettingsContext';
|
|
21
|
+
import { useZarrData } from '../../context/ZarrDataContext';
|
|
22
|
+
import { rgbToHex, useColor } from '../../helpers/color-helper';
|
|
23
|
+
import { MapHelper } from '../../helpers/map-helper';
|
|
24
|
+
import { Legend } from '../../utils/Legend';
|
|
25
|
+
import { LoadingLinear, LoadingSpinner } from '../../utils/LoadingIndicators';
|
|
26
|
+
import { useSelectedObs } from '../../utils/Resolver';
|
|
27
|
+
import { formatNumerical } from '../../utils/string';
|
|
28
|
+
import { useLabelObsData } from '../../utils/zarrData';
|
|
29
|
+
import { PlotAlert } from '../full-page/PlotAlert';
|
|
30
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
31
|
window.deck.log.level = 1;
|
|
29
32
|
const INITIAL_VIEW_STATE = {
|
|
30
33
|
longitude: 0,
|
|
@@ -35,11 +38,13 @@ const INITIAL_VIEW_STATE = {
|
|
|
35
38
|
bearing: 0
|
|
36
39
|
};
|
|
37
40
|
export function Scatterplot(_ref) {
|
|
38
|
-
var
|
|
41
|
+
var _features$features2, _obsmData$serverError, _labelObsData$serverE, _settings$selectedVar, _data$positions;
|
|
39
42
|
let {
|
|
40
43
|
radius = null,
|
|
41
44
|
setShowObs,
|
|
42
45
|
setShowVars,
|
|
46
|
+
plotType,
|
|
47
|
+
setPlotType,
|
|
43
48
|
isFullscreen = false
|
|
44
49
|
} = _ref;
|
|
45
50
|
const {
|
|
@@ -66,11 +71,14 @@ export function Scatterplot(_ref) {
|
|
|
66
71
|
values: []
|
|
67
72
|
});
|
|
68
73
|
const [coordsError, setCoordsError] = useState(null);
|
|
74
|
+
const [hasObsm, setHasObsm] = useState(true);
|
|
75
|
+
const [dataError, setDataError] = useState(null);
|
|
76
|
+
const selectedObs = useSelectedObs();
|
|
69
77
|
|
|
70
78
|
// EditableGeoJsonLayer
|
|
71
79
|
const [mode, setMode] = useState(() => ViewMode);
|
|
72
80
|
const [features, setFeatures] = useState({
|
|
73
|
-
type:
|
|
81
|
+
type: 'FeatureCollection',
|
|
74
82
|
features: settings.polygons[settings.selectedObsm] || []
|
|
75
83
|
});
|
|
76
84
|
const [selectedFeatureIndexes, setSelectedFeatureIndexes] = useState([]);
|
|
@@ -99,13 +107,25 @@ export function Scatterplot(_ref) {
|
|
|
99
107
|
setData(d => {
|
|
100
108
|
let values = d.values;
|
|
101
109
|
if (settings.colorEncoding === COLOR_ENCODINGS.VAR) {
|
|
102
|
-
|
|
110
|
+
if (!xData.serverError) {
|
|
111
|
+
values = xData.data;
|
|
112
|
+
setDataError(null);
|
|
113
|
+
} else {
|
|
114
|
+
values = [];
|
|
115
|
+
setDataError(xData.serverError);
|
|
116
|
+
}
|
|
103
117
|
} else if (settings.colorEncoding === COLOR_ENCODINGS.OBS) {
|
|
104
|
-
|
|
118
|
+
if (!obsData.serverError) {
|
|
119
|
+
values = obsData.data;
|
|
120
|
+
setDataError(null);
|
|
121
|
+
} else {
|
|
122
|
+
values = [];
|
|
123
|
+
setDataError(obsData.serverError);
|
|
124
|
+
}
|
|
105
125
|
}
|
|
106
126
|
if (!obsmData.serverError && obsmData.data) {
|
|
107
127
|
if (obsmData.data[0].length !== 2) {
|
|
108
|
-
setCoordsError(
|
|
128
|
+
setCoordsError('Invalid coordinates. Expected 2D coordinates');
|
|
109
129
|
return {
|
|
110
130
|
positions: [],
|
|
111
131
|
values: []
|
|
@@ -174,8 +194,7 @@ export function Scatterplot(_ref) {
|
|
|
174
194
|
getOriginalIndex,
|
|
175
195
|
sortedIndexMap
|
|
176
196
|
} = useMemo(() => {
|
|
177
|
-
|
|
178
|
-
if ((settings.colorEncoding === COLOR_ENCODINGS.VAR || settings.colorEncoding === COLOR_ENCODINGS.OBS && ((_settings$selectedObs = settings.selectedObs) === null || _settings$selectedObs === void 0 ? void 0 : _settings$selectedObs.type) === OBS_TYPES.CONTINUOUS) && data.positions && data.values && data.positions.length === data.values.length) {
|
|
197
|
+
if ((settings.colorEncoding === COLOR_ENCODINGS.VAR || settings.colorEncoding === COLOR_ENCODINGS.OBS && (selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.type) === OBS_TYPES.CONTINUOUS) && data.positions && data.values && data.positions.length === data.values.length) {
|
|
179
198
|
const sortedIndices = _.map(data.values, (_v, i) => i).sort((a, b) => data.values[a] - data.values[b]);
|
|
180
199
|
const sortedIndexMap = new Map(_.map(sortedIndices, (originalIndex, sortedIndex) => [originalIndex, sortedIndex]));
|
|
181
200
|
return {
|
|
@@ -192,24 +211,17 @@ export function Scatterplot(_ref) {
|
|
|
192
211
|
// return original index
|
|
193
212
|
sortedIndexMap: identitySortedIndexMap // return original index
|
|
194
213
|
};
|
|
195
|
-
}, [data, identityGetOriginalIndex, identitySortedIndexMap,
|
|
214
|
+
}, [data, identityGetOriginalIndex, identitySortedIndexMap, selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.type, settings.colorEncoding]);
|
|
196
215
|
const sortedObsIndices = useMemo(() => {
|
|
197
216
|
return obsIndices ? new Set(Array.from(obsIndices, i => sortedIndexMap.get(i))) : obsIndices;
|
|
198
217
|
}, [obsIndices, sortedIndexMap]);
|
|
199
218
|
const isCategorical = useMemo(() => {
|
|
200
219
|
if (settings.colorEncoding === COLOR_ENCODINGS.OBS) {
|
|
201
|
-
|
|
202
|
-
return ((_settings$selectedObs3 = settings.selectedObs) === null || _settings$selectedObs3 === void 0 ? void 0 : _settings$selectedObs3.type) === OBS_TYPES.CATEGORICAL || ((_settings$selectedObs4 = settings.selectedObs) === null || _settings$selectedObs4 === void 0 ? void 0 : _settings$selectedObs4.type) === OBS_TYPES.BOOLEAN;
|
|
220
|
+
return (selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.type) === OBS_TYPES.CATEGORICAL || (selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.type) === OBS_TYPES.BOOLEAN;
|
|
203
221
|
} else {
|
|
204
222
|
return false;
|
|
205
223
|
}
|
|
206
|
-
}, [settings.colorEncoding,
|
|
207
|
-
useEffect(() => {
|
|
208
|
-
dispatch({
|
|
209
|
-
type: "set.controls.valueRange",
|
|
210
|
-
valueRange: [valueMin, valueMax]
|
|
211
|
-
});
|
|
212
|
-
}, [dispatch, valueMax, valueMin]);
|
|
224
|
+
}, [settings.colorEncoding, selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.type]);
|
|
213
225
|
const {
|
|
214
226
|
min,
|
|
215
227
|
max
|
|
@@ -218,7 +230,6 @@ export function Scatterplot(_ref) {
|
|
|
218
230
|
max: settings.controls.range[1] * (valueMax - valueMin) + valueMin
|
|
219
231
|
};
|
|
220
232
|
const getFillColor = useCallback((_d, _ref2) => {
|
|
221
|
-
var _settings$selectedObs6, _settings$selectedObs7;
|
|
222
233
|
let {
|
|
223
234
|
index
|
|
224
235
|
} = _ref2;
|
|
@@ -227,10 +238,10 @@ export function Scatterplot(_ref) {
|
|
|
227
238
|
value: (sortedData.values[index] - min) / (max - min),
|
|
228
239
|
categorical: isCategorical,
|
|
229
240
|
grayOut: grayOut
|
|
230
|
-
}, useUnsColors && settings.colorEncoding === COLOR_ENCODINGS.OBS &&
|
|
231
|
-
colorscale:
|
|
241
|
+
}, useUnsColors && settings.colorEncoding === COLOR_ENCODINGS.OBS && selectedObs !== null && selectedObs !== void 0 && selectedObs.colors ? {
|
|
242
|
+
colorscale: selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.colors
|
|
232
243
|
} : {})) || [0, 0, 0, 100];
|
|
233
|
-
}, [isPending, sortedObsIndices, getColor, sortedData.values, min, max, isCategorical, useUnsColors, settings.colorEncoding,
|
|
244
|
+
}, [isPending, sortedObsIndices, getColor, sortedData.values, min, max, isCategorical, useUnsColors, settings.colorEncoding, selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.colors]);
|
|
234
245
|
|
|
235
246
|
// @TODO: add support for pseudospatial hover to reflect in radius
|
|
236
247
|
const getRadius = useCallback((_d, _ref3) => {
|
|
@@ -242,7 +253,7 @@ export function Scatterplot(_ref) {
|
|
|
242
253
|
}, [sortedObsIndices]);
|
|
243
254
|
const memoizedLayers = useMemo(() => {
|
|
244
255
|
return [new ScatterplotLayer({
|
|
245
|
-
id:
|
|
256
|
+
id: 'cherita-layer-scatterplot',
|
|
246
257
|
pickable: true,
|
|
247
258
|
data: sortedData.positions,
|
|
248
259
|
radiusScale: radiusScale,
|
|
@@ -255,7 +266,7 @@ export function Scatterplot(_ref) {
|
|
|
255
266
|
getRadius: getRadius
|
|
256
267
|
}
|
|
257
268
|
}), new EditableGeoJsonLayer({
|
|
258
|
-
id:
|
|
269
|
+
id: 'cherita-layer-draw',
|
|
259
270
|
data: features,
|
|
260
271
|
mode: mode,
|
|
261
272
|
selectedFeatureIndexes,
|
|
@@ -267,7 +278,7 @@ export function Scatterplot(_ref) {
|
|
|
267
278
|
} = _ref4;
|
|
268
279
|
setFeatures(updatedData);
|
|
269
280
|
let updatedSelectedFeatureIndexes = selectedFeatureIndexes;
|
|
270
|
-
if (editType ===
|
|
281
|
+
if (editType === 'addFeature') {
|
|
271
282
|
const {
|
|
272
283
|
featureIndexes
|
|
273
284
|
} = editContext;
|
|
@@ -295,13 +306,13 @@ export function Scatterplot(_ref) {
|
|
|
295
306
|
var _features$features;
|
|
296
307
|
if (!(features !== null && features !== void 0 && (_features$features = features.features) !== null && _features$features !== void 0 && _features$features.length)) {
|
|
297
308
|
dispatch({
|
|
298
|
-
type:
|
|
309
|
+
type: 'disable.slice.polygons'
|
|
299
310
|
});
|
|
300
311
|
}
|
|
301
312
|
}, [dispatch, features === null || features === void 0 || (_features$features2 = features.features) === null || _features$features2 === void 0 ? void 0 : _features$features2.length]);
|
|
302
313
|
useEffect(() => {
|
|
303
314
|
dispatch({
|
|
304
|
-
type:
|
|
315
|
+
type: 'set.polygons',
|
|
305
316
|
obsm: settings.selectedObsm,
|
|
306
317
|
polygons: (features === null || features === void 0 ? void 0 : features.features) || []
|
|
307
318
|
});
|
|
@@ -311,7 +322,7 @@ export function Scatterplot(_ref) {
|
|
|
311
322
|
// don't change selection while editing
|
|
312
323
|
return;
|
|
313
324
|
}
|
|
314
|
-
setSelectedFeatureIndexes(f => info.object ? info.layer.id ===
|
|
325
|
+
setSelectedFeatureIndexes(f => info.object ? info.layer.id === 'cherita-layer-draw' ? [info.index] : f : []);
|
|
315
326
|
}
|
|
316
327
|
const getLabel = function (o, v) {
|
|
317
328
|
let isVar = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
@@ -326,13 +337,11 @@ export function Scatterplot(_ref) {
|
|
|
326
337
|
object,
|
|
327
338
|
index
|
|
328
339
|
} = _ref5;
|
|
329
|
-
if (!object || (object === null || object === void 0 ? void 0 : object.type) ===
|
|
340
|
+
if (!object || (object === null || object === void 0 ? void 0 : object.type) === 'Feature') return;
|
|
330
341
|
const text = [];
|
|
331
|
-
if (settings.colorEncoding === COLOR_ENCODINGS.OBS &&
|
|
332
|
-
name: settings.selectedObs.name
|
|
333
|
-
})) {
|
|
342
|
+
if (settings.colorEncoding === COLOR_ENCODINGS.OBS && selectedObs && !_.includes(settings.labelObs, selectedObs.name)) {
|
|
334
343
|
var _data$values;
|
|
335
|
-
text.push(getLabel(
|
|
344
|
+
text.push(getLabel(selectedObs, (_data$values = data.values) === null || _data$values === void 0 ? void 0 : _data$values[getOriginalIndex(index)]));
|
|
336
345
|
}
|
|
337
346
|
if (settings.colorEncoding === COLOR_ENCODINGS.VAR && settings.selectedVar) {
|
|
338
347
|
var _data$values2;
|
|
@@ -340,82 +349,102 @@ export function Scatterplot(_ref) {
|
|
|
340
349
|
}
|
|
341
350
|
if (settings.labelObs.length) {
|
|
342
351
|
text.push(..._.map(labelObsData.data, (v, k) => {
|
|
343
|
-
const labelObs =
|
|
352
|
+
const labelObs = settings.data.obs[k];
|
|
344
353
|
return getLabel(labelObs, v[getOriginalIndex(index)]);
|
|
345
354
|
}));
|
|
346
355
|
}
|
|
347
356
|
if (!text.length) return;
|
|
348
357
|
const grayOut = sortedObsIndices && !sortedObsIndices.has(index);
|
|
349
358
|
return {
|
|
350
|
-
text: text.length ? _.compact(text).join(
|
|
351
|
-
className: grayOut ?
|
|
359
|
+
text: text.length ? _.compact(text).join('\n') : null,
|
|
360
|
+
className: grayOut ? 'tooltip-grayout' : 'deck-tooltip',
|
|
352
361
|
style: !grayOut ? {
|
|
353
|
-
|
|
362
|
+
'border-left': "3px solid ".concat(rgbToHex(getFillColor(null, {
|
|
354
363
|
index
|
|
355
364
|
})))
|
|
356
365
|
} : {
|
|
357
|
-
|
|
366
|
+
'border-left': 'none'
|
|
358
367
|
}
|
|
359
368
|
};
|
|
360
369
|
};
|
|
361
|
-
const error = settings.selectedObsm && ((_obsmData$serverError = obsmData.serverError) === null || _obsmData$serverError === void 0 ? void 0 : _obsmData$serverError.length) ||
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
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
|
-
|
|
370
|
+
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;
|
|
371
|
+
if (!hasObsm) {
|
|
372
|
+
return /*#__PURE__*/_jsx(PlotAlert, {
|
|
373
|
+
variant: "info",
|
|
374
|
+
heading: "Scatterplot unavailable for this dataset",
|
|
375
|
+
plotType: plotType,
|
|
376
|
+
setPlotType: setPlotType,
|
|
377
|
+
children: "This dataset does not include any embeddings, so a scatterplot cannot be displayed. Please choose a different plot type to explore the data."
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
return /*#__PURE__*/_jsx("div", {
|
|
381
|
+
className: "cherita-container-scatterplot",
|
|
382
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
383
|
+
className: "cherita-scatterplot",
|
|
384
|
+
children: [obsmData.isPending && /*#__PURE__*/_jsx(LoadingSpinner, {
|
|
385
|
+
disableShrink: true
|
|
386
|
+
}), isPending && /*#__PURE__*/_jsx(LoadingLinear, {}), /*#__PURE__*/_jsx(DeckGL, {
|
|
387
|
+
viewState: viewState,
|
|
388
|
+
onViewStateChange: e => setViewState(e.viewState),
|
|
389
|
+
controller: {
|
|
390
|
+
doubleClickZoom: mode === ViewMode
|
|
391
|
+
},
|
|
392
|
+
layers: layers,
|
|
393
|
+
onClick: onLayerClick,
|
|
394
|
+
getTooltip: getTooltip,
|
|
395
|
+
onAfterRender: () => {
|
|
396
|
+
setIsRendering(false);
|
|
397
|
+
},
|
|
398
|
+
useDevicePixels: false,
|
|
399
|
+
getCursor: _ref6 => {
|
|
400
|
+
let {
|
|
401
|
+
isDragging
|
|
402
|
+
} = _ref6;
|
|
403
|
+
return mode !== ViewMode ? 'crosshair' : isDragging ? 'grabbing' : 'grab';
|
|
404
|
+
},
|
|
405
|
+
ref: deckRef
|
|
406
|
+
}), /*#__PURE__*/_jsx(SpatialControls, {
|
|
407
|
+
mode: mode,
|
|
408
|
+
setMode: setMode,
|
|
409
|
+
features: features,
|
|
410
|
+
setFeatures: setFeatures,
|
|
411
|
+
selectedFeatureIndexes: selectedFeatureIndexes,
|
|
412
|
+
resetBounds: () => setViewState(getBounds()),
|
|
413
|
+
increaseZoom: () => setViewState(v => _objectSpread(_objectSpread({}, v), {}, {
|
|
414
|
+
zoom: v.zoom + 1
|
|
415
|
+
})),
|
|
416
|
+
decreaseZoom: () => setViewState(v => _objectSpread(_objectSpread({}, v), {}, {
|
|
417
|
+
zoom: v.zoom - 1
|
|
418
|
+
})),
|
|
419
|
+
setShowObs: setShowObs,
|
|
420
|
+
setShowVars: setShowVars,
|
|
421
|
+
isFullscreen: isFullscreen
|
|
422
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
423
|
+
className: "cherita-spatial-footer",
|
|
424
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
425
|
+
className: "cherita-toolbox-footer",
|
|
426
|
+
children: [!!error && !isRendering && /*#__PURE__*/_jsxs(Alert, {
|
|
427
|
+
variant: "danger",
|
|
428
|
+
children: [/*#__PURE__*/_jsxs(Alert.Heading, {
|
|
429
|
+
children: [/*#__PURE__*/_jsx(FontAwesomeIcon, {
|
|
430
|
+
icon: faTriangleExclamation
|
|
431
|
+
}), "\xA0Error loading data"]
|
|
432
|
+
}), /*#__PURE__*/_jsx("p", {
|
|
433
|
+
className: "mb-0",
|
|
434
|
+
children: error.message
|
|
435
|
+
})]
|
|
436
|
+
}), /*#__PURE__*/_jsx(Toolbox, {
|
|
437
|
+
mode: settings.colorEncoding === COLOR_ENCODINGS.VAR ? (_settings$selectedVar = settings.selectedVar) === null || _settings$selectedVar === void 0 ? void 0 : _settings$selectedVar.name : settings.colorEncoding === COLOR_ENCODINGS.OBS ? selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.name : null,
|
|
438
|
+
obsLength: parseInt((_data$positions = data.positions) === null || _data$positions === void 0 ? void 0 : _data$positions.length),
|
|
439
|
+
slicedLength: parseInt(slicedLength),
|
|
440
|
+
setHasObsm: setHasObsm
|
|
441
|
+
})]
|
|
442
|
+
}), !error && /*#__PURE__*/_jsx(Legend, {
|
|
443
|
+
isCategorical: isCategorical,
|
|
444
|
+
min: min,
|
|
445
|
+
max: max
|
|
446
|
+
})]
|
|
447
|
+
})]
|
|
448
|
+
})
|
|
449
|
+
});
|
|
421
450
|
}
|
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Box, Slider, Typography } from
|
|
3
|
-
import { Form } from
|
|
4
|
-
import { COLOR_ENCODINGS, OBS_TYPES } from
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import { Box, Slider, Typography } from '@mui/material';
|
|
3
|
+
import { Form } from 'react-bootstrap';
|
|
4
|
+
import { COLOR_ENCODINGS, OBS_TYPES } from '../../constants/constants';
|
|
5
|
+
import { useFilteredData } from '../../context/FilterContext';
|
|
6
|
+
import { useSettings, useSettingsDispatch } from '../../context/SettingsContext';
|
|
7
|
+
import { useSelectedObs } from '../../utils/Resolver';
|
|
8
|
+
import { ColorscaleSelect } from '../controls/Controls';
|
|
9
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
7
10
|
export const ScatterplotControls = () => {
|
|
8
|
-
var _settings$selectedObs;
|
|
9
11
|
const settings = useSettings();
|
|
10
12
|
const dispatch = useSettingsDispatch();
|
|
11
|
-
const [sliderValue, setSliderValue] =
|
|
12
|
-
const
|
|
13
|
+
const [sliderValue, setSliderValue] = useState(settings.controls.range || [0, 1]);
|
|
14
|
+
const {
|
|
15
|
+
valueMin,
|
|
16
|
+
valueMax
|
|
17
|
+
} = useFilteredData();
|
|
18
|
+
const selectedObs = useSelectedObs();
|
|
19
|
+
const isCategorical = settings.colorEncoding === COLOR_ENCODINGS.OBS ? (selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.type) === OBS_TYPES.CATEGORICAL : false;
|
|
13
20
|
const valueLabelFormat = value => {
|
|
14
|
-
return (value * (
|
|
21
|
+
return (value * (valueMax - valueMin) + valueMin).toFixed(2);
|
|
15
22
|
};
|
|
16
23
|
const marks = [{
|
|
17
24
|
value: 0,
|
|
@@ -26,35 +33,43 @@ export const ScatterplotControls = () => {
|
|
|
26
33
|
const updateRange = (_e, value) => {
|
|
27
34
|
setSliderValue(value);
|
|
28
35
|
dispatch({
|
|
29
|
-
type:
|
|
36
|
+
type: 'set.controls.range',
|
|
30
37
|
range: sliderValue
|
|
31
38
|
});
|
|
32
39
|
};
|
|
33
40
|
useEffect(() => {
|
|
34
41
|
setSliderValue(settings.controls.range);
|
|
35
42
|
}, [settings.controls.range]);
|
|
36
|
-
const rangeSlider = /*#__PURE__*/
|
|
37
|
-
className: "w-100"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
43
|
+
const rangeSlider = /*#__PURE__*/_jsxs(Box, {
|
|
44
|
+
className: "w-100",
|
|
45
|
+
children: [/*#__PURE__*/_jsx(Typography, {
|
|
46
|
+
id: "colorscale-range",
|
|
47
|
+
gutterBottom: true,
|
|
48
|
+
children: "Colorscale range"
|
|
49
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
50
|
+
className: "px-4",
|
|
51
|
+
children: /*#__PURE__*/_jsx(Slider, {
|
|
52
|
+
"aria-labelledby": "colorscale-range",
|
|
53
|
+
min: 0,
|
|
54
|
+
max: 1,
|
|
55
|
+
step: 0.001,
|
|
56
|
+
value: sliderValue,
|
|
57
|
+
onChange: updateSlider,
|
|
58
|
+
onChangeCommitted: updateRange,
|
|
59
|
+
valueLabelDisplay: "auto",
|
|
60
|
+
getAriaValueText: valueLabelFormat,
|
|
61
|
+
valueLabelFormat: valueLabelFormat,
|
|
62
|
+
marks: marks,
|
|
63
|
+
disabled: isCategorical
|
|
64
|
+
})
|
|
65
|
+
})]
|
|
66
|
+
});
|
|
67
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
68
|
+
children: /*#__PURE__*/_jsxs(Form, {
|
|
69
|
+
children: [/*#__PURE__*/_jsx(ColorscaleSelect, {}), /*#__PURE__*/_jsx(Form.Group, {
|
|
70
|
+
className: "mb-2",
|
|
71
|
+
children: rangeSlider
|
|
72
|
+
})]
|
|
73
|
+
})
|
|
74
|
+
});
|
|
60
75
|
};
|