@haniffalab/cherita-react 1.4.1-dev.2025-10-23.3179e534 → 1.4.1-dev.2025-10-23.55fbe6ff

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.
Files changed (126) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/components/controls/Controls.js +4 -4
  3. package/dist/cjs/components/dotplot/Dotplot.js +15 -28
  4. package/dist/cjs/components/dotplot/DotplotControls.js +5 -5
  5. package/dist/cjs/components/full-page/FullPage.js +1 -2
  6. package/dist/cjs/components/full-page/PlotAlert.js +1 -1
  7. package/dist/cjs/components/full-page/PlotTypeSelector.js +13 -13
  8. package/dist/cjs/components/heatmap/Heatmap.js +14 -24
  9. package/dist/cjs/components/icons/DotPlotIcon.js +1 -1
  10. package/dist/cjs/components/icons/HeatmapIcon.js +1 -1
  11. package/dist/cjs/components/icons/MatrixPlotIcon.1.js +1 -1
  12. package/dist/cjs/components/icons/MatrixPlotIcon.js +1 -1
  13. package/dist/cjs/components/icons/ScatterplotIcon.1.js +1 -1
  14. package/dist/cjs/components/icons/ScatterplotIcon.js +1 -1
  15. package/dist/cjs/components/icons/ViolinPlotIcon.js +1 -1
  16. package/dist/cjs/components/matrixplot/Matrixplot.js +15 -26
  17. package/dist/cjs/components/obs-list/ObsItem.js +19 -19
  18. package/dist/cjs/components/obs-list/ObsList.js +17 -17
  19. package/dist/cjs/components/obsm-list/ObsmList.js +7 -7
  20. package/dist/cjs/components/pseudospatial/Pseudospatial.js +16 -16
  21. package/dist/cjs/components/pseudospatial/PseudospatialToolbar.js +10 -10
  22. package/dist/cjs/components/scatterplot/Scatterplot.js +16 -16
  23. package/dist/cjs/components/scatterplot/ScatterplotControls.js +1 -1
  24. package/dist/cjs/components/scatterplot/SpatialControls.js +9 -9
  25. package/dist/cjs/components/scatterplot/Toolbox.js +4 -4
  26. package/dist/cjs/components/search-bar/SearchBar.js +14 -14
  27. package/dist/cjs/components/search-bar/SearchInfo.js +3 -3
  28. package/dist/cjs/components/search-bar/SearchResults.js +2 -2
  29. package/dist/cjs/components/toolbar/Toolbar.js +3 -3
  30. package/dist/cjs/components/var-list/VarItem.js +15 -15
  31. package/dist/cjs/components/var-list/VarList.js +5 -5
  32. package/dist/cjs/components/var-list/VarListToolbar.js +4 -4
  33. package/dist/cjs/components/var-list/VarSet.js +13 -13
  34. package/dist/cjs/components/violin/Violin.js +17 -41
  35. package/dist/cjs/constants/colorscales.js +19 -19
  36. package/dist/cjs/constants/constants.js +47 -47
  37. package/dist/cjs/context/DatasetContext.js +3 -3
  38. package/dist/cjs/context/FilterContext.js +2 -2
  39. package/dist/cjs/context/SettingsContext.js +57 -57
  40. package/dist/cjs/helpers/color-helper.js +2 -2
  41. package/dist/cjs/helpers/zarr-helper.js +3 -3
  42. package/dist/cjs/utils/Filter.js +1 -1
  43. package/dist/cjs/utils/Histogram.js +2 -2
  44. package/dist/cjs/utils/ImageViewer.js +2 -2
  45. package/dist/cjs/utils/Legend.js +1 -1
  46. package/dist/cjs/utils/LoadingIndicators.js +1 -1
  47. package/dist/cjs/utils/Resolver.js +7 -7
  48. package/dist/cjs/utils/Skeleton.js +1 -1
  49. package/dist/cjs/utils/StyledTooltip.js +5 -5
  50. package/dist/cjs/utils/VirtualizedList.js +7 -7
  51. package/dist/cjs/utils/errors.js +15 -15
  52. package/dist/cjs/utils/requests.js +14 -10
  53. package/dist/cjs/utils/search.js +4 -4
  54. package/dist/cjs/utils/string.js +6 -6
  55. package/dist/cjs/utils/zarrData.js +5 -5
  56. package/dist/css/cherita.css +21 -20
  57. package/dist/css/cherita.css.map +1 -1
  58. package/dist/esm/components/controls/Controls.js +9 -9
  59. package/dist/esm/components/dotplot/Dotplot.js +28 -41
  60. package/dist/esm/components/dotplot/DotplotControls.js +9 -9
  61. package/dist/esm/components/full-page/FullPage.js +22 -23
  62. package/dist/esm/components/full-page/PlotAlert.js +5 -5
  63. package/dist/esm/components/full-page/PlotTypeSelector.js +21 -21
  64. package/dist/esm/components/heatmap/Heatmap.js +27 -37
  65. package/dist/esm/components/heatmap/HeatmapControls.js +2 -2
  66. package/dist/esm/components/icons/DotPlotIcon.js +1 -1
  67. package/dist/esm/components/icons/HeatmapIcon.js +1 -1
  68. package/dist/esm/components/icons/MatrixPlotIcon.1.js +1 -1
  69. package/dist/esm/components/icons/MatrixPlotIcon.js +1 -1
  70. package/dist/esm/components/icons/ScatterplotIcon.1.js +1 -1
  71. package/dist/esm/components/icons/ScatterplotIcon.js +1 -1
  72. package/dist/esm/components/icons/ViolinPlotIcon.js +1 -1
  73. package/dist/esm/components/matrixplot/Matrixplot.js +28 -39
  74. package/dist/esm/components/matrixplot/MatrixplotControls.js +2 -2
  75. package/dist/esm/components/obs-list/ObsItem.js +37 -37
  76. package/dist/esm/components/obs-list/ObsList.js +34 -34
  77. package/dist/esm/components/obs-list/ObsToolbar.js +1 -1
  78. package/dist/esm/components/obsm-list/ObsmList.js +15 -15
  79. package/dist/esm/components/offcanvas/index.js +6 -6
  80. package/dist/esm/components/pseudospatial/Pseudospatial.js +31 -31
  81. package/dist/esm/components/pseudospatial/PseudospatialToolbar.js +17 -17
  82. package/dist/esm/components/scatterplot/Scatterplot.js +38 -38
  83. package/dist/esm/components/scatterplot/ScatterplotControls.js +9 -9
  84. package/dist/esm/components/scatterplot/SpatialControls.js +23 -23
  85. package/dist/esm/components/scatterplot/Toolbox.js +7 -7
  86. package/dist/esm/components/search-bar/SearchBar.js +27 -27
  87. package/dist/esm/components/search-bar/SearchInfo.js +14 -14
  88. package/dist/esm/components/search-bar/SearchResults.js +10 -10
  89. package/dist/esm/components/toolbar/Toolbar.js +6 -6
  90. package/dist/esm/components/var-list/VarItem.js +27 -27
  91. package/dist/esm/components/var-list/VarList.js +21 -21
  92. package/dist/esm/components/var-list/VarListToolbar.js +10 -10
  93. package/dist/esm/components/var-list/VarSet.js +22 -22
  94. package/dist/esm/components/violin/Violin.js +33 -57
  95. package/dist/esm/components/violin/ViolinControls.js +2 -2
  96. package/dist/esm/constants/colorscales.js +19 -19
  97. package/dist/esm/constants/constants.js +47 -47
  98. package/dist/esm/context/DatasetContext.js +11 -11
  99. package/dist/esm/context/FilterContext.js +3 -3
  100. package/dist/esm/context/SettingsContext.js +61 -61
  101. package/dist/esm/context/ZarrDataContext.js +3 -3
  102. package/dist/esm/helpers/color-helper.js +5 -5
  103. package/dist/esm/helpers/map-helper.js +2 -2
  104. package/dist/esm/helpers/zarr-helper.js +6 -6
  105. package/dist/esm/index.js +22 -22
  106. package/dist/esm/utils/Filter.js +8 -8
  107. package/dist/esm/utils/Histogram.js +6 -6
  108. package/dist/esm/utils/ImageViewer.js +4 -4
  109. package/dist/esm/utils/Legend.js +9 -9
  110. package/dist/esm/utils/LoadingIndicators.js +2 -2
  111. package/dist/esm/utils/Resolver.js +13 -13
  112. package/dist/esm/utils/Skeleton.js +2 -2
  113. package/dist/esm/utils/StyledTooltip.js +6 -6
  114. package/dist/esm/utils/VirtualizedList.js +9 -9
  115. package/dist/esm/utils/errors.js +15 -15
  116. package/dist/esm/utils/requests.js +17 -13
  117. package/dist/esm/utils/search.js +7 -7
  118. package/dist/esm/utils/string.js +7 -7
  119. package/dist/esm/utils/zarrData.js +13 -13
  120. package/package.json +11 -7
  121. package/scss/cherita-bootstrap.scss +2 -2
  122. package/scss/cherita.scss +24 -17
  123. package/scss/components/accordions.scss +4 -1
  124. package/scss/components/layouts.scss +13 -12
  125. package/scss/components/lists.scss +8 -4
  126. package/scss/components/plotly.scss +1 -0
package/README.md CHANGED
@@ -21,7 +21,7 @@ Install packages
21
21
  npm i
22
22
  ```
23
23
 
24
- Create a ``.env`` file within ``sites/demo`` to store environment variables for Vite to use. Within it set ``REACT_APP_API_URL`` to the backend API url like
24
+ Create a `.env` file within `sites/demo` to store environment variables for Vite to use. Within it set `REACT_APP_API_URL` to the backend API url like
25
25
 
26
26
  ```sh
27
27
  REACT_APP_API_URL=http://localhost:5000/api/
@@ -22,7 +22,7 @@ const ColorscaleSelect = () => {
22
22
  value: settings.controls.colorScale,
23
23
  onChange: e => {
24
24
  dispatch({
25
- type: "set.controls.colorScale",
25
+ type: 'set.controls.colorScale',
26
26
  colorScale: e.target.value
27
27
  });
28
28
  },
@@ -50,16 +50,16 @@ const ScaleSelect = _ref => {
50
50
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Form.Label, {
51
51
  children: "Standard scale"
52
52
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Form.Select, {
53
- value: settings.controls.scale[plot] || "",
53
+ value: settings.controls.scale[plot] || '',
54
54
  onChange: e => {
55
55
  dispatch({
56
- type: "set.controls.scale",
56
+ type: 'set.controls.scale',
57
57
  plot: plot,
58
58
  scale: !e.target.value.length ? null : e.target.value
59
59
  });
60
60
  },
61
61
  children: _lodash.default.values(SCALES[plot]).map(scale => /*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
62
- value: scale.value || "",
62
+ value: scale.value || '',
63
63
  children: scale.name
64
64
  }, scale.value))
65
65
  })]
@@ -35,7 +35,7 @@ function Dotplot(_ref) {
35
35
  plotType,
36
36
  setPlotType
37
37
  } = _ref;
38
- const ENDPOINT = "dotplot";
38
+ const ENDPOINT = 'dotplot';
39
39
  const dataset = (0, _DatasetContext.useDataset)();
40
40
  const settings = (0, _SettingsContext.useSettings)();
41
41
  const {
@@ -49,7 +49,7 @@ function Dotplot(_ref) {
49
49
  const [hasSelections, setHasSelections] = (0, _react.useState)(false);
50
50
  const selectedObs = (0, _Resolver.useSelectedObs)();
51
51
  const selectedMultiVar = (0, _Resolver.useSelectedMultiVar)();
52
- const [params, setParams] = (0, _react.useState)({
52
+ const params = (0, _react.useMemo)(() => ({
53
53
  url: dataset.url,
54
54
  obsCol: selectedObs,
55
55
  obsValues: !(selectedObs !== null && selectedObs !== void 0 && selectedObs.omit.length) ? null : _lodash.default.difference(selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.values, selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.omit),
@@ -62,7 +62,7 @@ function Dotplot(_ref) {
62
62
  meanOnlyExpressed: settings.controls.meanOnlyExpressed,
63
63
  expressionCutoff: settings.controls.expressionCutoff,
64
64
  varNamesCol: dataset.varNamesCol
65
- });
65
+ }), [dataset.url, dataset.varNamesCol, isSliced, obsIndices, selectedMultiVar, selectedObs, settings.controls.expressionCutoff, settings.controls.meanOnlyExpressed, settings.controls.scale.dotplot]);
66
66
  // @TODO: set default scale
67
67
 
68
68
  (0, _react.useEffect)(() => {
@@ -71,22 +71,6 @@ function Dotplot(_ref) {
71
71
  } else {
72
72
  setHasSelections(false);
73
73
  }
74
- setParams(p => {
75
- return _objectSpread(_objectSpread({}, p), {}, {
76
- url: dataset.url,
77
- obsCol: selectedObs,
78
- obsValues: !(selectedObs !== null && selectedObs !== void 0 && selectedObs.omit.length) ? null : _lodash.default.difference(selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.values, selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.omit),
79
- varKeys: selectedMultiVar.map(i => i.isSet ? {
80
- name: i.name,
81
- indices: i.vars.map(v => v.index)
82
- } : i.index),
83
- obsIndices: isSliced ? [...(obsIndices || [])] : null,
84
- standardScale: settings.controls.scale.dotplot,
85
- meanOnlyExpressed: settings.controls.meanOnlyExpressed,
86
- expressionCutoff: settings.controls.expressionCutoff,
87
- varNamesCol: dataset.varNamesCol
88
- });
89
- });
90
74
  }, [dataset.url, selectedObs, settings.controls.scale.dotplot, settings.controls.meanOnlyExpressed, settings.controls.expressionCutoff, dataset.varNamesCol, isSliced, obsIndices, selectedMultiVar]);
91
75
  const updateColorscale = (0, _react.useCallback)(colorscale => {
92
76
  setLayout(l => {
@@ -102,15 +86,15 @@ function Dotplot(_ref) {
102
86
  isPending,
103
87
  serverError
104
88
  } = (0, _requests.useDebouncedFetch)(ENDPOINT, params, 500, {
105
- enabled: !!params.obsCol && !!params.varKeys.length
89
+ isEnabled: params => !!params.obsCol && !!params.varKeys.length
106
90
  });
107
91
  (0, _react.useEffect)(() => {
108
- if (hasSelections && !isPending && !serverError) {
92
+ if (hasSelections && !!fetchedData && !isPending && !serverError) {
109
93
  setData(fetchedData.data);
110
94
  setLayout(fetchedData.layout);
111
95
  // @TODO: keep colorAxis range from settings
112
96
  dispatch({
113
- type: "set.controls.colorAxis",
97
+ type: 'set.controls.colorAxis',
114
98
  colorAxis: {
115
99
  dmin: fetchedData.range.min.toFixed(1),
116
100
  dmax: fetchedData.range.max.toFixed(1),
@@ -119,6 +103,9 @@ function Dotplot(_ref) {
119
103
  }
120
104
  });
121
105
  updateColorscale(colorscale.current);
106
+ } else {
107
+ setData([]);
108
+ setLayout({});
122
109
  }
123
110
  }, [fetchedData, isPending, serverError, hasSelections, dispatch, updateColorscale]);
124
111
  (0, _react.useEffect)(() => {
@@ -152,8 +139,8 @@ function Dotplot(_ref) {
152
139
  layout: layout,
153
140
  useResizeHandler: true,
154
141
  style: {
155
- width: "100%",
156
- height: "100%"
142
+ width: '100%',
143
+ height: '100%'
157
144
  },
158
145
  config: {
159
146
  displaylogo: false,
@@ -169,17 +156,17 @@ function Dotplot(_ref) {
169
156
  setPlotType: setPlotType,
170
157
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("p", {
171
158
  className: "p-0 m-0",
172
- children: ["Select one or more", " ", showVarsBtn ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
159
+ children: ["Select one or more", ' ', showVarsBtn ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
173
160
  variant: "link",
174
161
  className: "border-0 p-0 align-baseline",
175
162
  onClick: setShowVars,
176
163
  children: "features"
177
- }) : "features", " ", "to display their expression across groups, then choose a", " ", showObsBtn ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
164
+ }) : 'features', ' ', "to display their expression across groups, then choose a", ' ', showObsBtn ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
178
165
  variant: "link",
179
166
  className: "border-0 p-0 align-baseline",
180
167
  onClick: setShowObs,
181
168
  children: "category"
182
- }) : "category", " ", "to group observations in the dotplot."]
169
+ }) : 'category', ' ', "to group observations in the dotplot."]
183
170
  })
184
171
  });
185
172
  } else {
@@ -188,7 +175,7 @@ function Dotplot(_ref) {
188
175
  heading: "Error displaying the dotplot",
189
176
  plotType: plotType,
190
177
  setPlotType: setPlotType,
191
- children: serverError.message || "An unexpected error occurred while generating the plot."
178
+ children: serverError.message || 'An unexpected error occurred while generating the plot.'
192
179
  });
193
180
  }
194
181
  }
@@ -78,7 +78,7 @@ function DotplotControls() {
78
78
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
79
79
  variant: "outline-primary",
80
80
  onClick: () => dispatch({
81
- type: "set.controls.colorAxis.crange",
81
+ type: 'set.controls.colorAxis.crange',
82
82
  cmin: controls.colorAxis.cmin,
83
83
  cmax: controls.colorAxis.cmax
84
84
  }),
@@ -86,7 +86,7 @@ function DotplotControls() {
86
86
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
87
87
  variant: "outline-primary",
88
88
  onClick: () => dispatch({
89
- type: "set.controls.colorAxis.crange",
89
+ type: 'set.controls.colorAxis.crange',
90
90
  cmin: settings.controls.colorAxis.dmin,
91
91
  cmax: settings.controls.colorAxis.dmax
92
92
  }),
@@ -103,7 +103,7 @@ function DotplotControls() {
103
103
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Form.Control, {
104
104
  size: "sm",
105
105
  type: "number",
106
- step: "0.1",
106
+ step: '0.1',
107
107
  min: 0.0,
108
108
  value: controls.expressionCutoff,
109
109
  onChange: e => {
@@ -114,7 +114,7 @@ function DotplotControls() {
114
114
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
115
115
  variant: "outline-primary",
116
116
  onClick: () => dispatch({
117
- type: "set.controls.expressionCutoff",
117
+ type: 'set.controls.expressionCutoff',
118
118
  expressionCutoff: parseFloat(controls.expressionCutoff)
119
119
  }),
120
120
  children: "Apply"
@@ -129,7 +129,7 @@ function DotplotControls() {
129
129
  checked: settings.controls.meanOnlyExpressed,
130
130
  onChange: () => {
131
131
  dispatch({
132
- type: "set.controls.meanOnlyExpressed",
132
+ type: 'set.controls.meanOnlyExpressed',
133
133
  meanOnlyExpressed: !settings.controls.meanOnlyExpressed
134
134
  });
135
135
  }
@@ -7,7 +7,6 @@ exports.FullPage = FullPage;
7
7
  var _react = require("react");
8
8
  var _material = require("@mui/material");
9
9
  var _reactBootstrap = require("react-bootstrap");
10
- var _PlotTypeSelector = require("./PlotTypeSelector");
11
10
  var _constants = require("../../constants/constants");
12
11
  var _DatasetContext = require("../../context/DatasetContext");
13
12
  var _Dotplot = require("../dotplot/Dotplot");
@@ -18,6 +17,7 @@ var _Matrixplot = require("../matrixplot/Matrixplot");
18
17
  var _MatrixplotControls = require("../matrixplot/MatrixplotControls");
19
18
  var _ObsList = require("../obs-list/ObsList");
20
19
  var _offcanvas = require("../offcanvas");
20
+ var _PlotTypeSelector = require("./PlotTypeSelector");
21
21
  var _Pseudospatial = require("../pseudospatial/Pseudospatial");
22
22
  var _PseudospatialToolbar = require("../pseudospatial/PseudospatialToolbar");
23
23
  var _Scatterplot = require("../scatterplot/Scatterplot");
@@ -59,7 +59,6 @@ function FullPage(_ref) {
59
59
  const XlBreakpoint = (0, _material.useMediaQuery)(_constants.BREAKPOINTS.XL);
60
60
  const showObsBtn = LgBreakpoint;
61
61
  const showVarsBtn = XlBreakpoint;
62
- const showPlotBtn = showVarsBtn;
63
62
  const {
64
63
  plotControls,
65
64
  varMode,
@@ -11,7 +11,7 @@ var _constants = require("../../constants/constants");
11
11
  var _jsxRuntime = require("react/jsx-runtime");
12
12
  function PlotAlert(_ref) {
13
13
  let {
14
- variant = "warning",
14
+ variant = 'warning',
15
15
  plotType = _constants.PLOT_TYPES.SCATTERPLOT,
16
16
  setPlotType,
17
17
  heading,
@@ -22,28 +22,28 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
22
22
  const plotTypes = [{
23
23
  type: _constants.PLOT_TYPES.SCATTERPLOT,
24
24
  icon: _ScatterplotIcon.default,
25
- name: "Scatterplot",
26
- description: "Displays cells in 2D based on dimensionality reduction."
25
+ name: 'Scatterplot',
26
+ description: 'Displays cells in 2D based on dimensionality reduction.'
27
27
  }, {
28
28
  type: _constants.PLOT_TYPES.MATRIXPLOT,
29
29
  icon: _MatrixPlotIcon.default,
30
- name: "Matrix Plot",
31
- description: "Shows expression values of genes across categories."
30
+ name: 'Matrix Plot',
31
+ description: 'Shows expression values of genes across categories.'
32
32
  }, {
33
33
  type: _constants.PLOT_TYPES.DOTPLOT,
34
34
  icon: _DotPlotIcon.default,
35
- name: "Dot Plot",
36
- description: "Shows proportion and expression of genes across groups."
35
+ name: 'Dot Plot',
36
+ description: 'Shows proportion and expression of genes across groups.'
37
37
  }, {
38
38
  type: _constants.PLOT_TYPES.HEATMAP,
39
39
  icon: _HeatmapIcon.default,
40
- name: "Heatmap",
41
- description: "Visualises gene expression or feature activity as a colour-coded matrix."
40
+ name: 'Heatmap',
41
+ description: 'Visualises gene expression or feature activity as a colour-coded matrix.'
42
42
  }, {
43
43
  type: _constants.PLOT_TYPES.VIOLINPLOT,
44
44
  icon: _ViolinPlotIcon.default,
45
- name: "Violin Plot",
46
- description: "Displays distribution of gene expression across categories."
45
+ name: 'Violin Plot',
46
+ description: 'Displays distribution of gene expression across categories.'
47
47
  }];
48
48
  function PlotTypeSelector(_ref) {
49
49
  let {
@@ -68,7 +68,7 @@ function PlotTypeSelector(_ref) {
68
68
  } = _ref2;
69
69
  const isActive = currentType === type;
70
70
  const hovered = hoveredMap[type] || false;
71
- const colour = isActive ? "#005a86" : hovered ? "#0071a7" : "#000";
71
+ const colour = isActive ? '#005a86' : hovered ? '#0071a7' : '#000';
72
72
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_StyledTooltip.StyledTooltip, {
73
73
  title: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
74
74
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("strong", {
@@ -79,7 +79,7 @@ function PlotTypeSelector(_ref) {
79
79
  slotProps: {
80
80
  popper: {
81
81
  modifiers: [{
82
- name: "offset",
82
+ name: 'offset',
83
83
  options: {
84
84
  offset: [0, -12]
85
85
  }
@@ -90,7 +90,7 @@ function PlotTypeSelector(_ref) {
90
90
  onMouseEnter: () => handleMouseEnter(type),
91
91
  onMouseLeave: () => handleMouseLeave(type),
92
92
  onClick: () => onChange(type),
93
- className: "plotselector-icon".concat(isActive ? " active" : ""),
93
+ className: "plotselector-icon".concat(isActive ? ' active' : ''),
94
94
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Icon, {
95
95
  size: 34,
96
96
  colour: colour
@@ -35,7 +35,7 @@ function Heatmap(_ref) {
35
35
  plotType,
36
36
  setPlotType
37
37
  } = _ref;
38
- const ENDPOINT = "heatmap";
38
+ const ENDPOINT = 'heatmap';
39
39
  const dataset = (0, _DatasetContext.useDataset)();
40
40
  const settings = (0, _SettingsContext.useSettings)();
41
41
  const {
@@ -48,7 +48,7 @@ function Heatmap(_ref) {
48
48
  const [hasSelections, setHasSelections] = (0, _react.useState)(false);
49
49
  const selectedObs = (0, _Resolver.useSelectedObs)();
50
50
  const selectedMultiVar = (0, _Resolver.useSelectedMultiVar)();
51
- const [params, setParams] = (0, _react.useState)({
51
+ const params = (0, _react.useMemo)(() => ({
52
52
  url: dataset.url,
53
53
  obsCol: selectedObs,
54
54
  obsValues: !(selectedObs !== null && selectedObs !== void 0 && selectedObs.omit.length) ? null : _lodash.default.difference(selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.values, selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.omit),
@@ -58,26 +58,13 @@ function Heatmap(_ref) {
58
58
  } : i.index),
59
59
  obsIndices: isSliced ? [...(obsIndices || [])] : null,
60
60
  varNamesCol: dataset.varNamesCol
61
- });
61
+ }), [dataset.url, dataset.varNamesCol, isSliced, obsIndices, selectedMultiVar, selectedObs]);
62
62
  (0, _react.useEffect)(() => {
63
63
  if (selectedObs && selectedMultiVar.length) {
64
64
  setHasSelections(true);
65
65
  } else {
66
66
  setHasSelections(false);
67
67
  }
68
- setParams(p => {
69
- return _objectSpread(_objectSpread({}, p), {}, {
70
- url: dataset.url,
71
- obsCol: selectedObs,
72
- obsValues: !(selectedObs !== null && selectedObs !== void 0 && selectedObs.omit.length) ? null : _lodash.default.difference(selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.values, selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.omit),
73
- varKeys: selectedMultiVar.map(i => i.isSet ? {
74
- name: i.name,
75
- indices: i.vars.map(v => v.index)
76
- } : i.index),
77
- obsIndices: isSliced ? [...(obsIndices || [])] : null,
78
- varNamesCol: dataset.varNamesCol
79
- });
80
- });
81
68
  }, [selectedMultiVar, selectedObs, dataset.url, dataset.varNamesCol, obsIndices, isSliced]);
82
69
  const updateColorscale = (0, _react.useCallback)(colorscale => {
83
70
  setLayout(l => {
@@ -93,13 +80,16 @@ function Heatmap(_ref) {
93
80
  isPending,
94
81
  serverError
95
82
  } = (0, _requests.useDebouncedFetch)(ENDPOINT, params, 500, {
96
- enabled: !!params.obsCol && !!params.varKeys.length
83
+ isEnabled: params => !!params.obsCol && !!params.varKeys.length
97
84
  });
98
85
  (0, _react.useEffect)(() => {
99
- if (hasSelections && !isPending && !serverError) {
86
+ if (hasSelections && !!fetchedData && !isPending && !serverError) {
100
87
  setData(fetchedData.data);
101
88
  setLayout(fetchedData.layout);
102
89
  updateColorscale(colorscale.current);
90
+ } else {
91
+ setData([]);
92
+ setLayout({});
103
93
  }
104
94
  }, [fetchedData, hasSelections, isPending, serverError, updateColorscale]);
105
95
  (0, _react.useEffect)(() => {
@@ -123,8 +113,8 @@ function Heatmap(_ref) {
123
113
  layout: layout,
124
114
  useResizeHandler: true,
125
115
  style: {
126
- width: "100%",
127
- height: "100%"
116
+ width: '100%',
117
+ height: '100%'
128
118
  },
129
119
  config: {
130
120
  displaylogo: false,
@@ -140,17 +130,17 @@ function Heatmap(_ref) {
140
130
  setPlotType: setPlotType,
141
131
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("p", {
142
132
  className: "p-0 m-0",
143
- children: ["Select one or more", " ", showVarsBtn ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
133
+ children: ["Select one or more", ' ', showVarsBtn ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
144
134
  variant: "link",
145
135
  className: "border-0 p-0 align-baseline",
146
136
  onClick: setShowVars,
147
137
  children: "features"
148
- }) : "features", " ", "to display their expression, then choose a", " ", showObsBtn ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
138
+ }) : 'features', ' ', "to display their expression, then choose a", ' ', showObsBtn ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
149
139
  variant: "link",
150
140
  className: "border-0 p-0 align-baseline",
151
141
  onClick: setShowObs,
152
142
  children: "category"
153
- }) : "category", " ", "to group observations in the heatmap."]
143
+ }) : 'category', ' ', "to group observations in the heatmap."]
154
144
  })
155
145
  });
156
146
  } else {
@@ -159,7 +149,7 @@ function Heatmap(_ref) {
159
149
  heading: "Error displaying the heatmap",
160
150
  plotType: plotType,
161
151
  setPlotType: setPlotType,
162
- children: serverError.message || "An unexpected error occurred while generating the plot."
152
+ children: serverError.message || 'An unexpected error occurred while generating the plot.'
163
153
  });
164
154
  }
165
155
  }
@@ -16,7 +16,7 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
16
16
  function DotPlotIcon(_ref) {
17
17
  let {
18
18
  size = 40,
19
- colour = "#000",
19
+ colour = '#000',
20
20
  gap = 20
21
21
  } = _ref,
22
22
  props = _objectWithoutProperties(_ref, _excluded);
@@ -16,7 +16,7 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
16
16
  function HeatmapIcon(_ref) {
17
17
  let {
18
18
  size = 40,
19
- colour = "#000",
19
+ colour = '#000',
20
20
  gap = 1
21
21
  } = _ref,
22
22
  props = _objectWithoutProperties(_ref, _excluded);
@@ -16,7 +16,7 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
16
16
  function MatrixPlotIcon(_ref) {
17
17
  let {
18
18
  size = 40,
19
- colour = "#000",
19
+ colour = '#000',
20
20
  gap = 2
21
21
  } = _ref,
22
22
  props = _objectWithoutProperties(_ref, _excluded);
@@ -16,7 +16,7 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
16
16
  function MatrixPlotIcon(_ref) {
17
17
  let {
18
18
  size = 40,
19
- colour = "#000",
19
+ colour = '#000',
20
20
  gap = 2
21
21
  } = _ref,
22
22
  props = _objectWithoutProperties(_ref, _excluded);
@@ -16,7 +16,7 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
16
16
  function ScatterplotIcon(_ref) {
17
17
  let {
18
18
  size = 40,
19
- colour = "#000"
19
+ colour = '#000'
20
20
  } = _ref,
21
21
  props = _objectWithoutProperties(_ref, _excluded);
22
22
  // Points with cluster assignments
@@ -16,7 +16,7 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
16
16
  function ScatterplotIcon(_ref) {
17
17
  let {
18
18
  size = 40,
19
- colour = "#000"
19
+ colour = '#000'
20
20
  } = _ref,
21
21
  props = _objectWithoutProperties(_ref, _excluded);
22
22
  // Points with cluster assignments
@@ -16,7 +16,7 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
16
16
  function ViolinPlotIcon(_ref) {
17
17
  let {
18
18
  size = 40,
19
- colour = "#000"
19
+ colour = '#000'
20
20
  } = _ref,
21
21
  props = _objectWithoutProperties(_ref, _excluded);
22
22
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", _objectSpread(_objectSpread({
@@ -35,7 +35,7 @@ function Matrixplot(_ref) {
35
35
  plotType,
36
36
  setPlotType
37
37
  } = _ref;
38
- const ENDPOINT = "matrixplot";
38
+ const ENDPOINT = 'matrixplot';
39
39
  const dataset = (0, _DatasetContext.useDataset)();
40
40
  const settings = (0, _SettingsContext.useSettings)();
41
41
  const {
@@ -48,7 +48,7 @@ function Matrixplot(_ref) {
48
48
  const [hasSelections, setHasSelections] = (0, _react.useState)(false);
49
49
  const selectedObs = (0, _Resolver.useSelectedObs)();
50
50
  const selectedMultiVar = (0, _Resolver.useSelectedMultiVar)();
51
- const [params, setParams] = (0, _react.useState)({
51
+ const params = (0, _react.useMemo)(() => ({
52
52
  url: dataset.url,
53
53
  obsCol: selectedObs,
54
54
  obsValues: !(selectedObs !== null && selectedObs !== void 0 && selectedObs.omit.length) ? null : _lodash.default.difference(selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.values, selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.omit),
@@ -59,28 +59,14 @@ function Matrixplot(_ref) {
59
59
  obsIndices: isSliced ? [...(obsIndices || [])] : null,
60
60
  standardScale: settings.controls.scale.matrixplot,
61
61
  varNamesCol: dataset.varNamesCol
62
- });
62
+ }), [dataset.url, dataset.varNamesCol, isSliced, obsIndices, selectedMultiVar, selectedObs, settings.controls.scale.matrixplot]);
63
63
  (0, _react.useEffect)(() => {
64
64
  if (selectedObs && selectedMultiVar.length) {
65
65
  setHasSelections(true);
66
66
  } else {
67
67
  setHasSelections(false);
68
68
  }
69
- setParams(p => {
70
- return _objectSpread(_objectSpread({}, p), {}, {
71
- url: dataset.url,
72
- obsCol: selectedObs,
73
- obsValues: !(selectedObs !== null && selectedObs !== void 0 && selectedObs.omit.length) ? null : _lodash.default.difference(selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.values, selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.omit),
74
- varKeys: selectedMultiVar.map(i => i.isSet ? {
75
- name: i.name,
76
- indices: i.vars.map(v => v.index)
77
- } : i.index),
78
- obsIndices: isSliced ? [...(obsIndices || [])] : null,
79
- standardScale: settings.controls.scale.matrixplot,
80
- varNamesCol: dataset.varNamesCol
81
- });
82
- });
83
- }, [settings.controls.scale.matrixplot, selectedMultiVar, selectedObs, dataset.url, dataset.varNamesCol, obsIndices, isSliced]);
69
+ }, [selectedMultiVar.length, selectedObs]);
84
70
  const updateColorscale = (0, _react.useCallback)(colorscale => {
85
71
  setLayout(l => {
86
72
  return _objectSpread(_objectSpread({}, l), {}, {
@@ -95,13 +81,16 @@ function Matrixplot(_ref) {
95
81
  isPending,
96
82
  serverError
97
83
  } = (0, _requests.useDebouncedFetch)(ENDPOINT, params, 500, {
98
- enabled: !!params.obsCol && !!params.varKeys.length
84
+ isEnabled: params => !!params.obsCol && !!params.varKeys.length
99
85
  });
100
86
  (0, _react.useEffect)(() => {
101
- if (hasSelections && !isPending && !serverError) {
87
+ if (hasSelections && !!fetchedData && !isPending && !serverError) {
102
88
  setData(fetchedData.data);
103
89
  setLayout(fetchedData.layout);
104
90
  updateColorscale(colorscale.current);
91
+ } else {
92
+ setData([]);
93
+ setLayout({});
105
94
  }
106
95
  }, [fetchedData, hasSelections, isPending, serverError, updateColorscale]);
107
96
  (0, _react.useEffect)(() => {
@@ -125,8 +114,8 @@ function Matrixplot(_ref) {
125
114
  layout: layout,
126
115
  useResizeHandler: true,
127
116
  style: {
128
- width: "100%",
129
- height: "100%"
117
+ width: '100%',
118
+ height: '100%'
130
119
  },
131
120
  config: {
132
121
  displaylogo: false,
@@ -142,17 +131,17 @@ function Matrixplot(_ref) {
142
131
  setPlotType: setPlotType,
143
132
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("p", {
144
133
  className: "p-0 m-0",
145
- children: ["Select a", " ", showObsBtn ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
134
+ children: ["Select a", ' ', showObsBtn ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
146
135
  variant: "link",
147
136
  className: "border-0 p-0 align-baseline",
148
137
  onClick: setShowObs,
149
138
  children: "category"
150
- }) : "category", " ", "to group observations, then choose one or more", " ", showVarsBtn ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
139
+ }) : 'category', ' ', "to group observations, then choose one or more", ' ', showVarsBtn ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
151
140
  variant: "link",
152
141
  className: "border-0 p-0 align-baseline",
153
142
  onClick: setShowVars,
154
143
  children: "features"
155
- }) : "features", " ", "to display the matrix plot."]
144
+ }) : 'features', ' ', "to display the matrix plot."]
156
145
  })
157
146
  });
158
147
  } else {
@@ -161,7 +150,7 @@ function Matrixplot(_ref) {
161
150
  heading: "Error displaying the matrix plot",
162
151
  plotType: plotType,
163
152
  setPlotType: setPlotType,
164
- children: serverError.message || "An unexpected error occurred while generating the plot."
153
+ children: serverError.message || 'An unexpected error occurred while generating the plot.'
165
154
  });
166
155
  }
167
156
  }