@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
@@ -3,40 +3,40 @@ 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 { useState } from "react";
7
- import { PLOT_TYPES } from "../../constants/constants";
8
- import { StyledTooltip } from "../../utils/StyledTooltip";
9
- import DotPlotIcon from "../icons/DotPlotIcon";
10
- import HeatmapIcon from "../icons/HeatmapIcon";
11
- import MatrixPlotIcon from "../icons/MatrixPlotIcon";
12
- import ScatterplotIcon from "../icons/ScatterplotIcon";
13
- import ViolinPlotIcon from "../icons/ViolinPlotIcon";
6
+ import { useState } from 'react';
7
+ import { PLOT_TYPES } from '../../constants/constants';
8
+ import { StyledTooltip } from '../../utils/StyledTooltip';
9
+ import DotPlotIcon from '../icons/DotPlotIcon';
10
+ import HeatmapIcon from '../icons/HeatmapIcon';
11
+ import MatrixPlotIcon from '../icons/MatrixPlotIcon';
12
+ import ScatterplotIcon from '../icons/ScatterplotIcon';
13
+ import ViolinPlotIcon from '../icons/ViolinPlotIcon';
14
14
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
15
15
  const plotTypes = [{
16
16
  type: PLOT_TYPES.SCATTERPLOT,
17
17
  icon: ScatterplotIcon,
18
- name: "Scatterplot",
19
- description: "Displays cells in 2D based on dimensionality reduction."
18
+ name: 'Scatterplot',
19
+ description: 'Displays cells in 2D based on dimensionality reduction.'
20
20
  }, {
21
21
  type: PLOT_TYPES.MATRIXPLOT,
22
22
  icon: MatrixPlotIcon,
23
- name: "Matrix Plot",
24
- description: "Shows expression values of genes across categories."
23
+ name: 'Matrix Plot',
24
+ description: 'Shows expression values of genes across categories.'
25
25
  }, {
26
26
  type: PLOT_TYPES.DOTPLOT,
27
27
  icon: DotPlotIcon,
28
- name: "Dot Plot",
29
- description: "Shows proportion and expression of genes across groups."
28
+ name: 'Dot Plot',
29
+ description: 'Shows proportion and expression of genes across groups.'
30
30
  }, {
31
31
  type: PLOT_TYPES.HEATMAP,
32
32
  icon: HeatmapIcon,
33
- name: "Heatmap",
34
- description: "Visualises gene expression or feature activity as a colour-coded matrix."
33
+ name: 'Heatmap',
34
+ description: 'Visualises gene expression or feature activity as a colour-coded matrix.'
35
35
  }, {
36
36
  type: PLOT_TYPES.VIOLINPLOT,
37
37
  icon: ViolinPlotIcon,
38
- name: "Violin Plot",
39
- description: "Displays distribution of gene expression across categories."
38
+ name: 'Violin Plot',
39
+ description: 'Displays distribution of gene expression across categories.'
40
40
  }];
41
41
  export function PlotTypeSelector(_ref) {
42
42
  let {
@@ -61,7 +61,7 @@ export function PlotTypeSelector(_ref) {
61
61
  } = _ref2;
62
62
  const isActive = currentType === type;
63
63
  const hovered = hoveredMap[type] || false;
64
- const colour = isActive ? "#005a86" : hovered ? "#0071a7" : "#000";
64
+ const colour = isActive ? '#005a86' : hovered ? '#0071a7' : '#000';
65
65
  return /*#__PURE__*/_jsx(StyledTooltip, {
66
66
  title: /*#__PURE__*/_jsxs(_Fragment, {
67
67
  children: [/*#__PURE__*/_jsx("strong", {
@@ -72,7 +72,7 @@ export function PlotTypeSelector(_ref) {
72
72
  slotProps: {
73
73
  popper: {
74
74
  modifiers: [{
75
- name: "offset",
75
+ name: 'offset',
76
76
  options: {
77
77
  offset: [0, -12]
78
78
  }
@@ -83,7 +83,7 @@ export function PlotTypeSelector(_ref) {
83
83
  onMouseEnter: () => handleMouseEnter(type),
84
84
  onMouseLeave: () => handleMouseLeave(type),
85
85
  onClick: () => onChange(type),
86
- className: "plotselector-icon".concat(isActive ? " active" : ""),
86
+ className: "plotselector-icon".concat(isActive ? ' active' : ''),
87
87
  children: /*#__PURE__*/_jsx(Icon, {
88
88
  size: 34,
89
89
  colour: colour
@@ -3,19 +3,19 @@ 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 { useCallback, useEffect, useRef, useState } from "react";
7
- import _ from "lodash";
8
- import { Button } from "react-bootstrap";
9
- import Plot from "react-plotly.js";
10
- import { PLOTLY_MODEBAR_BUTTONS } from "../../constants/constants";
11
- import { useDataset } from "../../context/DatasetContext";
12
- import { useFilteredData } from "../../context/FilterContext";
13
- import { useSettings } from "../../context/SettingsContext";
14
- import { LoadingSpinner } from "../../utils/LoadingIndicators";
15
- import { useDebouncedFetch } from "../../utils/requests";
16
- import { useSelectedMultiVar, useSelectedObs } from "../../utils/Resolver";
17
- import { PlotAlert } from "../full-page/PlotAlert";
18
- import { ControlsPlotlyToolbar, ObsPlotlyToolbar, VarPlotlyToolbar } from "../toolbar/Toolbar";
6
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
7
+ import _ from 'lodash';
8
+ import { Button } from 'react-bootstrap';
9
+ import Plot from 'react-plotly.js';
10
+ import { PLOTLY_MODEBAR_BUTTONS } from '../../constants/constants';
11
+ import { useDataset } from '../../context/DatasetContext';
12
+ import { useFilteredData } from '../../context/FilterContext';
13
+ import { useSettings } from '../../context/SettingsContext';
14
+ import { LoadingSpinner } from '../../utils/LoadingIndicators';
15
+ import { useDebouncedFetch } from '../../utils/requests';
16
+ import { useSelectedMultiVar, useSelectedObs } from '../../utils/Resolver';
17
+ import { PlotAlert } from '../full-page/PlotAlert';
18
+ import { ControlsPlotlyToolbar, ObsPlotlyToolbar, VarPlotlyToolbar } from '../toolbar/Toolbar';
19
19
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
20
  export function Heatmap(_ref) {
21
21
  let {
@@ -28,7 +28,7 @@ export function Heatmap(_ref) {
28
28
  plotType,
29
29
  setPlotType
30
30
  } = _ref;
31
- const ENDPOINT = "heatmap";
31
+ const ENDPOINT = 'heatmap';
32
32
  const dataset = useDataset();
33
33
  const settings = useSettings();
34
34
  const {
@@ -41,7 +41,7 @@ export function Heatmap(_ref) {
41
41
  const [hasSelections, setHasSelections] = useState(false);
42
42
  const selectedObs = useSelectedObs();
43
43
  const selectedMultiVar = useSelectedMultiVar();
44
- const [params, setParams] = useState({
44
+ const params = useMemo(() => ({
45
45
  url: dataset.url,
46
46
  obsCol: selectedObs,
47
47
  obsValues: !(selectedObs !== null && selectedObs !== void 0 && selectedObs.omit.length) ? null : _.difference(selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.values, selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.omit),
@@ -51,26 +51,13 @@ export function Heatmap(_ref) {
51
51
  } : i.index),
52
52
  obsIndices: isSliced ? [...(obsIndices || [])] : null,
53
53
  varNamesCol: dataset.varNamesCol
54
- });
54
+ }), [dataset.url, dataset.varNamesCol, isSliced, obsIndices, selectedMultiVar, selectedObs]);
55
55
  useEffect(() => {
56
56
  if (selectedObs && selectedMultiVar.length) {
57
57
  setHasSelections(true);
58
58
  } else {
59
59
  setHasSelections(false);
60
60
  }
61
- setParams(p => {
62
- return _objectSpread(_objectSpread({}, p), {}, {
63
- url: dataset.url,
64
- obsCol: selectedObs,
65
- obsValues: !(selectedObs !== null && selectedObs !== void 0 && selectedObs.omit.length) ? null : _.difference(selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.values, selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.omit),
66
- varKeys: selectedMultiVar.map(i => i.isSet ? {
67
- name: i.name,
68
- indices: i.vars.map(v => v.index)
69
- } : i.index),
70
- obsIndices: isSliced ? [...(obsIndices || [])] : null,
71
- varNamesCol: dataset.varNamesCol
72
- });
73
- });
74
61
  }, [selectedMultiVar, selectedObs, dataset.url, dataset.varNamesCol, obsIndices, isSliced]);
75
62
  const updateColorscale = useCallback(colorscale => {
76
63
  setLayout(l => {
@@ -86,13 +73,16 @@ export function Heatmap(_ref) {
86
73
  isPending,
87
74
  serverError
88
75
  } = useDebouncedFetch(ENDPOINT, params, 500, {
89
- enabled: !!params.obsCol && !!params.varKeys.length
76
+ isEnabled: params => !!params.obsCol && !!params.varKeys.length
90
77
  });
91
78
  useEffect(() => {
92
- if (hasSelections && !isPending && !serverError) {
79
+ if (hasSelections && !!fetchedData && !isPending && !serverError) {
93
80
  setData(fetchedData.data);
94
81
  setLayout(fetchedData.layout);
95
82
  updateColorscale(colorscale.current);
83
+ } else {
84
+ setData([]);
85
+ setLayout({});
96
86
  }
97
87
  }, [fetchedData, hasSelections, isPending, serverError, updateColorscale]);
98
88
  useEffect(() => {
@@ -116,8 +106,8 @@ export function Heatmap(_ref) {
116
106
  layout: layout,
117
107
  useResizeHandler: true,
118
108
  style: {
119
- width: "100%",
120
- height: "100%"
109
+ width: '100%',
110
+ height: '100%'
121
111
  },
122
112
  config: {
123
113
  displaylogo: false,
@@ -133,17 +123,17 @@ export function Heatmap(_ref) {
133
123
  setPlotType: setPlotType,
134
124
  children: /*#__PURE__*/_jsxs("p", {
135
125
  className: "p-0 m-0",
136
- children: ["Select one or more", " ", showVarsBtn ? /*#__PURE__*/_jsx(Button, {
126
+ children: ["Select one or more", ' ', showVarsBtn ? /*#__PURE__*/_jsx(Button, {
137
127
  variant: "link",
138
128
  className: "border-0 p-0 align-baseline",
139
129
  onClick: setShowVars,
140
130
  children: "features"
141
- }) : "features", " ", "to display their expression, then choose a", " ", showObsBtn ? /*#__PURE__*/_jsx(Button, {
131
+ }) : 'features', ' ', "to display their expression, then choose a", ' ', showObsBtn ? /*#__PURE__*/_jsx(Button, {
142
132
  variant: "link",
143
133
  className: "border-0 p-0 align-baseline",
144
134
  onClick: setShowObs,
145
135
  children: "category"
146
- }) : "category", " ", "to group observations in the heatmap."]
136
+ }) : 'category', ' ', "to group observations in the heatmap."]
147
137
  })
148
138
  });
149
139
  } else {
@@ -152,7 +142,7 @@ export function Heatmap(_ref) {
152
142
  heading: "Error displaying the heatmap",
153
143
  plotType: plotType,
154
144
  setPlotType: setPlotType,
155
- children: serverError.message || "An unexpected error occurred while generating the plot."
145
+ children: serverError.message || 'An unexpected error occurred while generating the plot.'
156
146
  });
157
147
  }
158
148
  }
@@ -1,5 +1,5 @@
1
- import { Form } from "react-bootstrap";
2
- import { ColorscaleSelect } from "../controls/Controls";
1
+ import { Form } from 'react-bootstrap';
2
+ import { ColorscaleSelect } from '../controls/Controls';
3
3
  import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
4
4
  export function HeatmapControls() {
5
5
  return /*#__PURE__*/_jsx(_Fragment, {
@@ -10,7 +10,7 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
10
10
  export default function DotPlotIcon(_ref) {
11
11
  let {
12
12
  size = 40,
13
- colour = "#000",
13
+ colour = '#000',
14
14
  gap = 20
15
15
  } = _ref,
16
16
  props = _objectWithoutProperties(_ref, _excluded);
@@ -10,7 +10,7 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
10
10
  export default function HeatmapIcon(_ref) {
11
11
  let {
12
12
  size = 40,
13
- colour = "#000",
13
+ colour = '#000',
14
14
  gap = 1
15
15
  } = _ref,
16
16
  props = _objectWithoutProperties(_ref, _excluded);
@@ -10,7 +10,7 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
10
10
  export default function MatrixPlotIcon(_ref) {
11
11
  let {
12
12
  size = 40,
13
- colour = "#000",
13
+ colour = '#000',
14
14
  gap = 2
15
15
  } = _ref,
16
16
  props = _objectWithoutProperties(_ref, _excluded);
@@ -10,7 +10,7 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
10
10
  export default function MatrixPlotIcon(_ref) {
11
11
  let {
12
12
  size = 40,
13
- colour = "#000",
13
+ colour = '#000',
14
14
  gap = 2
15
15
  } = _ref,
16
16
  props = _objectWithoutProperties(_ref, _excluded);
@@ -10,7 +10,7 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
10
10
  export default function ScatterplotIcon(_ref) {
11
11
  let {
12
12
  size = 40,
13
- colour = "#000"
13
+ colour = '#000'
14
14
  } = _ref,
15
15
  props = _objectWithoutProperties(_ref, _excluded);
16
16
  // Points with cluster assignments
@@ -10,7 +10,7 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
10
10
  export default function ScatterplotIcon(_ref) {
11
11
  let {
12
12
  size = 40,
13
- colour = "#000"
13
+ colour = '#000'
14
14
  } = _ref,
15
15
  props = _objectWithoutProperties(_ref, _excluded);
16
16
  // Points with cluster assignments
@@ -10,7 +10,7 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
10
10
  export default function ViolinPlotIcon(_ref) {
11
11
  let {
12
12
  size = 40,
13
- colour = "#000"
13
+ colour = '#000'
14
14
  } = _ref,
15
15
  props = _objectWithoutProperties(_ref, _excluded);
16
16
  return /*#__PURE__*/_jsx("svg", _objectSpread(_objectSpread({
@@ -3,19 +3,19 @@ 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 { useCallback, useEffect, useRef, useState } from "react";
7
- import _ from "lodash";
8
- import { Button } from "react-bootstrap";
9
- import Plot from "react-plotly.js";
10
- import { PLOTLY_MODEBAR_BUTTONS } from "../../constants/constants";
11
- import { useDataset } from "../../context/DatasetContext";
12
- import { useFilteredData } from "../../context/FilterContext";
13
- import { useSettings } from "../../context/SettingsContext";
14
- import { LoadingSpinner } from "../../utils/LoadingIndicators";
15
- import { useDebouncedFetch } from "../../utils/requests";
16
- import { useSelectedMultiVar, useSelectedObs } from "../../utils/Resolver";
17
- import { PlotAlert } from "../full-page/PlotAlert";
18
- import { ControlsPlotlyToolbar, ObsPlotlyToolbar, VarPlotlyToolbar } from "../toolbar/Toolbar";
6
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
7
+ import _ from 'lodash';
8
+ import { Button } from 'react-bootstrap';
9
+ import Plot from 'react-plotly.js';
10
+ import { PLOTLY_MODEBAR_BUTTONS } from '../../constants/constants';
11
+ import { useDataset } from '../../context/DatasetContext';
12
+ import { useFilteredData } from '../../context/FilterContext';
13
+ import { useSettings } from '../../context/SettingsContext';
14
+ import { LoadingSpinner } from '../../utils/LoadingIndicators';
15
+ import { useDebouncedFetch } from '../../utils/requests';
16
+ import { useSelectedMultiVar, useSelectedObs } from '../../utils/Resolver';
17
+ import { PlotAlert } from '../full-page/PlotAlert';
18
+ import { ControlsPlotlyToolbar, ObsPlotlyToolbar, VarPlotlyToolbar } from '../toolbar/Toolbar';
19
19
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
20
  export function Matrixplot(_ref) {
21
21
  let {
@@ -28,7 +28,7 @@ export function Matrixplot(_ref) {
28
28
  plotType,
29
29
  setPlotType
30
30
  } = _ref;
31
- const ENDPOINT = "matrixplot";
31
+ const ENDPOINT = 'matrixplot';
32
32
  const dataset = useDataset();
33
33
  const settings = useSettings();
34
34
  const {
@@ -41,7 +41,7 @@ export function Matrixplot(_ref) {
41
41
  const [hasSelections, setHasSelections] = useState(false);
42
42
  const selectedObs = useSelectedObs();
43
43
  const selectedMultiVar = useSelectedMultiVar();
44
- const [params, setParams] = useState({
44
+ const params = useMemo(() => ({
45
45
  url: dataset.url,
46
46
  obsCol: selectedObs,
47
47
  obsValues: !(selectedObs !== null && selectedObs !== void 0 && selectedObs.omit.length) ? null : _.difference(selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.values, selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.omit),
@@ -52,28 +52,14 @@ export function Matrixplot(_ref) {
52
52
  obsIndices: isSliced ? [...(obsIndices || [])] : null,
53
53
  standardScale: settings.controls.scale.matrixplot,
54
54
  varNamesCol: dataset.varNamesCol
55
- });
55
+ }), [dataset.url, dataset.varNamesCol, isSliced, obsIndices, selectedMultiVar, selectedObs, settings.controls.scale.matrixplot]);
56
56
  useEffect(() => {
57
57
  if (selectedObs && selectedMultiVar.length) {
58
58
  setHasSelections(true);
59
59
  } else {
60
60
  setHasSelections(false);
61
61
  }
62
- setParams(p => {
63
- return _objectSpread(_objectSpread({}, p), {}, {
64
- url: dataset.url,
65
- obsCol: selectedObs,
66
- obsValues: !(selectedObs !== null && selectedObs !== void 0 && selectedObs.omit.length) ? null : _.difference(selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.values, selectedObs === null || selectedObs === void 0 ? void 0 : selectedObs.omit),
67
- varKeys: selectedMultiVar.map(i => i.isSet ? {
68
- name: i.name,
69
- indices: i.vars.map(v => v.index)
70
- } : i.index),
71
- obsIndices: isSliced ? [...(obsIndices || [])] : null,
72
- standardScale: settings.controls.scale.matrixplot,
73
- varNamesCol: dataset.varNamesCol
74
- });
75
- });
76
- }, [settings.controls.scale.matrixplot, selectedMultiVar, selectedObs, dataset.url, dataset.varNamesCol, obsIndices, isSliced]);
62
+ }, [selectedMultiVar.length, selectedObs]);
77
63
  const updateColorscale = useCallback(colorscale => {
78
64
  setLayout(l => {
79
65
  return _objectSpread(_objectSpread({}, l), {}, {
@@ -88,13 +74,16 @@ export function Matrixplot(_ref) {
88
74
  isPending,
89
75
  serverError
90
76
  } = useDebouncedFetch(ENDPOINT, params, 500, {
91
- enabled: !!params.obsCol && !!params.varKeys.length
77
+ isEnabled: params => !!params.obsCol && !!params.varKeys.length
92
78
  });
93
79
  useEffect(() => {
94
- if (hasSelections && !isPending && !serverError) {
80
+ if (hasSelections && !!fetchedData && !isPending && !serverError) {
95
81
  setData(fetchedData.data);
96
82
  setLayout(fetchedData.layout);
97
83
  updateColorscale(colorscale.current);
84
+ } else {
85
+ setData([]);
86
+ setLayout({});
98
87
  }
99
88
  }, [fetchedData, hasSelections, isPending, serverError, updateColorscale]);
100
89
  useEffect(() => {
@@ -118,8 +107,8 @@ export function Matrixplot(_ref) {
118
107
  layout: layout,
119
108
  useResizeHandler: true,
120
109
  style: {
121
- width: "100%",
122
- height: "100%"
110
+ width: '100%',
111
+ height: '100%'
123
112
  },
124
113
  config: {
125
114
  displaylogo: false,
@@ -135,17 +124,17 @@ export function Matrixplot(_ref) {
135
124
  setPlotType: setPlotType,
136
125
  children: /*#__PURE__*/_jsxs("p", {
137
126
  className: "p-0 m-0",
138
- children: ["Select a", " ", showObsBtn ? /*#__PURE__*/_jsx(Button, {
127
+ children: ["Select a", ' ', showObsBtn ? /*#__PURE__*/_jsx(Button, {
139
128
  variant: "link",
140
129
  className: "border-0 p-0 align-baseline",
141
130
  onClick: setShowObs,
142
131
  children: "category"
143
- }) : "category", " ", "to group observations, then choose one or more", " ", showVarsBtn ? /*#__PURE__*/_jsx(Button, {
132
+ }) : 'category', ' ', "to group observations, then choose one or more", ' ', showVarsBtn ? /*#__PURE__*/_jsx(Button, {
144
133
  variant: "link",
145
134
  className: "border-0 p-0 align-baseline",
146
135
  onClick: setShowVars,
147
136
  children: "features"
148
- }) : "features", " ", "to display the matrix plot."]
137
+ }) : 'features', ' ', "to display the matrix plot."]
149
138
  })
150
139
  });
151
140
  } else {
@@ -154,7 +143,7 @@ export function Matrixplot(_ref) {
154
143
  heading: "Error displaying the matrix plot",
155
144
  plotType: plotType,
156
145
  setPlotType: setPlotType,
157
- children: serverError.message || "An unexpected error occurred while generating the plot."
146
+ children: serverError.message || 'An unexpected error occurred while generating the plot.'
158
147
  });
159
148
  }
160
149
  }
@@ -1,5 +1,5 @@
1
- import { Form } from "react-bootstrap";
2
- import { ColorscaleSelect, ScaleSelect } from "../controls/Controls";
1
+ import { Form } from 'react-bootstrap';
2
+ import { ColorscaleSelect, ScaleSelect } from '../controls/Controls';
3
3
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
4
4
  export function MatrixplotControls() {
5
5
  return /*#__PURE__*/_jsx(_Fragment, {