@haniffalab/cherita-react 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cjs/components/controls/Controls.js +38 -30
- package/dist/cjs/components/dotplot/Dotplot.js +85 -57
- package/dist/cjs/components/dotplot/DotplotControls.js +103 -83
- package/dist/cjs/components/full-page/FullPage.js +167 -114
- package/dist/cjs/components/full-page/PlotAlert.js +45 -0
- package/dist/cjs/components/full-page/PlotTypeSelector.js +102 -0
- package/dist/cjs/components/heatmap/Heatmap.js +83 -53
- 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 +83 -54
- package/dist/cjs/components/matrixplot/MatrixplotControls.js +8 -5
- package/dist/cjs/components/obs-list/ObsItem.js +305 -216
- package/dist/cjs/components/obs-list/ObsList.js +164 -128
- package/dist/cjs/components/obs-list/ObsToolbar.js +2 -3
- package/dist/cjs/components/obsm-list/ObsmList.js +67 -28
- package/dist/cjs/components/offcanvas/index.js +62 -27
- package/dist/cjs/components/pseudospatial/Pseudospatial.js +132 -76
- package/dist/cjs/components/pseudospatial/PseudospatialToolbar.js +122 -74
- package/dist/cjs/components/scatterplot/Scatterplot.js +223 -175
- package/dist/cjs/components/scatterplot/ScatterplotControls.js +45 -31
- package/dist/cjs/components/scatterplot/SpatialControls.js +143 -116
- package/dist/cjs/components/scatterplot/Toolbox.js +41 -30
- package/dist/cjs/components/search-bar/SearchBar.js +176 -120
- package/dist/cjs/components/search-bar/SearchInfo.js +79 -85
- package/dist/cjs/components/search-bar/SearchResults.js +93 -71
- package/dist/cjs/components/toolbar/Toolbar.js +111 -0
- package/dist/cjs/components/var-list/VarItem.js +131 -103
- package/dist/cjs/components/var-list/VarList.js +96 -74
- 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 +124 -81
- package/dist/cjs/components/violin/ViolinControls.js +8 -5
- package/dist/cjs/constants/colorscales.js +19 -19
- package/dist/cjs/constants/constants.js +54 -39
- package/dist/cjs/context/DatasetContext.js +27 -17
- package/dist/cjs/context/FilterContext.js +11 -9
- package/dist/cjs/context/SettingsContext.js +339 -125
- package/dist/cjs/context/ZarrDataContext.js +6 -5
- package/dist/cjs/helpers/color-helper.js +2 -2
- package/dist/cjs/helpers/map-helper.js +2 -1
- package/dist/cjs/helpers/zarr-helper.js +3 -3
- package/dist/cjs/index.js +15 -21
- package/dist/cjs/utils/Filter.js +16 -11
- package/dist/cjs/utils/Histogram.js +35 -33
- package/dist/cjs/utils/ImageViewer.js +11 -8
- package/dist/cjs/utils/Legend.js +37 -30
- package/dist/cjs/utils/LoadingIndicators.js +15 -13
- package/dist/cjs/utils/Resolver.js +213 -0
- package/dist/cjs/utils/Skeleton.js +10 -10
- package/dist/cjs/utils/StyledTooltip.js +44 -0
- package/dist/cjs/utils/VirtualizedList.js +36 -29
- package/dist/cjs/utils/errors.js +15 -15
- package/dist/cjs/utils/requests.js +21 -9
- package/dist/cjs/utils/search.js +4 -4
- package/dist/cjs/utils/string.js +6 -6
- package/dist/cjs/utils/zarrData.js +20 -21
- package/dist/css/cherita.css +188 -65
- package/dist/css/cherita.css.map +1 -1
- package/dist/esm/components/controls/Controls.js +43 -35
- package/dist/esm/components/dotplot/Dotplot.js +93 -64
- package/dist/esm/components/dotplot/DotplotControls.js +106 -85
- package/dist/esm/components/full-page/FullPage.js +180 -124
- package/dist/esm/components/full-page/PlotAlert.js +39 -0
- package/dist/esm/components/full-page/PlotTypeSelector.js +95 -0
- package/dist/esm/components/heatmap/Heatmap.js +91 -60
- 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 +91 -61
- package/dist/esm/components/matrixplot/MatrixplotControls.js +10 -6
- package/dist/esm/components/obs-list/ObsItem.js +320 -228
- package/dist/esm/components/obs-list/ObsList.js +179 -142
- package/dist/esm/components/obs-list/ObsToolbar.js +3 -3
- package/dist/esm/components/obsm-list/ObsmList.js +71 -32
- package/dist/esm/components/offcanvas/index.js +68 -33
- package/dist/esm/components/pseudospatial/Pseudospatial.js +145 -88
- package/dist/esm/components/pseudospatial/PseudospatialToolbar.js +127 -78
- package/dist/esm/components/scatterplot/Scatterplot.js +243 -194
- package/dist/esm/components/scatterplot/ScatterplotControls.js +50 -35
- package/dist/esm/components/scatterplot/SpatialControls.js +155 -127
- package/dist/esm/components/scatterplot/Toolbox.js +44 -32
- package/dist/esm/components/search-bar/SearchBar.js +187 -130
- package/dist/esm/components/search-bar/SearchInfo.js +86 -91
- package/dist/esm/components/search-bar/SearchResults.js +100 -77
- package/dist/esm/components/toolbar/Toolbar.js +101 -0
- package/dist/esm/components/var-list/VarItem.js +142 -113
- package/dist/esm/components/var-list/VarList.js +108 -88
- 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 +135 -91
- package/dist/esm/components/violin/ViolinControls.js +10 -6
- package/dist/esm/constants/colorscales.js +19 -19
- package/dist/esm/constants/constants.js +53 -38
- package/dist/esm/context/DatasetContext.js +34 -23
- package/dist/esm/context/FilterContext.js +11 -8
- package/dist/esm/context/SettingsContext.js +341 -126
- package/dist/esm/context/ZarrDataContext.js +8 -6
- package/dist/esm/helpers/color-helper.js +5 -5
- package/dist/esm/helpers/map-helper.js +4 -3
- package/dist/esm/helpers/zarr-helper.js +6 -6
- package/dist/esm/index.js +22 -22
- package/dist/esm/utils/Filter.js +22 -17
- package/dist/esm/utils/Histogram.js +39 -37
- package/dist/esm/utils/ImageViewer.js +12 -8
- package/dist/esm/utils/Legend.js +44 -36
- package/dist/esm/utils/LoadingIndicators.js +16 -13
- package/dist/esm/utils/Resolver.js +201 -0
- package/dist/esm/utils/Skeleton.js +11 -10
- package/dist/esm/utils/StyledTooltip.js +38 -0
- package/dist/esm/utils/VirtualizedList.js +37 -29
- package/dist/esm/utils/errors.js +15 -15
- package/dist/esm/utils/requests.js +24 -12
- package/dist/esm/utils/search.js +7 -7
- package/dist/esm/utils/string.js +7 -7
- package/dist/esm/utils/zarrData.js +27 -28
- package/package.json +21 -8
- package/scss/cherita-bootstrap.scss +2 -2
- package/scss/cherita.scss +65 -17
- package/scss/components/accordions.scss +15 -2
- package/scss/components/layouts.scss +116 -30
- package/scss/components/lists.scss +16 -5
- package/scss/components/plotly.scss +40 -23
- package/scss/components/plots.scss +14 -1
- package/dist/cjs/components/full-page/FullPagePseudospatial.js +0 -157
- package/dist/esm/components/full-page/FullPagePseudospatial.js +0 -149
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
const _excluded = ["size", "colour"];
|
|
2
|
+
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; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
6
|
+
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); }
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
9
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
10
|
+
export default function ScatterplotIcon(_ref) {
|
|
11
|
+
let {
|
|
12
|
+
size = 40,
|
|
13
|
+
colour = '#000'
|
|
14
|
+
} = _ref,
|
|
15
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
16
|
+
// Points with cluster assignments
|
|
17
|
+
const points = [
|
|
18
|
+
// Cluster 0
|
|
19
|
+
{
|
|
20
|
+
x: 15.2,
|
|
21
|
+
y: 35.9,
|
|
22
|
+
cluster: 0
|
|
23
|
+
}, {
|
|
24
|
+
x: 10.0,
|
|
25
|
+
y: 38.0,
|
|
26
|
+
cluster: 0
|
|
27
|
+
}, {
|
|
28
|
+
x: 12.3,
|
|
29
|
+
y: 40.7,
|
|
30
|
+
cluster: 0
|
|
31
|
+
}, {
|
|
32
|
+
x: 15.7,
|
|
33
|
+
y: 39.9,
|
|
34
|
+
cluster: 0
|
|
35
|
+
}, {
|
|
36
|
+
x: 8.1,
|
|
37
|
+
y: 42.2,
|
|
38
|
+
cluster: 0
|
|
39
|
+
}, {
|
|
40
|
+
x: 10.8,
|
|
41
|
+
y: 44.5,
|
|
42
|
+
cluster: 0
|
|
43
|
+
}, {
|
|
44
|
+
x: 14.3,
|
|
45
|
+
y: 44.6,
|
|
46
|
+
cluster: 0
|
|
47
|
+
}, {
|
|
48
|
+
x: 7.4,
|
|
49
|
+
y: 46.7,
|
|
50
|
+
cluster: 0
|
|
51
|
+
}, {
|
|
52
|
+
x: 11.1,
|
|
53
|
+
y: 48.8,
|
|
54
|
+
cluster: 0
|
|
55
|
+
}, {
|
|
56
|
+
x: 14.8,
|
|
57
|
+
y: 48.5,
|
|
58
|
+
cluster: 0
|
|
59
|
+
}, {
|
|
60
|
+
x: 12.6,
|
|
61
|
+
y: 52.1,
|
|
62
|
+
cluster: 0
|
|
63
|
+
},
|
|
64
|
+
// Cluster 1
|
|
65
|
+
{
|
|
66
|
+
x: 29.4,
|
|
67
|
+
y: 37.0,
|
|
68
|
+
cluster: 1
|
|
69
|
+
}, {
|
|
70
|
+
x: 26.1,
|
|
71
|
+
y: 40.2,
|
|
72
|
+
cluster: 1
|
|
73
|
+
}, {
|
|
74
|
+
x: 29.8,
|
|
75
|
+
y: 42.0,
|
|
76
|
+
cluster: 1
|
|
77
|
+
}, {
|
|
78
|
+
x: 33.0,
|
|
79
|
+
y: 39.5,
|
|
80
|
+
cluster: 1
|
|
81
|
+
}, {
|
|
82
|
+
x: 34.9,
|
|
83
|
+
y: 43.6,
|
|
84
|
+
cluster: 1
|
|
85
|
+
}, {
|
|
86
|
+
x: 31.5,
|
|
87
|
+
y: 46.2,
|
|
88
|
+
cluster: 1
|
|
89
|
+
}, {
|
|
90
|
+
x: 29.3,
|
|
91
|
+
y: 49.5,
|
|
92
|
+
cluster: 1
|
|
93
|
+
}, {
|
|
94
|
+
x: 26.7,
|
|
95
|
+
y: 45.2,
|
|
96
|
+
cluster: 1
|
|
97
|
+
},
|
|
98
|
+
// Cluster 2
|
|
99
|
+
{
|
|
100
|
+
x: 21.6,
|
|
101
|
+
y: 53.1,
|
|
102
|
+
cluster: 2
|
|
103
|
+
}, {
|
|
104
|
+
x: 25.3,
|
|
105
|
+
y: 53.9,
|
|
106
|
+
cluster: 2
|
|
107
|
+
}, {
|
|
108
|
+
x: 25.8,
|
|
109
|
+
y: 57.9,
|
|
110
|
+
cluster: 2
|
|
111
|
+
}, {
|
|
112
|
+
x: 22.1,
|
|
113
|
+
y: 57.4,
|
|
114
|
+
cluster: 2
|
|
115
|
+
}, {
|
|
116
|
+
x: 18.4,
|
|
117
|
+
y: 56.0,
|
|
118
|
+
cluster: 2
|
|
119
|
+
}, {
|
|
120
|
+
x: 18.6,
|
|
121
|
+
y: 59.8,
|
|
122
|
+
cluster: 2
|
|
123
|
+
}, {
|
|
124
|
+
x: 22.5,
|
|
125
|
+
y: 61.7,
|
|
126
|
+
cluster: 2
|
|
127
|
+
}];
|
|
128
|
+
const radius = 1.8;
|
|
129
|
+
const opacity = 1.0; // uniform expression
|
|
130
|
+
|
|
131
|
+
// Compute viewBox dynamically
|
|
132
|
+
const xs = points.map(p => p.x);
|
|
133
|
+
const ys = points.map(p => p.y);
|
|
134
|
+
const minX = Math.min(...xs) - radius;
|
|
135
|
+
const minY = Math.min(...ys) - radius;
|
|
136
|
+
const maxX = Math.max(...xs) + radius;
|
|
137
|
+
const maxY = Math.max(...ys) + radius;
|
|
138
|
+
return /*#__PURE__*/_jsx("svg", _objectSpread(_objectSpread({
|
|
139
|
+
width: size,
|
|
140
|
+
height: size,
|
|
141
|
+
viewBox: "".concat(minX, " ").concat(minY, " ").concat(maxX - minX, " ").concat(maxY - minY),
|
|
142
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
143
|
+
}, props), {}, {
|
|
144
|
+
children: points.map((_ref2, i) => {
|
|
145
|
+
let {
|
|
146
|
+
x,
|
|
147
|
+
y
|
|
148
|
+
} = _ref2;
|
|
149
|
+
return /*#__PURE__*/_jsx("circle", {
|
|
150
|
+
cx: x,
|
|
151
|
+
cy: y,
|
|
152
|
+
r: radius,
|
|
153
|
+
fill: colour,
|
|
154
|
+
opacity: opacity
|
|
155
|
+
}, i);
|
|
156
|
+
})
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
const _excluded = ["size", "colour"];
|
|
2
|
+
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; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
6
|
+
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); }
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
9
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
10
|
+
export default function ScatterplotIcon(_ref) {
|
|
11
|
+
let {
|
|
12
|
+
size = 40,
|
|
13
|
+
colour = '#000'
|
|
14
|
+
} = _ref,
|
|
15
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
16
|
+
// Points with cluster assignments
|
|
17
|
+
const points = [
|
|
18
|
+
// Cluster 0
|
|
19
|
+
{
|
|
20
|
+
x: 15.2,
|
|
21
|
+
y: 35.9,
|
|
22
|
+
cluster: 0
|
|
23
|
+
}, {
|
|
24
|
+
x: 10.0,
|
|
25
|
+
y: 38.0,
|
|
26
|
+
cluster: 0
|
|
27
|
+
}, {
|
|
28
|
+
x: 12.3,
|
|
29
|
+
y: 40.7,
|
|
30
|
+
cluster: 0
|
|
31
|
+
}, {
|
|
32
|
+
x: 15.7,
|
|
33
|
+
y: 39.9,
|
|
34
|
+
cluster: 0
|
|
35
|
+
}, {
|
|
36
|
+
x: 8.1,
|
|
37
|
+
y: 42.2,
|
|
38
|
+
cluster: 0
|
|
39
|
+
}, {
|
|
40
|
+
x: 10.8,
|
|
41
|
+
y: 44.5,
|
|
42
|
+
cluster: 0
|
|
43
|
+
}, {
|
|
44
|
+
x: 14.3,
|
|
45
|
+
y: 44.6,
|
|
46
|
+
cluster: 0
|
|
47
|
+
}, {
|
|
48
|
+
x: 7.4,
|
|
49
|
+
y: 46.7,
|
|
50
|
+
cluster: 0
|
|
51
|
+
}, {
|
|
52
|
+
x: 11.1,
|
|
53
|
+
y: 48.8,
|
|
54
|
+
cluster: 0
|
|
55
|
+
},
|
|
56
|
+
// Cluster 1
|
|
57
|
+
{
|
|
58
|
+
x: 29.4,
|
|
59
|
+
y: 37.0,
|
|
60
|
+
cluster: 1
|
|
61
|
+
}, {
|
|
62
|
+
x: 26.1,
|
|
63
|
+
y: 40.2,
|
|
64
|
+
cluster: 1
|
|
65
|
+
}, {
|
|
66
|
+
x: 29.8,
|
|
67
|
+
y: 42.0,
|
|
68
|
+
cluster: 1
|
|
69
|
+
}, {
|
|
70
|
+
x: 33.0,
|
|
71
|
+
y: 39.5,
|
|
72
|
+
cluster: 1
|
|
73
|
+
}, {
|
|
74
|
+
x: 34.9,
|
|
75
|
+
y: 43.6,
|
|
76
|
+
cluster: 1
|
|
77
|
+
}, {
|
|
78
|
+
x: 31.5,
|
|
79
|
+
y: 46.2,
|
|
80
|
+
cluster: 1
|
|
81
|
+
},
|
|
82
|
+
// Cluster 2
|
|
83
|
+
{
|
|
84
|
+
x: 21.6,
|
|
85
|
+
y: 53.1,
|
|
86
|
+
cluster: 2
|
|
87
|
+
}, {
|
|
88
|
+
x: 25.3,
|
|
89
|
+
y: 53.9,
|
|
90
|
+
cluster: 2
|
|
91
|
+
}, {
|
|
92
|
+
x: 25.8,
|
|
93
|
+
y: 57.9,
|
|
94
|
+
cluster: 2
|
|
95
|
+
}, {
|
|
96
|
+
x: 22.1,
|
|
97
|
+
y: 57.4,
|
|
98
|
+
cluster: 2
|
|
99
|
+
}, {
|
|
100
|
+
x: 18.4,
|
|
101
|
+
y: 56.0,
|
|
102
|
+
cluster: 2
|
|
103
|
+
}, {
|
|
104
|
+
x: 22.5,
|
|
105
|
+
y: 61.7,
|
|
106
|
+
cluster: 2
|
|
107
|
+
}];
|
|
108
|
+
const radius = 1.8;
|
|
109
|
+
const opacity = 1.0; // uniform expression
|
|
110
|
+
|
|
111
|
+
// Compute viewBox dynamically
|
|
112
|
+
const xs = points.map(p => p.x);
|
|
113
|
+
const ys = points.map(p => p.y);
|
|
114
|
+
const minX = Math.min(...xs) - radius;
|
|
115
|
+
const minY = Math.min(...ys) - radius;
|
|
116
|
+
const maxX = Math.max(...xs) + radius;
|
|
117
|
+
const maxY = Math.max(...ys) + radius;
|
|
118
|
+
return /*#__PURE__*/_jsx("svg", _objectSpread(_objectSpread({
|
|
119
|
+
width: size,
|
|
120
|
+
height: size,
|
|
121
|
+
viewBox: "".concat(minX, " ").concat(minY, " ").concat(maxX - minX, " ").concat(maxY - minY),
|
|
122
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
123
|
+
}, props), {}, {
|
|
124
|
+
children: points.map((_ref2, i) => {
|
|
125
|
+
let {
|
|
126
|
+
x,
|
|
127
|
+
y
|
|
128
|
+
} = _ref2;
|
|
129
|
+
return /*#__PURE__*/_jsx("circle", {
|
|
130
|
+
cx: x,
|
|
131
|
+
cy: y,
|
|
132
|
+
r: radius,
|
|
133
|
+
fill: colour,
|
|
134
|
+
opacity: opacity
|
|
135
|
+
}, i);
|
|
136
|
+
})
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const _excluded = ["size", "colour"];
|
|
2
|
+
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; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
6
|
+
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); }
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
9
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
10
|
+
export default function ViolinPlotIcon(_ref) {
|
|
11
|
+
let {
|
|
12
|
+
size = 40,
|
|
13
|
+
colour = '#000'
|
|
14
|
+
} = _ref,
|
|
15
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
16
|
+
return /*#__PURE__*/_jsx("svg", _objectSpread(_objectSpread({
|
|
17
|
+
viewBox: "0 0 37 40",
|
|
18
|
+
width: size,
|
|
19
|
+
height: size,
|
|
20
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
21
|
+
}, props), {}, {
|
|
22
|
+
children: /*#__PURE__*/_jsxs("g", {
|
|
23
|
+
fill: colour,
|
|
24
|
+
stroke: colour,
|
|
25
|
+
strokeWidth: "0.5",
|
|
26
|
+
transform: "translate(-12 -8)",
|
|
27
|
+
children: [/*#__PURE__*/_jsx("path", {
|
|
28
|
+
d: "M19.9971,24.5 A6.3078,6.3078 0 0 0 18.5732,20.8389 7.1479,7.1479 0 0 1 16.9971,16.5 V16.0029 H16.0029 V16.5 a7.1479,7.1479 0 0 1 -1.5761,4.3389 6.3078,6.3078 0 0 0 -1.4239,3.6611 12.4967,12.4967 0 0 1 -0.4853,3.38 13.5076,13.5076 0 0 0 -0.5147,3.62 6.3078,6.3078 0 0 0 1.4239,3.6611 7.1479,7.1479 0 0 1 1.5761,4.3389 19.2486,19.2486 0 0 0 0.5664,4.7246 13.6883,13.6883 0 0 1 0.4336,3.2754 v0.4971 h0.9942 V47.5 A13.6883,13.6883 0 0 1 17.4307,44.2246 19.2486,19.2486 0 0 0 17.9971,39.5 7.1479,7.1479 0 0 1 19.5732,35.1611 6.3078,6.3078 0 0 0 20.9971,31.5 13.5076,13.5076 0 0 0 20.4824,27.88 12.4967,12.4967 0 0 1 19.9971,24.5 Z"
|
|
29
|
+
}), /*#__PURE__*/_jsx("path", {
|
|
30
|
+
d: "M34.6436,12.6963 C32.8506,11.5537 30.9971,10.3711 30.9971,8.5 V8.0029 H30.0029 V8.5 c0,1.8711 -1.8535,3.0537 -3.6465,4.1963 -1.7246,1.1006 -3.3535,2.1387 -3.3535,3.8037 0,1.6152 1.2188,2.7031 2.3975,3.7549 1.2793,1.1426 2.6025,2.3242 2.6025,4.2451 a18.1508,18.1508 0 0 1 -0.542,4.5068 14.5,14.5 0 0 0 -0.458,3.4932 6.038,6.038 0 0 0 1.6,3.7979 5.179,5.179 0 0 1 1.4,3.2021 v0.4971 h0.9942 V39.5 a5.179,5.179 0 0 1 1.4,-3.2021 6.038,6.038 0 0 0 1.6,-3.7979 14.5,14.5 0 0 0 -0.458,-3.4932 18.1508,18.1508 0 0 1 -0.542,-4.5068 c0,-1.9209 1.3232,-3.1025 2.6025,-4.2451 1.1787,-1.0518 2.3975,-2.14 2.3975,-3.7549 0,-1.665 -1.6289,-2.7031 -3.3535,-3.8037 z"
|
|
31
|
+
}), /*#__PURE__*/_jsx("path", {
|
|
32
|
+
d: "M47.3975,35.7021 A5.179,5.179 0 0 1 45.9975,32.5 14.5,14.5 0 0 0 45.5395,29.0068 18.1508,18.1508 0 0 1 44.9975,24.5 V24.0029 H44.0033 V24.5 a18.1508,18.1508 0 0 1 -0.542,4.5068 14.5,14.5 0 0 0 -0.458,3.4932 5.179,5.179 0 0 1 -1.4,3.2021 6.038,6.038 0 0 0 -1.6,3.7979 c0,1.582 0.9717,2.667 1.9121,3.7158 1.0264,1.1455 2.0879,2.3311 2.0879,4.2842 v0.4971 h0.9942 V47.5 c0,-1.9531 1.0615,-3.1387 2.0879,-4.2842 0.94,-1.0488 1.9121,-2.1338 1.9121,-3.7158 a6.038,6.038 0 0 0 -1.6,-3.7979 z"
|
|
33
|
+
})]
|
|
34
|
+
})
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
@@ -3,18 +3,32 @@ 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 _ from
|
|
8
|
-
import {
|
|
9
|
-
import Plot from
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
20
|
+
export function Matrixplot(_ref) {
|
|
21
|
+
let {
|
|
22
|
+
showObsBtn = false,
|
|
23
|
+
showVarsBtn = false,
|
|
24
|
+
showCtrlsBtn = false,
|
|
25
|
+
setShowObs,
|
|
26
|
+
setShowVars,
|
|
27
|
+
setShowControls,
|
|
28
|
+
plotType,
|
|
29
|
+
setPlotType
|
|
30
|
+
} = _ref;
|
|
31
|
+
const ENDPOINT = 'matrixplot';
|
|
18
32
|
const dataset = useDataset();
|
|
19
33
|
const settings = useSettings();
|
|
20
34
|
const {
|
|
@@ -25,46 +39,27 @@ export function Matrixplot() {
|
|
|
25
39
|
const [data, setData] = useState([]);
|
|
26
40
|
const [layout, setLayout] = useState({});
|
|
27
41
|
const [hasSelections, setHasSelections] = useState(false);
|
|
28
|
-
const
|
|
42
|
+
const selectedObs = useSelectedObs();
|
|
43
|
+
const selectedMultiVar = useSelectedMultiVar();
|
|
44
|
+
const params = useMemo(() => ({
|
|
29
45
|
url: dataset.url,
|
|
30
|
-
obsCol:
|
|
31
|
-
obsValues: !(
|
|
32
|
-
|
|
33
|
-
return (_settings$selectedObs4 = settings.selectedObs) === null || _settings$selectedObs4 === void 0 ? void 0 : _settings$selectedObs4.codesMap[c];
|
|
34
|
-
}),
|
|
35
|
-
varKeys: settings.selectedMultiVar.map(i => i.isSet ? {
|
|
46
|
+
obsCol: selectedObs,
|
|
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),
|
|
48
|
+
varKeys: selectedMultiVar.map(i => i.isSet ? {
|
|
36
49
|
name: i.name,
|
|
37
50
|
indices: i.vars.map(v => v.index)
|
|
38
51
|
} : i.index),
|
|
39
52
|
obsIndices: isSliced ? [...(obsIndices || [])] : null,
|
|
40
53
|
standardScale: settings.controls.scale.matrixplot,
|
|
41
54
|
varNamesCol: dataset.varNamesCol
|
|
42
|
-
});
|
|
55
|
+
}), [dataset.url, dataset.varNamesCol, isSliced, obsIndices, selectedMultiVar, selectedObs, settings.controls.scale.matrixplot]);
|
|
43
56
|
useEffect(() => {
|
|
44
|
-
if (
|
|
57
|
+
if (selectedObs && selectedMultiVar.length) {
|
|
45
58
|
setHasSelections(true);
|
|
46
59
|
} else {
|
|
47
60
|
setHasSelections(false);
|
|
48
61
|
}
|
|
49
|
-
|
|
50
|
-
var _settings$selectedObs5, _settings$selectedObs6, _settings$selectedObs7;
|
|
51
|
-
return _objectSpread(_objectSpread({}, p), {}, {
|
|
52
|
-
url: dataset.url,
|
|
53
|
-
obsCol: settings.selectedObs,
|
|
54
|
-
obsValues: !((_settings$selectedObs5 = settings.selectedObs) !== null && _settings$selectedObs5 !== void 0 && _settings$selectedObs5.omit.length) ? null : _.difference(_.values((_settings$selectedObs6 = settings.selectedObs) === null || _settings$selectedObs6 === void 0 ? void 0 : _settings$selectedObs6.codes), (_settings$selectedObs7 = settings.selectedObs) === null || _settings$selectedObs7 === void 0 ? void 0 : _settings$selectedObs7.omit).map(c => {
|
|
55
|
-
var _settings$selectedObs8;
|
|
56
|
-
return (_settings$selectedObs8 = settings.selectedObs) === null || _settings$selectedObs8 === void 0 ? void 0 : _settings$selectedObs8.codesMap[c];
|
|
57
|
-
}),
|
|
58
|
-
varKeys: settings.selectedMultiVar.map(i => i.isSet ? {
|
|
59
|
-
name: i.name,
|
|
60
|
-
indices: i.vars.map(v => v.index)
|
|
61
|
-
} : i.index),
|
|
62
|
-
obsIndices: isSliced ? [...(obsIndices || [])] : null,
|
|
63
|
-
standardScale: settings.controls.scale.matrixplot,
|
|
64
|
-
varNamesCol: dataset.varNamesCol
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
}, [settings.controls.scale.matrixplot, settings.selectedMultiVar, settings.selectedObs, dataset.url, dataset.varNamesCol, obsIndices, isSliced]);
|
|
62
|
+
}, [selectedMultiVar.length, selectedObs]);
|
|
68
63
|
const updateColorscale = useCallback(colorscale => {
|
|
69
64
|
setLayout(l => {
|
|
70
65
|
return _objectSpread(_objectSpread({}, l), {}, {
|
|
@@ -79,41 +74,76 @@ export function Matrixplot() {
|
|
|
79
74
|
isPending,
|
|
80
75
|
serverError
|
|
81
76
|
} = useDebouncedFetch(ENDPOINT, params, 500, {
|
|
82
|
-
|
|
77
|
+
isEnabled: params => !!params.obsCol && !!params.varKeys.length
|
|
83
78
|
});
|
|
84
79
|
useEffect(() => {
|
|
85
|
-
if (hasSelections && !isPending && !serverError) {
|
|
80
|
+
if (hasSelections && !!fetchedData && !isPending && !serverError) {
|
|
86
81
|
setData(fetchedData.data);
|
|
87
82
|
setLayout(fetchedData.layout);
|
|
88
83
|
updateColorscale(colorscale.current);
|
|
84
|
+
} else {
|
|
85
|
+
setData([]);
|
|
86
|
+
setLayout({});
|
|
89
87
|
}
|
|
90
88
|
}, [fetchedData, hasSelections, isPending, serverError, updateColorscale]);
|
|
91
89
|
useEffect(() => {
|
|
92
90
|
colorscale.current = settings.controls.colorScale;
|
|
93
91
|
updateColorscale(colorscale.current);
|
|
94
92
|
}, [settings.controls.colorScale, updateColorscale]);
|
|
93
|
+
const customModeBarButtons = _.compact([showObsBtn && ObsPlotlyToolbar({
|
|
94
|
+
onClick: setShowObs
|
|
95
|
+
}), showVarsBtn && VarPlotlyToolbar({
|
|
96
|
+
onClick: setShowVars
|
|
97
|
+
}), showCtrlsBtn && ControlsPlotlyToolbar({
|
|
98
|
+
onClick: setShowControls
|
|
99
|
+
})]);
|
|
100
|
+
const modeBarButtons = customModeBarButtons.length ? [customModeBarButtons, PLOTLY_MODEBAR_BUTTONS] : [PLOTLY_MODEBAR_BUTTONS];
|
|
95
101
|
if (!serverError) {
|
|
96
102
|
if (hasSelections) {
|
|
97
|
-
return /*#__PURE__*/
|
|
98
|
-
className: "cherita-matrixplot position-relative"
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
104
|
+
className: "cherita-plot cherita-matrixplot position-relative",
|
|
105
|
+
children: [isPending && /*#__PURE__*/_jsx(LoadingSpinner, {}), /*#__PURE__*/_jsx(Plot, {
|
|
106
|
+
data: data,
|
|
107
|
+
layout: layout,
|
|
108
|
+
useResizeHandler: true,
|
|
109
|
+
style: {
|
|
110
|
+
width: '100%',
|
|
111
|
+
height: '100%'
|
|
112
|
+
},
|
|
113
|
+
config: {
|
|
114
|
+
displaylogo: false,
|
|
115
|
+
modeBarButtons: modeBarButtons
|
|
116
|
+
}
|
|
117
|
+
})]
|
|
118
|
+
});
|
|
108
119
|
}
|
|
109
|
-
return /*#__PURE__*/
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
120
|
+
return /*#__PURE__*/_jsx(PlotAlert, {
|
|
121
|
+
variant: "info",
|
|
122
|
+
heading: "Set up your matrix plot",
|
|
123
|
+
plotType: plotType,
|
|
124
|
+
setPlotType: setPlotType,
|
|
125
|
+
children: /*#__PURE__*/_jsxs("p", {
|
|
126
|
+
className: "p-0 m-0",
|
|
127
|
+
children: ["Select a", ' ', showObsBtn ? /*#__PURE__*/_jsx(Button, {
|
|
128
|
+
variant: "link",
|
|
129
|
+
className: "border-0 p-0 align-baseline",
|
|
130
|
+
onClick: setShowObs,
|
|
131
|
+
children: "category"
|
|
132
|
+
}) : 'category', ' ', "to group observations, then choose one or more", ' ', showVarsBtn ? /*#__PURE__*/_jsx(Button, {
|
|
133
|
+
variant: "link",
|
|
134
|
+
className: "border-0 p-0 align-baseline",
|
|
135
|
+
onClick: setShowVars,
|
|
136
|
+
children: "features"
|
|
137
|
+
}) : 'features', ' ', "to display the matrix plot."]
|
|
138
|
+
})
|
|
139
|
+
});
|
|
114
140
|
} else {
|
|
115
|
-
return /*#__PURE__*/
|
|
116
|
-
variant: "danger"
|
|
117
|
-
|
|
141
|
+
return /*#__PURE__*/_jsx(PlotAlert, {
|
|
142
|
+
variant: "danger",
|
|
143
|
+
heading: "Error displaying the matrix plot",
|
|
144
|
+
plotType: plotType,
|
|
145
|
+
setPlotType: setPlotType,
|
|
146
|
+
children: serverError.message || 'An unexpected error occurred while generating the plot.'
|
|
147
|
+
});
|
|
118
148
|
}
|
|
119
149
|
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { Form } from 'react-bootstrap';
|
|
2
|
+
import { ColorscaleSelect, ScaleSelect } from '../controls/Controls';
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
4
4
|
export function MatrixplotControls() {
|
|
5
|
-
return /*#__PURE__*/
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
6
|
+
children: /*#__PURE__*/_jsxs(Form, {
|
|
7
|
+
children: [/*#__PURE__*/_jsx(ColorscaleSelect, {}), /*#__PURE__*/_jsx(ScaleSelect, {
|
|
8
|
+
plot: "matrixplot"
|
|
9
|
+
})]
|
|
10
|
+
})
|
|
11
|
+
});
|
|
8
12
|
}
|