Skip to content

Commit 5fd7920

Browse files
committed
return messages when no pattern is identified
1 parent 9055645 commit 5fd7920

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

src/vitessce/widget_plugins/spatial_query.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,27 +128,35 @@ def _build_plugin_esm(cell_type_list):
128128
129129
const [imgSrc, setImgSrc] = React.useState(null);
130130
const [loading, setLoading] = React.useState(false);
131+
const [statusMsg, setStatusMsg] = React.useState(null);
131132
132133
const uuid = queryParams?.uuid;
133134
134135
React.useEffect(() => {{
135136
if (uuid == null) return;
136137
setLoading(true);
138+
setStatusMsg(null);
137139
invokeCommand('get_heatmap', {{ uuid }}, []).then(([result]) => {{
138140
if (result?.img) {{
139141
setImgSrc('data:image/png;base64,' + result.img);
142+
setStatusMsg(null);
140143
}} else {{
141144
setImgSrc(null);
145+
setStatusMsg(result?.message ?? 'No results.');
142146
}}
143147
setLoading(false);
144-
}}).catch(() => setLoading(false));
148+
}}).catch(() => {{
149+
setImgSrc(null);
150+
setStatusMsg('Error loading heatmap.');
151+
setLoading(false);
152+
}});
145153
}}, [uuid]);
146154
147155
return (
148156
<div className="spatial-query-heatmap" style={{{{ width: '100%', height: '100%', overflow: 'auto', display: 'flex', alignItems: 'center', justifyContent: 'center' }}}}>
149157
{{loading && <p>Loading heatmap...</p>}}
150158
{{!loading && imgSrc && <img src={{imgSrc}} style={{{{ maxWidth: '100%', maxHeight: '100%' }}}} />}}
151-
{{!loading && !imgSrc && <p style={{{{ color: '#888' }}}}>Run a query to see the heatmap.</p>}}
159+
{{!loading && !imgSrc && <p style={{{{ color: '#888' }}}}>{{statusMsg ?? 'Run a query to see the heatmap.'}}</p>}}
152160
</div>
153161
);
154162
}}
@@ -333,13 +341,15 @@ def _render_heatmap_base64(self, fp_tree, query_type, cell_type_of_interest):
333341

334342
def _handle_get_heatmap(self, _message, _buffers):
335343
if self._last_fp_tree is None:
336-
return {"img": None}, []
344+
return {"img": None, "message": None}, []
345+
if len(self._last_fp_tree) == 0:
346+
return {"img": None, "message": "No significant patterns found."}, []
337347
img_b64 = self._render_heatmap_base64(
338348
self._last_fp_tree,
339349
self._last_query_type,
340350
self._last_cell_type_of_interest,
341351
)
342-
return {"img": img_b64}, []
352+
return {"img": img_b64, "message": None}, []
343353

344354
def get_matching_cell_ids(self, cell_type, cell_i):
345355
cell_ids = [self.cell_i_to_cell_id[i] for i in cell_i]

0 commit comments

Comments
 (0)