@haniffalab/cherita-react 1.3.0-dev.2025-06-06.0b38976b → 1.3.0-dev.2025-06-06.c0b05a89

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.
@@ -155,8 +155,12 @@ function CategoricalItem(_ref) {
155
155
  pct: null
156
156
  },
157
157
  isSliced,
158
+ colors = null,
158
159
  showColor = true
159
160
  } = _ref;
161
+ const {
162
+ useUnsColors
163
+ } = (0, _DatasetContext.useDataset)();
160
164
  const {
161
165
  getColor
162
166
  } = (0, _colorHelper.useColor)();
@@ -241,7 +245,7 @@ function CategoricalItem(_ref) {
241
245
  y: "0",
242
246
  width: "10",
243
247
  height: "10",
244
- fill: "rgb(".concat(getColor({
248
+ fill: "rgb(".concat(getColor(_objectSpread({
245
249
  value: (code - min) / (max - min),
246
250
  categorical: true,
247
251
  grayOut: isOmitted,
@@ -249,7 +253,9 @@ function CategoricalItem(_ref) {
249
253
  alpha: 1
250
254
  },
251
255
  colorEncoding: "obs"
252
- }), ")")
256
+ }, useUnsColors ? {
257
+ colorscale: colors
258
+ } : {})), ")")
253
259
  }))) : null))));
254
260
  }
255
261
  function CategoricalObs(_ref2) {
@@ -291,9 +297,10 @@ function CategoricalObs(_ref2) {
291
297
  value_counts: (filteredObsData === null || filteredObsData === void 0 ? void 0 : filteredObsData.value_counts[obs.values[index]]) || 0,
292
298
  pct: (filteredObsData === null || filteredObsData === void 0 ? void 0 : filteredObsData.pct[obs.values[index]]) || 0
293
299
  },
294
- isSliced: isSliced
300
+ isSliced: isSliced,
301
+ colors: obs.colors
295
302
  };
296
- }, [settings.colorEncoding, filteredObsData === null || filteredObsData === void 0 ? void 0 : filteredObsData.pct, filteredObsData === null || filteredObsData === void 0 ? void 0 : filteredObsData.value_counts, isSliced, obs.codes, obs.omit, obs.value_counts, obs.values, obsHistograms.fetchedData, obsHistograms.isPending, totalCounts]);
303
+ }, [obs.values, obs.codes, obs.value_counts, obs.omit, obs.colors, totalCounts, settings.colorEncoding, obsHistograms.fetchedData, obsHistograms.isPending, isSliced, filteredObsData === null || filteredObsData === void 0 ? void 0 : filteredObsData.value_counts, filteredObsData === null || filteredObsData === void 0 ? void 0 : filteredObsData.pct]);
297
304
  showColor &= settings.colorEncoding === _constants.COLOR_ENCODINGS.OBS;
298
305
  return /*#__PURE__*/_react.default.createElement(_reactBootstrap.ListGroup, {
299
306
  variant: "flush",
@@ -16,6 +16,7 @@ var _reactBootstrap = require("react-bootstrap");
16
16
  var _SpatialControls = require("./SpatialControls");
17
17
  var _Toolbox = require("./Toolbox");
18
18
  var _constants = require("../../constants/constants");
19
+ var _DatasetContext = require("../../context/DatasetContext");
19
20
  var _FilterContext = require("../../context/FilterContext");
20
21
  var _SettingsContext = require("../../context/SettingsContext");
21
22
  var _ZarrDataContext = require("../../context/ZarrDataContext");
@@ -42,13 +43,16 @@ const INITIAL_VIEW_STATE = {
42
43
  bearing: 0
43
44
  };
44
45
  function Scatterplot(_ref) {
45
- var _settings$selectedObs2, _settings$selectedObs5, _features$features2, _obsmData$serverError, _xData$serverError, _obsData$serverError, _labelObsData$serverE, _settings$selectedVar, _settings$selectedObs6, _data$positions;
46
+ var _settings$selectedObs2, _settings$selectedObs5, _settings$selectedObs8, _features$features2, _obsmData$serverError, _xData$serverError, _obsData$serverError, _labelObsData$serverE, _settings$selectedVar, _settings$selectedObs9, _data$positions;
46
47
  let {
47
48
  radius = null,
48
49
  setShowObs,
49
50
  setShowVars,
50
51
  isFullscreen = false
51
52
  } = _ref;
53
+ const {
54
+ useUnsColors
55
+ } = (0, _DatasetContext.useDataset)();
52
56
  const settings = (0, _SettingsContext.useSettings)();
53
57
  const {
54
58
  obsIndices,
@@ -207,16 +211,19 @@ function Scatterplot(_ref) {
207
211
  max: settings.controls.range[1] * (valueMax - valueMin) + valueMin
208
212
  };
209
213
  const getFillColor = (0, _react.useCallback)((_d, _ref2) => {
214
+ var _settings$selectedObs6, _settings$selectedObs7;
210
215
  let {
211
216
  index
212
217
  } = _ref2;
213
218
  const grayOut = isPending || sortedObsIndices && !sortedObsIndices.has(index);
214
- return getColor({
219
+ return getColor(_objectSpread({
215
220
  value: (sortedData.values[index] - min) / (max - min),
216
221
  categorical: isCategorical,
217
222
  grayOut: grayOut
218
- }) || [0, 0, 0, 100];
219
- }, [isPending, sortedObsIndices, getColor, sortedData.values, min, max, isCategorical]);
223
+ }, useUnsColors && settings.colorEncoding === _constants.COLOR_ENCODINGS.OBS && (_settings$selectedObs6 = settings.selectedObs) !== null && _settings$selectedObs6 !== void 0 && _settings$selectedObs6.colors ? {
224
+ colorscale: (_settings$selectedObs7 = settings.selectedObs) === null || _settings$selectedObs7 === void 0 ? void 0 : _settings$selectedObs7.colors
225
+ } : {})) || [0, 0, 0, 100];
226
+ }, [isPending, sortedObsIndices, getColor, sortedData.values, min, max, isCategorical, useUnsColors, settings.colorEncoding, (_settings$selectedObs8 = settings.selectedObs) === null || _settings$selectedObs8 === void 0 ? void 0 : _settings$selectedObs8.colors]);
220
227
 
221
228
  // @TODO: add support for pseudospatial hover to reflect in radius
222
229
  const getRadius = (0, _react.useCallback)((_d, _ref3) => {
@@ -396,7 +403,7 @@ function Scatterplot(_ref) {
396
403
  }, /*#__PURE__*/_react.default.createElement(_reactFontawesome.FontAwesomeIcon, {
397
404
  icon: _freeSolidSvgIcons.faTriangleExclamation
398
405
  }), "\xA0Error loading data"), /*#__PURE__*/_react.default.createElement(_Toolbox.Toolbox, {
399
- 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 ? (_settings$selectedObs6 = settings.selectedObs) === null || _settings$selectedObs6 === void 0 ? void 0 : _settings$selectedObs6.name : null,
406
+ 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 ? (_settings$selectedObs9 = settings.selectedObs) === null || _settings$selectedObs9 === void 0 ? void 0 : _settings$selectedObs9.name : null,
400
407
  obsLength: parseInt((_data$positions = data.positions) === null || _data$positions === void 0 ? void 0 : _data$positions.length),
401
408
  slicedLength: parseInt(slicedLength)
402
409
  })), /*#__PURE__*/_react.default.createElement(_Legend.Legend, {
@@ -15,6 +15,7 @@ var _DatasetContext = require("../../context/DatasetContext");
15
15
  var _SettingsContext = require("../../context/SettingsContext");
16
16
  var _requests = require("../../utils/requests");
17
17
  var _VarItem = require("../var-list/VarItem");
18
+ var _VarList = require("../var-list/VarList");
18
19
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
19
20
  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); }
20
21
  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; }
@@ -52,39 +53,6 @@ function VarInfo(_ref) {
52
53
  data: fetchedData
53
54
  })));
54
55
  }
55
- const useVarMean = function (varKeys) {
56
- let enabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
57
- const ENDPOINT = "matrix/mean";
58
- const dataset = (0, _DatasetContext.useDataset)();
59
- const [params, setParams] = (0, _react.useState)({
60
- url: dataset.url,
61
- varKeys: _lodash.default.map(varKeys, v => v.isSet ? {
62
- name: v.name,
63
- indices: v.vars.map(v => v.index)
64
- } : v.index),
65
- // obsIndices:
66
- varNamesCol: dataset.varNamesCol
67
- });
68
- (0, _react.useEffect)(() => {
69
- setParams(p => {
70
- return _objectSpread(_objectSpread({}, p), {}, {
71
- varKeys: _lodash.default.map(varKeys, v => v.isSet ? {
72
- name: v.name,
73
- indices: v.vars.map(v => v.index)
74
- } : v.index)
75
- });
76
- });
77
- }, [varKeys]);
78
- return (0, _requests.useFetch)(ENDPOINT, params, {
79
- enabled: enabled,
80
- refetchOnMount: false
81
- });
82
- };
83
-
84
- // ensure nulls are lowest values
85
- const sortMeans = (i, means) => {
86
- return means[i.name] || _lodash.default.min(_lodash.default.values(means)) - 1;
87
- };
88
56
  function DiseaseInfo(_ref2) {
89
57
  let {
90
58
  disease,
@@ -119,12 +87,12 @@ function DiseaseInfo(_ref2) {
119
87
  setDiseaseVars(diseaseData.fetchedData);
120
88
  }
121
89
  }, [diseaseData.fetchedData, diseaseData.isPending, diseaseData.serverError]);
122
- const varMeans = useVarMean(diseaseVars, !!(diseaseVars !== null && diseaseVars !== void 0 && diseaseVars.length) && settings.varSort.disease.sort === _constants.VAR_SORT.MATRIX);
90
+ const varMeans = (0, _VarList.useVarMean)(diseaseVars, !!(diseaseVars !== null && diseaseVars !== void 0 && diseaseVars.length) && settings.varSort.disease.sort === _constants.VAR_SORT.MATRIX);
123
91
  (0, _react.useEffect)(() => {
124
92
  if (settings.varSort.disease.sort === _constants.VAR_SORT.MATRIX) {
125
93
  if (!varMeans.isPending && !varMeans.serverError) {
126
94
  setSortedDiseaseVars(_lodash.default.orderBy(diseaseVars, o => {
127
- return sortMeans(o, varMeans.fetchedData);
95
+ return (0, _VarList.sortMeans)(o, varMeans.fetchedData);
128
96
  }, settings.varSort.disease.sortOrder));
129
97
  }
130
98
  } else if (settings.varSort.disease.sort === _constants.VAR_SORT.NAME) {
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.VarNamesList = VarNamesList;
7
+ exports.useVarMean = exports.sortMeans = void 0;
7
8
  var _react = _interopRequireWildcard(require("react"));
8
9
  var _freeSolidSvgIcons = require("@fortawesome/free-solid-svg-icons");
9
10
  var _reactFontawesome = require("@fortawesome/react-fontawesome");
@@ -15,6 +16,7 @@ var _VarListToolbar = require("./VarListToolbar");
15
16
  var _VarSet = require("./VarSet");
16
17
  var _constants = require("../../constants/constants");
17
18
  var _DatasetContext = require("../../context/DatasetContext");
19
+ var _FilterContext = require("../../context/FilterContext");
18
20
  var _SettingsContext = require("../../context/SettingsContext");
19
21
  var _LoadingIndicators = require("../../utils/LoadingIndicators");
20
22
  var _requests = require("../../utils/requests");
@@ -29,13 +31,16 @@ const useVarMean = function (varKeys) {
29
31
  let enabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
30
32
  const ENDPOINT = "matrix/mean";
31
33
  const dataset = (0, _DatasetContext.useDataset)();
34
+ const {
35
+ obsIndices
36
+ } = (0, _FilterContext.useFilteredData)();
32
37
  const [params, setParams] = (0, _react.useState)({
33
38
  url: dataset.url,
34
39
  varKeys: _lodash.default.map(varKeys, v => v.isSet ? {
35
40
  name: v.name,
36
41
  indices: v.vars.map(v => v.index)
37
42
  } : v.index),
38
- // obsIndices:
43
+ obsIndices: obsIndices,
39
44
  varNamesCol: dataset.varNamesCol
40
45
  });
41
46
  (0, _react.useEffect)(() => {
@@ -44,10 +49,11 @@ const useVarMean = function (varKeys) {
44
49
  varKeys: _lodash.default.map(varKeys, v => v.isSet ? {
45
50
  name: v.name,
46
51
  indices: v.vars.map(v => v.index)
47
- } : v.index)
52
+ } : v.index),
53
+ obsIndices: obsIndices
48
54
  });
49
55
  });
50
- }, [varKeys]);
56
+ }, [obsIndices, varKeys]);
51
57
  return (0, _requests.useFetch)(ENDPOINT, params, {
52
58
  enabled: enabled,
53
59
  refetchOnMount: false
@@ -55,9 +61,11 @@ const useVarMean = function (varKeys) {
55
61
  };
56
62
 
57
63
  // ensure nulls are lowest values
64
+ exports.useVarMean = useVarMean;
58
65
  const sortMeans = (i, means) => {
59
66
  return means[i.name] || _lodash.default.min(_lodash.default.values(means)) - 1;
60
67
  };
68
+ exports.sortMeans = sortMeans;
61
69
  function VarNamesList(_ref) {
62
70
  var _settings$selectedVar, _settings$selectedVar2;
63
71
  let {
@@ -69,7 +69,8 @@ const initialDataset = {
69
69
  obsGroups: null,
70
70
  imageUrl: null,
71
71
  defaultSettings: {},
72
- canOverrideSettings: true
72
+ canOverrideSettings: true,
73
+ useUnsColors: false
73
74
  };
74
75
  function DatasetProvider(_ref2) {
75
76
  let {
@@ -147,8 +147,12 @@ function CategoricalItem(_ref) {
147
147
  pct: null
148
148
  },
149
149
  isSliced,
150
+ colors = null,
150
151
  showColor = true
151
152
  } = _ref;
153
+ const {
154
+ useUnsColors
155
+ } = useDataset();
152
156
  const {
153
157
  getColor
154
158
  } = useColor();
@@ -233,7 +237,7 @@ function CategoricalItem(_ref) {
233
237
  y: "0",
234
238
  width: "10",
235
239
  height: "10",
236
- fill: "rgb(".concat(getColor({
240
+ fill: "rgb(".concat(getColor(_objectSpread({
237
241
  value: (code - min) / (max - min),
238
242
  categorical: true,
239
243
  grayOut: isOmitted,
@@ -241,7 +245,9 @@ function CategoricalItem(_ref) {
241
245
  alpha: 1
242
246
  },
243
247
  colorEncoding: "obs"
244
- }), ")")
248
+ }, useUnsColors ? {
249
+ colorscale: colors
250
+ } : {})), ")")
245
251
  }))) : null))));
246
252
  }
247
253
  export function CategoricalObs(_ref2) {
@@ -283,9 +289,10 @@ export function CategoricalObs(_ref2) {
283
289
  value_counts: (filteredObsData === null || filteredObsData === void 0 ? void 0 : filteredObsData.value_counts[obs.values[index]]) || 0,
284
290
  pct: (filteredObsData === null || filteredObsData === void 0 ? void 0 : filteredObsData.pct[obs.values[index]]) || 0
285
291
  },
286
- isSliced: isSliced
292
+ isSliced: isSliced,
293
+ colors: obs.colors
287
294
  };
288
- }, [settings.colorEncoding, filteredObsData === null || filteredObsData === void 0 ? void 0 : filteredObsData.pct, filteredObsData === null || filteredObsData === void 0 ? void 0 : filteredObsData.value_counts, isSliced, obs.codes, obs.omit, obs.value_counts, obs.values, obsHistograms.fetchedData, obsHistograms.isPending, totalCounts]);
295
+ }, [obs.values, obs.codes, obs.value_counts, obs.omit, obs.colors, totalCounts, settings.colorEncoding, obsHistograms.fetchedData, obsHistograms.isPending, isSliced, filteredObsData === null || filteredObsData === void 0 ? void 0 : filteredObsData.value_counts, filteredObsData === null || filteredObsData === void 0 ? void 0 : filteredObsData.pct]);
289
296
  showColor &= settings.colorEncoding === COLOR_ENCODINGS.OBS;
290
297
  return /*#__PURE__*/React.createElement(ListGroup, {
291
298
  variant: "flush",
@@ -15,6 +15,7 @@ import { Alert } from "react-bootstrap";
15
15
  import { SpatialControls } from "./SpatialControls";
16
16
  import { Toolbox } from "./Toolbox";
17
17
  import { COLOR_ENCODINGS, OBS_TYPES, SELECTED_POLYGON_FILLCOLOR, UNSELECTED_POLYGON_FILLCOLOR } from "../../constants/constants";
18
+ import { useDataset } from "../../context/DatasetContext";
18
19
  import { useFilteredData } from "../../context/FilterContext";
19
20
  import { useSettings, useSettingsDispatch } from "../../context/SettingsContext";
20
21
  import { useZarrData } from "../../context/ZarrDataContext";
@@ -34,13 +35,16 @@ const INITIAL_VIEW_STATE = {
34
35
  bearing: 0
35
36
  };
36
37
  export function Scatterplot(_ref) {
37
- var _settings$selectedObs2, _settings$selectedObs5, _features$features2, _obsmData$serverError, _xData$serverError, _obsData$serverError, _labelObsData$serverE, _settings$selectedVar, _settings$selectedObs6, _data$positions;
38
+ var _settings$selectedObs2, _settings$selectedObs5, _settings$selectedObs8, _features$features2, _obsmData$serverError, _xData$serverError, _obsData$serverError, _labelObsData$serverE, _settings$selectedVar, _settings$selectedObs9, _data$positions;
38
39
  let {
39
40
  radius = null,
40
41
  setShowObs,
41
42
  setShowVars,
42
43
  isFullscreen = false
43
44
  } = _ref;
45
+ const {
46
+ useUnsColors
47
+ } = useDataset();
44
48
  const settings = useSettings();
45
49
  const {
46
50
  obsIndices,
@@ -199,16 +203,19 @@ export function Scatterplot(_ref) {
199
203
  max: settings.controls.range[1] * (valueMax - valueMin) + valueMin
200
204
  };
201
205
  const getFillColor = useCallback((_d, _ref2) => {
206
+ var _settings$selectedObs6, _settings$selectedObs7;
202
207
  let {
203
208
  index
204
209
  } = _ref2;
205
210
  const grayOut = isPending || sortedObsIndices && !sortedObsIndices.has(index);
206
- return getColor({
211
+ return getColor(_objectSpread({
207
212
  value: (sortedData.values[index] - min) / (max - min),
208
213
  categorical: isCategorical,
209
214
  grayOut: grayOut
210
- }) || [0, 0, 0, 100];
211
- }, [isPending, sortedObsIndices, getColor, sortedData.values, min, max, isCategorical]);
215
+ }, useUnsColors && settings.colorEncoding === COLOR_ENCODINGS.OBS && (_settings$selectedObs6 = settings.selectedObs) !== null && _settings$selectedObs6 !== void 0 && _settings$selectedObs6.colors ? {
216
+ colorscale: (_settings$selectedObs7 = settings.selectedObs) === null || _settings$selectedObs7 === void 0 ? void 0 : _settings$selectedObs7.colors
217
+ } : {})) || [0, 0, 0, 100];
218
+ }, [isPending, sortedObsIndices, getColor, sortedData.values, min, max, isCategorical, useUnsColors, settings.colorEncoding, (_settings$selectedObs8 = settings.selectedObs) === null || _settings$selectedObs8 === void 0 ? void 0 : _settings$selectedObs8.colors]);
212
219
 
213
220
  // @TODO: add support for pseudospatial hover to reflect in radius
214
221
  const getRadius = useCallback((_d, _ref3) => {
@@ -388,7 +395,7 @@ export function Scatterplot(_ref) {
388
395
  }, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
389
396
  icon: faTriangleExclamation
390
397
  }), "\xA0Error loading data"), /*#__PURE__*/React.createElement(Toolbox, {
391
- 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 ? (_settings$selectedObs6 = settings.selectedObs) === null || _settings$selectedObs6 === void 0 ? void 0 : _settings$selectedObs6.name : null,
398
+ 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 ? (_settings$selectedObs9 = settings.selectedObs) === null || _settings$selectedObs9 === void 0 ? void 0 : _settings$selectedObs9.name : null,
392
399
  obsLength: parseInt((_data$positions = data.positions) === null || _data$positions === void 0 ? void 0 : _data$positions.length),
393
400
  slicedLength: parseInt(slicedLength)
394
401
  })), /*#__PURE__*/React.createElement(Legend, {
@@ -13,6 +13,7 @@ import { useDataset } from "../../context/DatasetContext";
13
13
  import { useSettings, useSettingsDispatch } from "../../context/SettingsContext";
14
14
  import { useFetch } from "../../utils/requests";
15
15
  import { VarDiseaseInfo } from "../var-list/VarItem";
16
+ import { sortMeans, useVarMean } from "../var-list/VarList";
16
17
  export function VarInfo(_ref) {
17
18
  let {
18
19
  varItem
@@ -43,39 +44,6 @@ export function VarInfo(_ref) {
43
44
  data: fetchedData
44
45
  })));
45
46
  }
46
- const useVarMean = function (varKeys) {
47
- let enabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
48
- const ENDPOINT = "matrix/mean";
49
- const dataset = useDataset();
50
- const [params, setParams] = useState({
51
- url: dataset.url,
52
- varKeys: _.map(varKeys, v => v.isSet ? {
53
- name: v.name,
54
- indices: v.vars.map(v => v.index)
55
- } : v.index),
56
- // obsIndices:
57
- varNamesCol: dataset.varNamesCol
58
- });
59
- useEffect(() => {
60
- setParams(p => {
61
- return _objectSpread(_objectSpread({}, p), {}, {
62
- varKeys: _.map(varKeys, v => v.isSet ? {
63
- name: v.name,
64
- indices: v.vars.map(v => v.index)
65
- } : v.index)
66
- });
67
- });
68
- }, [varKeys]);
69
- return useFetch(ENDPOINT, params, {
70
- enabled: enabled,
71
- refetchOnMount: false
72
- });
73
- };
74
-
75
- // ensure nulls are lowest values
76
- const sortMeans = (i, means) => {
77
- return means[i.name] || _.min(_.values(means)) - 1;
78
- };
79
47
  export function DiseaseInfo(_ref2) {
80
48
  let {
81
49
  disease,
@@ -14,20 +14,24 @@ import { VarListToolbar } from "./VarListToolbar";
14
14
  import { VarSet } from "./VarSet";
15
15
  import { SELECTION_MODES, VAR_SORT } from "../../constants/constants";
16
16
  import { useDataset } from "../../context/DatasetContext";
17
+ import { useFilteredData } from "../../context/FilterContext";
17
18
  import { useSettings, useSettingsDispatch } from "../../context/SettingsContext";
18
19
  import { LoadingSpinner } from "../../utils/LoadingIndicators";
19
20
  import { useFetch } from "../../utils/requests";
20
- const useVarMean = function (varKeys) {
21
+ export const useVarMean = function (varKeys) {
21
22
  let enabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
22
23
  const ENDPOINT = "matrix/mean";
23
24
  const dataset = useDataset();
25
+ const {
26
+ obsIndices
27
+ } = useFilteredData();
24
28
  const [params, setParams] = useState({
25
29
  url: dataset.url,
26
30
  varKeys: _.map(varKeys, v => v.isSet ? {
27
31
  name: v.name,
28
32
  indices: v.vars.map(v => v.index)
29
33
  } : v.index),
30
- // obsIndices:
34
+ obsIndices: obsIndices,
31
35
  varNamesCol: dataset.varNamesCol
32
36
  });
33
37
  useEffect(() => {
@@ -36,10 +40,11 @@ const useVarMean = function (varKeys) {
36
40
  varKeys: _.map(varKeys, v => v.isSet ? {
37
41
  name: v.name,
38
42
  indices: v.vars.map(v => v.index)
39
- } : v.index)
43
+ } : v.index),
44
+ obsIndices: obsIndices
40
45
  });
41
46
  });
42
- }, [varKeys]);
47
+ }, [obsIndices, varKeys]);
43
48
  return useFetch(ENDPOINT, params, {
44
49
  enabled: enabled,
45
50
  refetchOnMount: false
@@ -47,7 +52,7 @@ const useVarMean = function (varKeys) {
47
52
  };
48
53
 
49
54
  // ensure nulls are lowest values
50
- const sortMeans = (i, means) => {
55
+ export const sortMeans = (i, means) => {
51
56
  return means[i.name] || _.min(_.values(means)) - 1;
52
57
  };
53
58
  export function VarNamesList(_ref) {
@@ -59,7 +59,8 @@ const initialDataset = {
59
59
  obsGroups: null,
60
60
  imageUrl: null,
61
61
  defaultSettings: {},
62
- canOverrideSettings: true
62
+ canOverrideSettings: true,
63
+ useUnsColors: false
63
64
  };
64
65
  export function DatasetProvider(_ref2) {
65
66
  let {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haniffalab/cherita-react",
3
- "version": "1.3.0-dev.2025-06-06.0b38976b",
3
+ "version": "1.3.0-dev.2025-06-06.c0b05a89",
4
4
  "author": "Haniffa Lab",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -127,5 +127,5 @@
127
127
  "url": "https://github.com/haniffalab/cherita-react/issues"
128
128
  },
129
129
  "homepage": "https://github.com/haniffalab/cherita-react#readme",
130
- "prereleaseSha": "0b38976bfa4499c6f24545ed2f278f078633d27b"
130
+ "prereleaseSha": "c0b05a895b3e582b1719870cbd23b084095c36de"
131
131
  }