diff --git a/cirro-studio/package.json b/cirro-studio/package.json index 79c1a52..05d68ec 100644 --- a/cirro-studio/package.json +++ b/cirro-studio/package.json @@ -1,7 +1,7 @@ { "name": "spatial-data-studio-cirro", "private": true, - "version": "1.9.1", + "version": "1.10.0", "type": "module", "scripts": { "dev": "vite", diff --git a/cirro-studio/src/app/Shell.tsx b/cirro-studio/src/app/Shell.tsx index e251334..a724e75 100644 --- a/cirro-studio/src/app/Shell.tsx +++ b/cirro-studio/src/app/Shell.tsx @@ -52,7 +52,7 @@ function ProjectPicker({ projects, loggedIn, onSettings }: { projects: CirroProj // What read-only means here, and how to keep work for good. function ReadOnlyBadge({ loggedIn, onSignIn }: { loggedIn: boolean; onSignIn: () => void }) { return ( - + Read-only ▾}> {() => (

You can look and run every analysis here. What you save stays in this browser: not on other computers, and nobody else sees it.

diff --git a/cirro-studio/src/app/route.ts b/cirro-studio/src/app/route.ts index 003107f..a66d83d 100644 --- a/cirro-studio/src/app/route.ts +++ b/cirro-studio/src/app/route.ts @@ -103,6 +103,10 @@ const sameAddress = (a: string, b: string) => { return sorted(a) === sorted(b); }; +/** Moving to another stage, or back to the overview, leaves a stage's selection and search + * behind. */ +export const LEAVING_STAGE = { [SELECT_PARAM]: null, [QUERY_PARAM]: null, [FILTER_PARAM]: null }; + /** Stepping out (Esc, ×) goes back in history when the previous entry is where it leads, * so stepping in and out doesn't pile up entries; otherwise it navigates there. */ export function stepBack(update: Record) { diff --git a/cirro-studio/src/figures/ChartFigure.tsx b/cirro-studio/src/figures/ChartFigure.tsx index 413f06f..a3b5170 100644 --- a/cirro-studio/src/figures/ChartFigure.tsx +++ b/cirro-studio/src/figures/ChartFigure.tsx @@ -2,12 +2,14 @@ // a heatmap from neighborhood enrichment, stacked bars from a composition. import { useEffect, useRef, useState } from 'react'; import type { AsyncReadable } from '@zarrita/storage'; +import { downloadBlob } from '@cirrobio/spatial-viewer'; import { Heatmap } from '../charts/Heatmap'; import { StackedBars } from '../charts/StackedBars'; import { Volcano } from '../charts/Volcano'; import { describeError } from '../cirro/session'; import { useSize } from '../lib/useSize'; import { GENE_TEST_COLUMN, matrixOf, readDataFrame, type DataFrame } from '../reports/store'; +import { fileStem, pngBlob, standaloneSvg, svgBlob } from './export'; import type { ChartSpec, FigureSpec } from './spec'; const num = (df: DataFrame, column: string) => { @@ -64,10 +66,41 @@ export function ChartFigure({ spec, store, table }: { spec: FigureSpec; store: R live = false; }; }, [store, table, resultPath, marksPath]); + const [exporting, setExporting] = useState(false); + // The chart as it is drawn here, at the width the figure was kept at. No PDF: the PDF + // writer loses the labels' halos and with them the labels, and the SVG is the vector copy. + const download = async (format: 'svg' | 'png') => { + const drawn = ref.current?.querySelector('svg'); + if (!drawn) return; + setProblem(null); + setExporting(true); + try { + const svg = standaloneSvg(drawn); + const page = { widthMm: spec.width_mm, heightMm: (spec.width_mm * drawn.clientHeight) / drawn.clientWidth }; + const blob = format === 'svg' ? svgBlob(svg) : await pngBlob(svg, page); + downloadBlob(blob, `${fileStem(spec.title)}.${format}`); + } catch (e) { + setProblem(describeError(e)); + } finally { + setExporting(false); + } + }; return (
-

{spec.title}

- {spec.caption &&

{spec.caption}

} +
+
+

{spec.title}

+ {spec.caption &&

{spec.caption}

} +
+ {chart && tables && ( +
+ Download + {(['png', 'svg'] as const).map((f) => ( + + ))} +
+ )} +
{problem &&

{problem}

} {chart && tables && width > 0 && }
diff --git a/cirro-studio/src/figures/export.ts b/cirro-studio/src/figures/export.ts index 7fd5683..66b8970 100644 --- a/cirro-studio/src/figures/export.ts +++ b/cirro-studio/src/figures/export.ts @@ -38,13 +38,37 @@ export function withPhys(png: Uint8Array, dpi: number): Uint8Array< return out; } +/** A figure's title as a file name, without its extension. */ +export const fileStem = (title: string) => title.trim().replace(/[^A-Za-z0-9]+/g, '-').replace(/^-|-$/g, '').toLowerCase() || 'figure'; + +type PageSize = Pick; + +// What a chart's stylesheet sets, which a file of its own has to carry itself. +const PAINT = ['fill', 'fill-opacity', 'stroke', 'stroke-width', 'stroke-dasharray', 'stroke-linejoin', 'paint-order', 'opacity', 'font-family', 'font-size', 'font-weight', 'text-anchor']; + +/** A chart drawn on the page as an SVG that stands alone: the paint its stylesheet gives + * each element written onto the element. */ +export function standaloneSvg(svg: SVGSVGElement): string { + const copy = svg.cloneNode(true) as SVGSVGElement; + const drawn = [svg, ...svg.querySelectorAll('*')]; + const copied = [copy, ...copy.querySelectorAll('*')]; + drawn.forEach((el, i) => { + const style = getComputedStyle(el); + for (const p of PAINT) copied[i].setAttribute(p, style.getPropertyValue(p)); + copied[i].removeAttribute('class'); + }); + copy.setAttribute('xmlns', 'http://www.w3.org/2000/svg'); + copy.setAttribute('viewBox', `0 0 ${svg.clientWidth} ${svg.clientHeight}`); + return new XMLSerializer().serializeToString(copy); +} + export function svgBlob(svg: string): Blob { return new Blob([svg], { type: 'image/svg+xml' }); } /** Rasterise the figure at `dpi`, white background, through the browser's own SVG * renderer (the same one that shows the preview). */ -export async function pngBlob(svg: string, layout: FigureLayout, dpi = FIGURE_DPI): Promise { +export async function pngBlob(svg: string, layout: PageSize, dpi = FIGURE_DPI): Promise { const width = Math.round((layout.widthMm / 25.4) * dpi); const height = Math.round((layout.heightMm / 25.4) * dpi); const url = URL.createObjectURL(svgBlob(svg)); diff --git a/cirro-studio/src/item/DraftBar.tsx b/cirro-studio/src/item/DraftBar.tsx index e7e429d..fcf525f 100644 --- a/cirro-studio/src/item/DraftBar.tsx +++ b/cirro-studio/src/item/DraftBar.tsx @@ -26,6 +26,7 @@ export function DraftBar({ wb, baseSize, datasetName }: { wb: Workbench; baseSiz · {formatBytes(wb.draftBytes)} to save + {wb.changes.length > 3 && +{wb.changes.length - 3} earlier} {wb.changes.slice(-3).map((c, i) => { const text = describeChange(c); return {text}; diff --git a/cirro-studio/src/item/Facts.tsx b/cirro-studio/src/item/Facts.tsx index 10ef7b3..4077afb 100644 --- a/cirro-studio/src/item/Facts.tsx +++ b/cirro-studio/src/item/Facts.tsx @@ -1,5 +1,6 @@ -// The line above a picture: its name, what it is, how big, where it came from and what -// it was made into, whose data it is (for public data), and a way to its page in Cirro. +// The line above a picture: its name, what it is, whose data it is (for public data), where +// it came from and what it was made into. Details holds the rest: how big, when it was +// added, and a way to its page in Cirro. import type { ReactNode } from 'react'; import type { CatalogItem } from '../data/model'; import { stageOf, type Library, type StageId } from '../app/library'; @@ -36,13 +37,10 @@ export function Facts({ title, item, origin, kind, stage, from, into, extra, uns )}

{title}

{kind} - {item.size > 0 && {formatBytes(item.size)}} - {dataset && {dataset.processName}} - {dataset?.createdAt && {formatDate(dataset.createdAt)}} - {credit && } + {extra} + {credit && } {from.length > 0 && from {from.map((k) => )}} {into.length > 0 && made into {into.slice(0, 3).map((k) => )}{into.length > 3 && +{into.length - 3}}} - {extra} {collection.access === 'write' && ( + )} void remove()} />
{problem &&

{problem}

} @@ -210,20 +214,6 @@ export function StorePage({ item, entity }: { item: StoreItem | VersionItem; ent let displayBody: ReactNode; if (onCanvas) { displayBody =
; - } else if (lens === 'composition' && displays.spatial) { - displayBody = ( -
-

The composition counts the {unit}s in each group of what the tissue is colored by, across the groups of another column if you choose one.

- updateEncoding(wb.key, 'spatial', { color_by: path })} /> - - {across && } -
- ); } else { displayBody =

Display settings apply to the tissue and the {unit} map.

; } @@ -259,16 +249,7 @@ export function StorePage({ item, entity }: { item: StoreItem | VersionItem; ent 1 ? ` ${wb.levels.length - 1}` : ''} · ${item.title}` : 'Spatial data'} stage="spatial" from={from} into={into} unsaved={wb.changes.length > 0} - extra={( - <> - {fields && {summary(fields, unit)}} - {saved > 0 && ( - - )} - - )} /> + extra={fields && {summary(fields, unit)}} /> {!wb.handle ? (
@@ -276,20 +257,34 @@ export function StorePage({ item, entity }: { item: StoreItem | VersionItem; ent
) : ( - - {onCanvas && ( + {(onCanvas || lens === 'composition') && (
- {/* What colors the cells, in reach on the view: the most common change there is. */} + {/* What colors the cells (and so what the composition counts), in reach on the + view: the most common change there is. */} {fields && displays[canvasSlot] && ( -
+
+ Color by updateEncoding(wb.key, canvasSlot, { color_by: path })} />
)} -
+ {lens === 'composition' && ( +
+ Across + f.kind === 'categorical')} value={across ?? ''} placeholder="The whole tissue" + onChange={(c) => navigate({ [ACROSS_PARAM]: c || null }, { replace: true })} /> + {/* The picker has no empty choice. */} + {across && ( + + )} +
+ )} + {onCanvas &&
}
)}
@@ -302,8 +297,9 @@ export function StorePage({ item, entity }: { item: StoreItem | VersionItem; ent chooseLens(`figure:${id}`)} /> ), }} - // Versions has nothing to set, so it takes the drawer's side of the page. - right={lens === 'versions' ? undefined : { + // Versions and a report have nothing to set, and the composition's two choices are on + // the bar, so they take the drawer's side of the page. + right={lens === 'versions' || lens === 'composition' || reportOpen ? undefined : { label: 'Display', icon: , content: ( diff --git a/cirro-studio/src/item/ViewFrame.tsx b/cirro-studio/src/item/ViewFrame.tsx index fea56bb..d8cb0b4 100644 --- a/cirro-studio/src/item/ViewFrame.tsx +++ b/cirro-studio/src/item/ViewFrame.tsx @@ -9,9 +9,8 @@ type Side = 'left' | 'right'; interface Open { left: boolean; right: boolean } const STORAGE_KEY = appKey('drawers'); -const LEFT_WIDTH = 300; -// A task's panel holds charts and tables, so the tasks drawer widens while one is open. -const TASK_WIDTH = 380; +// One width for the task list and an open task, so the views bar holds still between them. +const LEFT_WIDTH = 340; const RIGHT_WIDTH = 288; const GAP = 12; // The room a closed drawer's tab takes at the top corner, which the views bar keeps clear of. @@ -22,6 +21,9 @@ export const BAR_ROOM = 40; // Below this the drawers start closed, and only one is out at a time: both would cover // most of the view. const ROOMY_WIDTH = 1100; +// Below this a drawer covers close to half the view, so a page opens with both away +// whatever was kept open on a wider window. +const TIGHT_WIDTH = 860; function useNarrow(): boolean { const [narrow, setNarrow] = useState(() => window.innerWidth < ROOMY_WIDTH); @@ -34,6 +36,7 @@ function useNarrow(): boolean { } function initialOpen(): Open { + if (window.innerWidth < TIGHT_WIDTH) return { left: false, right: false }; try { const saved = JSON.parse(localStorage.getItem(STORAGE_KEY) ?? 'null') as Open | null; if (saved) return saved; @@ -98,13 +101,12 @@ export function useDrawers(working: boolean): Drawers { window.addEventListener('keydown', onKey); return () => window.removeEventListener('keydown', onKey); }, [toggle, toggleBoth]); - const left = working ? TASK_WIDTH : LEFT_WIDTH; // Kept as one object while the drawers stay put: the canvas host is rebuilt when it changes. const inset = useMemo( - () => ({ left: open.left ? left + GAP : 0, right: open.right ? RIGHT_WIDTH + GAP : 0 }), - [open.left, open.right, left], + () => ({ left: open.left ? LEFT_WIDTH + GAP : 0, right: open.right ? RIGHT_WIDTH + GAP : 0 }), + [open.left, open.right], ); - return { open, toggle, widths: { left, right: RIGHT_WIDTH }, inset }; + return { open, toggle, widths: { left: LEFT_WIDTH, right: RIGHT_WIDTH }, inset }; } const Chevron = ({ to }: { to: Side }) => ( @@ -149,8 +151,10 @@ function Drawer({ side, spec, open, onToggle }: { side: Side; spec: DrawerSpec; * chart rather than the tissue) keeps clear of the open drawers instead of running under * them. Without `right` (a view with nothing to set) the right drawer and its tab are * away, and the view has that side to itself. */ -export function ViewFrame({ drawers, left, right, bar, main, sheet = false }: { +export function ViewFrame({ drawers, left, right, bar, main, sheet = false, barRoom = BAR_ROOM }: { drawers: Drawers; left: DrawerSpec; right?: DrawerSpec; bar?: ReactNode; main: ReactNode; sheet?: boolean; + // The bar's measured room, where it can wrap to a second row. + barRoom?: number; }) { const insetRight = right ? drawers.inset.right : 0; const style = { @@ -158,7 +162,7 @@ export function ViewFrame({ drawers, left, right, bar, main, sheet = false }: { '--inset-left': `${drawers.inset.left}px`, '--inset-right': `${insetRight}px`, '--bar-left': `${drawers.open.left ? drawers.inset.left + GAP : TAB_ROOM}px`, '--bar-right': `${!right ? GAP : drawers.open.right ? insetRight + GAP : TAB_ROOM}px`, - '--bar-room': `${BAR_ROOM}px`, + '--bar-room': `${barRoom}px`, } as CSSProperties; return (
diff --git a/cirro-studio/src/map/Home.tsx b/cirro-studio/src/map/Home.tsx index 941da12..418ef7d 100644 --- a/cirro-studio/src/map/Home.tsx +++ b/cirro-studio/src/map/Home.tsx @@ -5,20 +5,25 @@ // only tells where they belong. import { useLayoutEffect, useMemo, useRef, useState, type MouseEvent } from 'react'; import { STAGES, type StageId } from '../app/library'; -import { LENS_PARAM, navigate, openItem, STAGE_PARAM } from '../app/route'; +import { LEAVING_STAGE, LENS_PARAM, navigate, openItem, STAGE_PARAM } from '../app/route'; import { useStudio } from '../app/studio'; import { formatBytes, plural, STAGE_ICONS, tint } from '../app/ui'; import { useSize } from '../lib/useSize'; import type { Bubble, Scene } from './BubbleLayer'; import { packCluster, type StageNode } from './nodes'; -const HEAD_HEIGHT = 150; -const FOOT_HEIGHT = 56; +const HEAD_HEIGHT = 176; +// The headings are smaller where the stages wrap (app.css), leaving the bubbles more of each row. +const NARROW_HEAD_HEIGHT = 124; +const FOOT_HEIGHT = 24; // The stylesheet's breakpoint (app.css, .map-landing) where the stages wrap to two // columns; the bubbles follow their labels into the second row. const TWO_COLUMNS_BELOW = 860; -// Items smaller than this share of the largest still draw as a visible dot. -const FLOOR_SHARE = 0.004; +// A bubble's area is the square root of its bytes, so a 10 GB store doesn't leave a 10 MB +// one a speck; and no bubble is narrower than this share of the largest where the project +// has room for that, so every item (a figure, which has no bytes of its own) is something +// to point at. +const FLOOR_WIDTH = 0.3; interface Placed { x: number; y: number; r: number; node: StageNode } @@ -29,15 +34,19 @@ export function Home({ nodes, onScene }: { nodes: Record; const layout = useMemo(() => { if (!width || !height) return null; - const perRow = width <= TWO_COLUMNS_BELOW ? 2 : STAGES.length; + const narrow = width <= TWO_COLUMNS_BELOW; + const perRow = narrow ? 2 : STAGES.length; + const head = narrow ? NARROW_HEAD_HEIGHT : HEAD_HEIGHT; const rows = Math.ceil(STAGES.length / perRow); const colWidth = width / perRow; const rowHeight = height / rows; - const maxD = Math.max(60, Math.min(colWidth - 40, rowHeight - HEAD_HEIGHT - FOOT_HEIGHT - 24)); + const maxD = Math.max(60, Math.min(colWidth - 40, rowHeight - head - FOOT_HEIGHT - 24)); const all = STAGES.flatMap((s) => nodes[s.id]); - const largest = Math.max(1, ...all.map((n) => n.size)); - const floor = largest * FLOOR_SHARE; - const weight = (n: StageNode) => Math.max(n.size, floor); + const areas = all.map((n) => Math.sqrt(n.size)); + // In a project of a thousand items the floor gives way (to half the mean area), or the + // small items together would crowd the large ones down to specks as well. + const floor = Math.min(Math.max(1, ...areas) * FLOOR_WIDTH ** 2, areas.reduce((a, b) => a + b, 0) / (2 * Math.max(1, areas.length))); + const weight = (n: StageNode) => Math.max(Math.sqrt(n.size), floor); const totals = STAGES.map((s) => nodes[s.id].reduce((sum, n) => sum + weight(n), 0)); const maxTotal = Math.max(1, ...totals); const placed = new Map(); @@ -45,10 +54,10 @@ export function Home({ nodes, onScene }: { nodes: Record; const d = totals[i] ? Math.max(48, maxD * Math.sqrt(totals[i] / maxTotal)) : 0; const cx = colWidth * ((i % perRow) + 0.5); const row = Math.floor(i / perRow); - const bottom = (row + 1) * rowHeight - (row === rows - 1 ? FOOT_HEIGHT : 0); - const cy = (row * rowHeight + HEAD_HEIGHT + bottom) / 2; + // On one line under the headings, the widest cluster just clear of them. + const cy = row * rowHeight + head + maxD / 2; if (d) { - for (const p of packCluster(nodes[s.id], d, floor)) placed.set(p.node.key, { ...p, x: cx - d / 2 + p.x, y: cy - d / 2 + p.y }); + for (const p of packCluster(nodes[s.id], d, weight)) placed.set(p.node.key, { ...p, x: cx - d / 2 + p.x, y: cy - d / 2 + p.y }); } return { stage: s, cx, cy, d }; }); @@ -80,7 +89,7 @@ export function Home({ nodes, onScene }: { nodes: Record; const open = (e: MouseEvent, stage: StageId) => { const n = bubbleAt(e, stage); if (n) openItem(n.target.datasetId, n.target.path, n.target.lens ? { [LENS_PARAM]: n.target.lens } : {}); - else navigate({ section: 'stage', [STAGE_PARAM]: stage }); + else navigate({ section: 'stage', [STAGE_PARAM]: stage, ...LEAVING_STAGE }); }; const totalBytes = (id: StageId) => nodes[id].reduce((s, n) => s + n.size, 0); @@ -123,7 +132,15 @@ export function Home({ nodes, onScene }: { nodes: Record; ))}
-

{hovered ? hovered.label : 'Click a bubble to open it, or a heading to list everything there.'}

+

Click a bubble to open it, or a heading to list everything there.

+ {hovered && layout?.placed.has(hovered.key) && (() => { + const p = layout.placed.get(hovered.key)!; + return ( +

+ {hovered.label}{hovered.size > 0 && · {formatBytes(hovered.size)}} +

+ ); + })()}
); } diff --git a/cirro-studio/src/map/StageTree.tsx b/cirro-studio/src/map/StageTree.tsx index f77443f..642e217 100644 --- a/cirro-studio/src/map/StageTree.tsx +++ b/cirro-studio/src/map/StageTree.tsx @@ -66,7 +66,12 @@ export function StageTree({ stage, nodes, state, onState, open, onOpenFolders, o const rowEl = (id: string) => grid.current?.querySelector(`[data-row="${CSS.escape(id)}"]`); const dotOf = (id: string) => rowEl(id)?.querySelector('.stage-tree-dot') ?? null; useEffect(() => { - if (state.selected) rowEl(state.selected)?.scrollIntoView({ block: 'nearest' }); + const row = state.selected ? rowEl(state.selected) : null; + if (!row) return; + row.scrollIntoView({ block: 'nearest' }); + // Then the look under it, when it fits: its Open is the point of selecting the row. + const look = row.nextElementSibling; + if (look?.classList.contains('stage-tree-look-row')) look.scrollIntoView({ block: 'nearest' }); }, [state.selected]); const current = rows.findIndex((r) => r.node.id === state.selected); // Far enough down to show the selected row, wherever it is. @@ -126,6 +131,7 @@ export function StageTree({ stage, nodes, state, onState, open, onOpenFolders, o }; const folders = countFolders(root); + const shown = keep ? mine.filter(keep).length : mine.length; const reading = catalog.status === 'scanning' ? ` · still reading ${catalog.toScan - catalog.scanned} datasets` : ''; if (!mine.length) { @@ -138,7 +144,7 @@ export function StageTree({ stage, nodes, state, onState, open, onOpenFolders, o

{info.label}

- {plural(mine.length, info.unit)} + {keep ? `${shown} of ${plural(mine.length, info.unit)}` : plural(mine.length, info.unit)} {root.bytes > 0 && ` · ${formatBytes(root.bytes)}`} {folders > 0 && ` · in ${plural(folders, ['folder', 'folders'])}`} {shared.length > 0 && · {shared.map(saidOfAll).join(' · ')}} @@ -164,9 +170,9 @@ export function StageTree({ stage, nodes, state, onState, open, onOpenFolders, o const id = filterId({ key: facet.key, text: v.text }); const on = state.filters.has(id); return ( - ); }))} @@ -242,6 +248,11 @@ export function StageTree({ stage, nodes, state, onState, open, onOpenFolders, o )} + {/* Outside the tab order: Enter on the row opens it. */} + {size && n.size > 0 && } diff --git a/cirro-studio/src/map/StageView.tsx b/cirro-studio/src/map/StageView.tsx index 711ccf5..46e54e1 100644 --- a/cirro-studio/src/map/StageView.tsx +++ b/cirro-studio/src/map/StageView.tsx @@ -6,7 +6,7 @@ import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type RefObject } from 'react'; import { STAGES, stageOf, type StageId } from '../app/library'; import { - FILTER_PARAM, FLAT_PARAM, LENS_PARAM, navigate, openItem, QUERY_PARAM, SELECT_PARAM, SORT_PARAM, STAGE_PARAM, stepBack, useRoute, + FILTER_PARAM, FLAT_PARAM, LEAVING_STAGE, LENS_PARAM, navigate, openItem, QUERY_PARAM, SELECT_PARAM, SORT_PARAM, STAGE_PARAM, stepBack, useRoute, } from '../app/route'; import { plural, STAGE_ICONS, tint } from '../app/ui'; import { useSize } from '../lib/useSize'; @@ -45,8 +45,6 @@ function addressOf(patch: Partial): Record { return out; } -// Moving to another stage, or back to the overview, leaves this stage's selection and search behind. -const leaving = { [SELECT_PARAM]: null, [QUERY_PARAM]: null, [FILTER_PARAM]: null }; function Rail({ current, nodes, slots }: { current: StageId; nodes: Record; slots: RefObject>>; @@ -55,7 +53,7 @@ function Rail({ current, nodes, slots }: {

- {nodes[stage].length > 0 &&

Double-click a row to open it · / to search

} + {nodes[stage].length > 0 &&

Click a row for its details · Open, double-click or Enter opens it · / to search

}
); diff --git a/cirro-studio/src/map/nodes.ts b/cirro-studio/src/map/nodes.ts index ccce652..8d7acc9 100644 --- a/cirro-studio/src/map/nodes.ts +++ b/cirro-studio/src/map/nodes.ts @@ -175,11 +175,10 @@ type PackedNode = HierarchyCircularNode; // one, so a minimap's padding doesn't take the room its bubbles need. const gapFor = (d: number) => Math.min(4, d / 60); -/** Packed circles, areas by bytes. Small items keep a floor so a figure is still a dot - * beside a 5 GB store. */ -function packTree(tree: Tree, d: number, floor: number): PackedNode { +/** Packed circles, areas by each item's `weight`. */ +function packTree(tree: Tree, d: number, weight: (n: StageNode) => number): PackedNode { const root = hierarchy(tree) - .sum((t) => (t.node ? Math.max(t.node.size, floor) : 0)) + .sum((t) => (t.node ? weight(t.node) : 0)) .sort((a, b) => (b.value ?? 0) - (a.value ?? 0)); const gap = gapFor(d); return pack().size([d, d]).padding((t) => (t.depth === 0 ? 2 * gap : gap))(root); @@ -187,8 +186,8 @@ function packTree(tree: Tree, d: number, floor: number): PackedNode { /** A stage's bubbles packed by folder into a circle `d` across, positioned from its * top-left corner: a column of the overview, or a stage's minimap in the rail. */ -export function packCluster(nodes: StageNode[], d: number, floor: number): { node: StageNode; x: number; y: number; r: number }[] { - return packTree(folderTree(nodes), d, floor).leaves() +export function packCluster(nodes: StageNode[], d: number, weight: (n: StageNode) => number): { node: StageNode; x: number; y: number; r: number }[] { + return packTree(folderTree(nodes), d, weight).leaves() .filter((l) => l.data.node) .map((l) => ({ node: l.data.node!, x: l.x, y: l.y, r: l.r })); } diff --git a/cirro-studio/src/reports/ReportView.tsx b/cirro-studio/src/reports/ReportView.tsx index 35893d8..d067639 100644 --- a/cirro-studio/src/reports/ReportView.tsx +++ b/cirro-studio/src/reports/ReportView.tsx @@ -2,7 +2,7 @@ // run, then the report its kind draws from the kept tables. import { lazy, Suspense, useEffect, useRef, useState, type LazyExoticComponent, type ReactElement } from 'react'; import type { CheckpointHandle } from '@cirrobio/spatial-viewer'; -import { LENS_PARAM, navigate } from '../app/route'; +import { LENS_PARAM, navigate, TASK_PARAM } from '../app/route'; import { describeError } from '../cirro/session'; import { useSize } from '../lib/useSize'; import { storeOf, type Workbench } from '../workbench/workbench'; @@ -64,7 +64,12 @@ export function ReportView({ result, wb, unit }: { result: KeptResult; wb: Workb const Report = REPORTS[result.meta.kind]; return (
- void remove()} /> + void remove()}> + {/* What clusters are for, without scrolling to the report's end for it. */} + {result.meta.kind === 'clusters' && ( + + )} + {problem &&

{problem}

} {!Report &&

This version of the app doesn't draw this kind of report; its tables are in the data.

} {Report && !table && !problem &&

Reading the result…

} diff --git a/cirro-studio/src/styles/app.css b/cirro-studio/src/styles/app.css index 533946f..4af193f 100644 --- a/cirro-studio/src/styles/app.css +++ b/cirro-studio/src/styles/app.css @@ -129,8 +129,9 @@ input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: .shell-breadcrumb { display: flex; align-items: center; gap: var(--sds-space-2); min-width: min(8em, 25vw); } .shell-access > .topbar-button { color: var(--sds-color-text-muted); font-size: var(--sds-text-xs); white-space: nowrap; - border: 1px solid var(--sds-color-border); border-radius: 999px; padding: 1px 8px; + border: 1px solid var(--sds-color-border); border-radius: 999px; padding: 1px 8px; flex: none; } +.shell-access > .topbar-button:hover { color: var(--sds-color-text); border-color: var(--sds-color-text-muted); } .shell-access-panel { width: 300px; padding: var(--sds-space-3); display: grid; gap: var(--sds-space-2); font-size: var(--sds-text-sm); white-space: normal; } .shell-access-panel .button { justify-self: start; } .shell-spacer { flex: 1 1 var(--sds-space-4); } @@ -188,7 +189,7 @@ input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: .map-home { position: relative; width: 100%; height: 100%; overflow: hidden; } .map-home-canvas { position: absolute; inset: 0; } .map-landing { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); } -.map-stage { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; display: grid; align-content: start; justify-items: center; padding: var(--sds-space-8) var(--sds-space-3) 0; border-radius: 18px; } +.map-stage { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; display: grid; align-content: start; justify-items: center; padding: 56px var(--sds-space-3) 0; border-radius: 18px; } .map-stage:hover { background: color-mix(in srgb, var(--c) 5%, transparent); } .map-stage-empty .map-icon, .map-stage-empty .map-stage-name { opacity: 0.55; } .map-stage-head { display: grid; justify-items: center; gap: 6px; text-align: center; } @@ -196,8 +197,13 @@ input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: .map-icon svg { width: 100%; height: 100%; display: block; } .map-rail-map svg { width: 28px; height: 28px; display: block; } .map-stage-name { font-size: var(--sds-text-2xl); font-weight: var(--sds-weight-semibold); } +/* A heading opens its stage's list. */ +.map-stage-name::after { content: ' ›'; color: var(--sds-color-text-muted); font-weight: normal; } +.map-stage:hover .map-stage-name::after { color: var(--c); } .map-stage-caption { font-size: var(--sds-text-sm); color: var(--sds-color-text-muted); } -.map-tagline { position: absolute; left: 0; right: 0; bottom: var(--sds-space-4); text-align: center; font-size: var(--sds-text-sm); color: var(--sds-color-text-muted); pointer-events: none; } +.map-tagline { position: absolute; left: 0; right: 0; top: var(--sds-space-4); margin: 0; text-align: center; font-size: var(--sds-text-sm); color: var(--sds-color-text-muted); pointer-events: none; } +/* The name of the bubble under the pointer, just over it. */ +.map-bubble-name { position: absolute; z-index: 3; margin: 0; transform: translate(-50%, calc(-100% - 6px)); white-space: nowrap; pointer-events: none; font-size: var(--sds-text-sm); font-weight: var(--sds-weight-medium); padding: 2px var(--sds-space-2); border-radius: var(--sds-radius-md); background: var(--sds-color-surface-raised); border: 1px solid var(--sds-color-border); box-shadow: var(--sds-shadow-raised); } .map-links path { fill: none; stroke: var(--sds-color-text-muted); stroke-width: 1.2; stroke-dasharray: 3 4; opacity: 0.55; } /* The words of a view arrive as its bubbles settle; the lineage lines once they have. */ .map-landing, .map-tagline, .map-rail, .map-bar { animation: fade-in 0.45s ease 0.15s both; } @@ -220,13 +226,16 @@ input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: /* Names are placed for where a bubble ends up, so they wait until it is there. */ .bubble-layer-moving .bubble-label, .bubble-layer-moving .bubble-name { opacity: 0; transition: none; } -.map-stage-view { display: grid; grid-template-columns: 184px minmax(0, 1fr); height: 100%; } -.map-rail { display: grid; align-content: start; gap: var(--sds-space-2); padding: var(--sds-space-3); border-right: 1px solid var(--sds-color-border); overflow: auto; } -.map-rail-stage { font: inherit; color: inherit; text-align: left; display: grid; row-gap: 2px; padding: var(--sds-space-3); background: none; border: 1px solid transparent; border-radius: var(--sds-radius-lg); cursor: pointer; } +/* The row is pinned to the view's height so a long list scrolls inside .map-browser; an implicit + auto row would grow to the list and .map would clip it. */ +.map-stage-view { display: grid; grid-template-columns: 184px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); height: 100%; } +/* The four stages share the rail's height, their minimaps shrinking, so none is below the fold. */ +.map-rail { display: grid; grid-template-rows: repeat(4, minmax(0, auto)); align-content: start; gap: var(--sds-space-2); padding: var(--sds-space-3); border-right: 1px solid var(--sds-color-border); overflow: auto; } +.map-rail-stage { font: inherit; color: inherit; text-align: left; display: grid; grid-template-rows: auto auto minmax(0, 1fr); min-height: 0; row-gap: 2px; padding: var(--sds-space-3); background: none; border: 1px solid transparent; border-radius: var(--sds-radius-lg); cursor: pointer; } .map-rail-stage:hover { background: var(--sds-color-surface); } .map-rail-stage[aria-current="true"] { border-color: var(--c); background: color-mix(in srgb, var(--c) 6%, transparent); } /* The stage's minimap: its bubbles, laid over this by the map's BubbleLayer. */ -.map-rail-map { height: 112px; margin-top: var(--sds-space-2); display: grid; place-items: center; color: var(--c); } +.map-rail-map { height: 112px; max-height: 100%; min-height: 0; margin-top: var(--sds-space-2); display: grid; place-items: center; color: var(--c); } .map-rail-name { font-weight: var(--sds-weight-semibold); } .map-rail-caption { font-size: var(--sds-text-xs); color: var(--sds-color-text-muted); } .map-main { position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; } @@ -255,20 +264,28 @@ input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: .facts-summary { color: var(--sds-color-text-muted); font-variant-numeric: tabular-nums; } .facts-kind { display: inline-flex; align-items: center; gap: 6px; font-weight: var(--sds-weight-semibold); } .facts-kin { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--sds-color-text-muted); } +/* Whose data it is gives way first, so the line stays one row with Details at its end. */ +.facts-credit { flex: 1 1 12em; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .facts-spacer { flex: 1; } .kin-chip { font: inherit; font-size: var(--sds-text-sm); display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--sds-color-border); border-radius: 999px; padding: 0 var(--sds-space-2); background: var(--sds-color-surface-raised); color: var(--sds-color-text); cursor: pointer; max-width: 260px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } .kin-chip:hover { border-color: var(--c, var(--sds-color-accent)); } .picture-loading { display: grid; place-items: center; gap: var(--sds-space-3); align-content: center; border-top: 1px solid var(--sds-color-border); } /* The frame: the view fills it edge to edge, and the drawers float over it (ViewFrame). */ -.frame { position: relative; min-height: 0; overflow: hidden; border-top: 1px solid var(--sds-color-border); } -.frame-main { position: absolute; inset: 0; } +/* Clipped, not hidden: a drawer pushed away sits past the edge, and a hidden box could still be + scrolled to it (by a focus or scrollIntoView), shifting the whole view sideways. */ +.frame { position: relative; min-height: 0; overflow: clip; border-top: 1px solid var(--sds-color-border); } +/* Its own stacking context: the canvas' overlays (the overview, the legends) stay under the + views bar and its menus, however they stack among themselves. */ +.frame-main { position: absolute; inset: 0; isolation: isolate; } /* A list or chart rather than the tissue keeps clear of the open drawers, and of the views bar. */ .frame-sheet { overflow: auto; background: var(--sds-color-surface); transition: padding 0.2s ease; padding: var(--drawer-gap) calc(var(--inset-right) + var(--drawer-gap)) var(--drawer-gap) calc(var(--inset-left) + var(--drawer-gap)); } -.frame-barred .frame-sheet { padding-top: calc(var(--bar-room) + var(--drawer-gap)); } +/* A sheet starts under the views bar, so what scrolls in it never passes behind the bar. */ +.frame-barred .frame-sheet { top: calc(var(--bar-room) + var(--drawer-gap)); padding-top: 0; } +.frame-barred { background: var(--sds-color-surface); } /* The views, as the Studio's switch over its canvas: one joined strip, the open view in the accent; the canvas' tools (ViewTools) in a strip like it at the other end. */ .frame-bar { @@ -283,6 +300,9 @@ input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: pointer-events: auto; flex: 0 1 240px; min-width: 150px; padding: 3px; border: 1px solid var(--sds-color-border); border-radius: var(--sds-radius-md); background: color-mix(in srgb, var(--sds-color-surface-raised) 90%, transparent); box-shadow: var(--sds-shadow-raised); } +.view-labelled { display: flex; align-items: center; gap: 6px; flex-basis: 300px; font-size: var(--sds-text-xs); color: var(--sds-color-text-muted); } +.view-labelled > span { padding-left: 4px; white-space: nowrap; } +.view-labelled > div { flex: 1; min-width: 0; } .view-tabs, .view-tools { pointer-events: auto; display: flex; flex-wrap: nowrap; font-size: var(--sds-text-xs); box-shadow: var(--sds-shadow-raised); border: 1px solid var(--sds-color-border); border-radius: var(--sds-radius-md); @@ -290,7 +310,9 @@ input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: } /* The blur makes the strip a stacking context, which its Reports and Figures menus can't rise out of; lifting the strip keeps them over the tools when those wrap under the tabs. */ -.view-tabs { position: relative; z-index: 1; } +/* Narrower than its tabs, the strip takes a second row rather than running past the frame, + where its last tabs could not be reached (a scrolling strip would clip its menus). */ +.view-tabs { position: relative; z-index: 1; flex-wrap: wrap; min-width: 0; } .view-tab, .view-tab-menu .topbar-button { font: inherit; font-weight: var(--sds-weight-medium); white-space: nowrap; padding: 4px var(--sds-space-3); border: 0; border-radius: 0; background: none; color: var(--sds-color-text-muted); cursor: pointer; transition: color 0.15s ease, background-color 0.15s ease; @@ -439,6 +461,7 @@ input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: .draft-list { display: flex; gap: var(--sds-space-2); flex: 1; min-width: 0; overflow: hidden; } /* One line each, newest kept whole: older chips shrink to an ellipsis first. */ .draft-list .chip { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 4em; } +.draft-earlier { flex: none; align-self: center; font-size: var(--sds-text-sm); } .draft-list .chip:last-child { flex-shrink: 0; max-width: 100%; } /* An open stage: its items as a tree of their folders, a row each with its facts in words, its @@ -449,6 +472,8 @@ input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: .stage-tree-summary { margin: 2px 0 0; font-size: var(--sds-text-sm); color: var(--sds-color-text-muted); } .stage-tree-shared { color: var(--sds-color-text); } .stage-tree-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sds-space-2); } +/* A source's citation can run to a line; the chip keeps to a few words, with the rest in its title. */ +.stage-tree-chip-text { display: inline-block; max-width: 28ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; } .stage-tree-chip[aria-pressed="true"] { border-color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); } .stage-tree-sort { display: inline-flex; align-items: center; gap: 6px; font-size: var(--sds-text-sm); } .stage-tree-sort .select { padding: 2px 6px; font-size: var(--sds-text-sm); } @@ -463,6 +488,14 @@ input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: .stage-tree-caret { width: 1em; flex: none; color: var(--sds-color-text-muted); } .stage-tree-dot { width: 10px; height: 10px; flex: none; margin-top: 5px; border-radius: 50%; background: var(--c); } .stage-tree-label { display: grid; min-width: 0; } +/* One click opens an item from its row; the row itself selects it, for the look under it, + which has its own Open. It lies over the end of the row, taking no room from the name. + Always shown where nothing hovers. */ +.stage-tree-item { position: relative; } +.stage-tree-open { position: absolute; top: 5px; right: var(--sds-space-2); opacity: 0; pointer-events: none; } +.stage-tree-row:hover .stage-tree-open, .stage-tree-row:focus-visible .stage-tree-open, .stage-tree-open:focus-visible { opacity: 1; pointer-events: auto; } +.stage-tree-row.selected .stage-tree-open { visibility: hidden; } +@media (hover: none) { .stage-tree-open { opacity: 1; pointer-events: auto; } } .stage-tree-title { font-weight: var(--sds-weight-medium); overflow-wrap: anywhere; } .stage-tree-path { font-size: var(--sds-text-xs); } .stage-tree-facts { font-size: var(--sds-text-sm); color: var(--sds-color-text-muted); } @@ -500,8 +533,17 @@ input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: @media (max-width: 860px) { .map-landing { grid-template-columns: repeat(2, minmax(0, 1fr)); } + .map-stage { padding-top: 40px; } + .map-stage-head { gap: 2px; } + .map-icon { width: 24px; height: 24px; } + .map-stage-name { font-size: var(--sds-text-lg); } .map-stage-view { grid-template-columns: minmax(0, 1fr); } - .map-rail { display: none; } + .map-hint { display: none; } + /* The rail lies along the top, each stage by its name and count, without its minimap. */ + .map-stage-view { grid-template-rows: auto minmax(0, 1fr); } + .map-rail { display: flex; gap: var(--sds-space-1); padding: var(--sds-space-2) var(--sds-space-3) 0; border-right: 0; overflow-x: auto; } + .map-rail-stage { flex: none; padding: var(--sds-space-1) var(--sds-space-3); } + .map-rail-map { display: none; } } @media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation-duration: 0s !important; } @@ -540,7 +582,7 @@ input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: .report-body { display: grid; gap: var(--sds-space-6); } .report-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--sds-space-3); margin: 0; } .report-stat { background: var(--sds-color-surface); border: 1px solid var(--sds-color-border); border-radius: var(--sds-radius-md); padding: var(--sds-space-3); } -.report-stat dt { font-size: var(--sds-text-xs); color: var(--sds-color-text-muted); text-transform: uppercase; letter-spacing: 0.05em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.report-stat dt { font-size: var(--sds-text-xs); color: var(--sds-color-text-muted); text-transform: uppercase; letter-spacing: 0.05em; overflow-wrap: anywhere; } .report-stat dd { margin: var(--sds-space-1) 0 0; font-size: var(--sds-text-xl); font-weight: var(--sds-weight-semibold); font-variant-numeric: tabular-nums; } .report-stat .report-stat-note { font-size: var(--sds-text-xs); font-weight: normal; } .report-section { display: grid; gap: var(--sds-space-2); min-width: 0; } diff --git a/cirro-studio/src/tasks/FigureTask.tsx b/cirro-studio/src/tasks/FigureTask.tsx index fbb776e..774a0fa 100644 --- a/cirro-studio/src/tasks/FigureTask.tsx +++ b/cirro-studio/src/tasks/FigureTask.tsx @@ -8,7 +8,7 @@ import { LENS_PARAM, useRoute } from '../app/route'; import { useStudio } from '../app/studio'; import { plural } from '../app/ui'; import { describeError } from '../cirro/session'; -import { pdfBlob, pngBlob, svgBlob } from '../figures/export'; +import { fileStem, pdfBlob, pngBlob, svgBlob } from '../figures/export'; import { figureLayout, figureSvg, SIZE_PRESETS, type FigureLegend, type SizePreset } from '../figures/layout'; import { coordinateUnit, scaleBar, storeReader } from '../figures/scaleBar'; import { figureContent, keepFigure, removeFigure, type FigureSpec } from '../figures/spec'; @@ -44,7 +44,6 @@ function visiblePart(canvas: HTMLCanvasElement, inset: { left: number; right: nu return { image, cssWidth: image.width / ratio }; } -const slug = (s: string) => s.trim().replace(/[^A-Za-z0-9]+/g, '-').replace(/^-|-$/g, '').toLowerCase() || 'figure'; export default function FigureTask({ wb, name, inset, figures }: TaskProps) { const { session } = useStudio(); @@ -137,7 +136,7 @@ export default function FigureTask({ wb, name, inset, figures }: TaskProps) { const svg = figureSvg(spec); const layout = figureLayout(spec); const blob = format === 'svg' ? svgBlob(svg) : format === 'pdf' ? await pdfBlob(svg, layout) : await pngBlob(svg, layout); - const file = `${slug(title)}.${format}`; + const file = `${fileStem(title)}.${format}`; downloadBlob(blob, file); setDownloaded(file); setOmitted(layout.legend?.omitted ?? 0); @@ -168,11 +167,11 @@ export default function FigureTask({ wb, name, inset, figures }: TaskProps) {
Download {(['png', 'pdf', 'svg'] as const).map((f) => ( - + ))}
{downloaded &&

Downloaded {downloaded}.

} - {keptAs && (inDraft(keptAs) ? ( diff --git a/docs/guide/analyze.md b/docs/guide/analyze.md index 7ee973e..ac8eb78 100644 --- a/docs/guide/analyze.md +++ b/docs/guide/analyze.md @@ -49,11 +49,11 @@ half a minute for 200,000. ## Compare composition The **Composition** tab counts the cells in each group of what the tissue is colored -by. Choose a column under **Across**, in its Display drawer, and it counts them across -that column's groups instead: cell types or Leiden clusters across regions, say, or +by. Choose a column under **Across**, beside **Color by** over the view, and it counts +them across that column's groups instead: cell types or Leiden clusters across regions, say, or cellular neighborhoods across the areas you drew with **Label cells** (the *labels* column). Cells with no group in either column are left out, and the view says how many. -A column of more than 100 groups can't be counted across. **Count the whole tissue** +A column of more than 100 groups can't be counted across. The **×** beside **Across** (*Count the whole tissue*) goes back to one bar per group. The comparison shows: @@ -125,7 +125,10 @@ kept twice. While the figure is only in the unsaved changes, **Take it out**, in under the button, takes it back out and leaves the rest of the changes as they are. A kept figure is saved with the version, listed under the **Figures** tab and on the -map's Figures stage, and opens framed as it was. With a figure open, **Remove…** under +map's Figures stage, and opens framed as it was. An open chart figure has **Download** +over it, as a 300 dpi PNG or an SVG; a tissue or cell map figure has **Download…** under +its caption in the Display drawer, which opens **Save as a figure** on the view as the +figure framed it. With a figure open, **Remove…** under its caption in the Display drawer takes it out: out of the unsaved changes, or, for a figure saved in an earlier version, out of the next version you save. The version that kept it still has it, under **Versions**, but the map's Figures stage no longer lists it. diff --git a/docs/guide/find-a-dataset.md b/docs/guide/find-a-dataset.md index a20f207..c6c037d 100644 --- a/docs/guide/find-a-dataset.md +++ b/docs/guide/find-a-dataset.md @@ -145,13 +145,16 @@ files such as `cells.zarr.zip`. again from the version's data. - **What you can do.** Open it to see it again: a tissue figure restores the store's view as it was framed, where **Save as a figure** downloads it as SVG, PDF or a 300 dpi PNG, - and a chart figure redraws the chart from the result it came from. + and a chart figure redraws the chart from the result it came from, with **Download** as + a 300 dpi PNG or an SVG. ## The map A project opens as a map of the four stages (Images, Instrument runs, Spatial data, -Figures). Each bubble is one item, sized by its files and named inside it when there is -room; pointing at one shows its full name under the map. A dataset holding several stores +Figures). Each bubble is one item, larger the larger its files (on a compressed scale, so that a +small dataset beside a very large one, or a figure, is still something to point at) and +named inside it when there is room; pointing at one shows its full name and size beside +it. A dataset holding several stores shows each one, and rings inside a spatial-data bubble are the versions saved on that store. Dashed lines join a run or an image to the spatial data made from it. @@ -167,15 +170,17 @@ bubbles, to open it as a list of its items, a row each, in their Cirro folders: the scale for each one, so a closed folder still shows where its large items are. - **Said once.** What every item of the stage shares ("all 10x Xenium") is said once, above the list, rather than on every row. -- **Find and narrow.** Search by name, folder, tag or any of those facts; the chips beside +- **Find and narrow.** Search by name, folder, tag or any of those facts (the line under + the stage's name then says how many of its items are shown); the chips beside the search narrow the list to one kind of item (only "OME-TIFF", say), and are offered only for facts that tell the stage's items apart. Order by name, size or newest, and switch between **Folders** and a **Flat list** of everything. - **Select** a row to see more under it: the dataset's description, who added it and when, a link to it in Cirro, what it was made from and what was made from it (click one to go to it in its own stage), and what you can do: **Open** it, open it in an Analysis - Workspace, or run a pipeline on it. A double-click, or Enter, opens an item straight - away, its picture growing out of its row; leaving the picture comes back to the list with + Workspace, or run a pipeline on it. **Open**, which shows at the end of a row's name + as you point at it, a double-click, or Enter opens an item straight away, its picture + growing out of its row; leaving the picture comes back to the list with the row still selected. - **Keyboard.** The arrow keys move through the list and open and close folders, typing jumps to a name, `/` goes to the search (where the down arrow moves into the list and @@ -184,5 +189,6 @@ bubbles, to open it as a list of its items, a row each, in their Cirro folders: On a wide screen, a rail on the left keeps every stage as a small map of its bubbles: the open stage's dims the items the search leaves out and rings the selected item and what -it was made from and into. What you have opened, searched for, selected and chosen is +it was made from and into. On a narrow one the stages are a strip of names along the top +instead. What you have opened, searched for, selected and chosen is kept in the page's address, so a reload, Back or a shared link shows the same list. diff --git a/docs/guide/look-at-a-section.md b/docs/guide/look-at-a-section.md index 47c4ebd..3b47b78 100644 --- a/docs/guide/look-at-a-section.md +++ b/docs/guide/look-at-a-section.md @@ -4,13 +4,15 @@ Click an item of spatial data on the [map](find-a-dataset.md#the-map), and its [store](glossary.md#store) opens across the whole page: one [section](glossary.md#section), every cell over the tissue image. It is read in place: no copy is downloaded, only the pieces on screen. Pan and zoom as you would on a map. The color legend, the image's -channels and an overview of the whole section are drawn on the image itself. +channels and an overview of the whole section are drawn on the image itself. Click the +color legend's title to fold a long legend away, and again to bring it back. ![A Xenium pancreas section open in the web app: every cell drawn over the immunofluorescence image and colored by its cellular neighborhood, with the analysis tasks in a drawer on the left and the display settings in a drawer on the right.](../images/web-app.jpg) -The line above it starts with the way back to the map, names the store, its size and -where it came from, counts its cells (spots, for Visium) and genes, and links the run or -image it was made **from** and what it was **made into**. A [version](glossary.md#version) +The line above it starts with the way back to the map, names the store, counts its cells +(spots, for Visium) and genes, says where it came from, and links the run or image it was +made **from** and what it was **made into**. **Details**, at its end, has the rest: its +size, its data type, when it was added and its place in the project. A [version](glossary.md#version) shows as *Version N · its title* beside the name of the store it was saved on, and keeps that store's credit. Esc closes menus and an open task, but never leaves the dataset: the way back does. @@ -26,8 +28,12 @@ Tabs over the top of the view switch what is shown: ([Compare composition](analyze.md#compare-composition)). A color of values rather than groups, or of more than 100 groups (too many to color), has nothing to count, and the view says so. -- **Versions**: the store's history, with the page to itself (it has nothing to set). -- **Figures**: a menu of the figures saved with it, when there are any. +- **Versions**: the store's history. +- **Reports** and **Figures**: a menu each of the reports and figures kept with it, when + there are any. + +Composition, Versions and an open report have no display settings, so they have no Display +drawer and take its side of the page. A figure or report the store lists but whose data can't be read (a version copied somewhere without all of its files, say) stays in its menu, named with the reason, and @@ -36,7 +42,10 @@ can't be opened; the others open as usual. Beside the tabs are **Color by** (the same box as in the Display drawer, below: type a gene's or an annotation's name and pick it), a scale bar (when the store says its coordinates are microns), zoom out and in, and **Fit to data**, which stay in reach when -the drawers are away; when the view is narrow they move under the tabs. For a Visium +the drawers are away; when the view is narrow they move under the tabs, and the tabs +take a second row rather than run off the view. On **Composition** the same place holds +**Color by**, which picks the groups counted, and **Across**, the column they are counted +across. For a Visium store, whose observations are capture spots, the header, the map's tab, Composition and Label cells say spots rather than cells. @@ -45,7 +54,8 @@ Label cells say spots rather than cells. Two drawers float over the view. Pull one in with its tab at the edge of the view and push it away with its arrow, or press **[** for the left one, **]** for the right one and **\\** for both at once; the app remembers which you keep open. In a window narrower -than 1,100 pixels only one is out at a time. +than 1,100 pixels only one is out at a time, and in one narrower than 860 pixels a +section opens with both away. - **The left drawer** holds the analysis tasks ([Analyze in the browser](analyze.md)). - **Display**, the right drawer, holds the display settings, the same panel with the same @@ -75,5 +85,4 @@ zero), so a few cells with very high counts don't leave the rest of the tissue d past either end take its color, and the legend marks that end with ≥ or ≤. **Color range** sets the range by hand and **Reset** returns it. The tissue and the cell map share one color: choosing a color, its range, its legend title or a group's color on one changes -the other. On **Composition** the drawer holds the color, which picks the groups -counted, and **Across**, the column they are counted across. +the other. diff --git a/docs/images/web-app-report.jpg b/docs/images/web-app-report.jpg index 63b3b99..756125a 100644 Binary files a/docs/images/web-app-report.jpg and b/docs/images/web-app-report.jpg differ diff --git a/docs/images/web-app.jpg b/docs/images/web-app.jpg index d0c492d..e237cf7 100644 Binary files a/docs/images/web-app.jpg and b/docs/images/web-app.jpg differ diff --git a/frontend/package.json b/frontend/package.json index 848ea42..e00d3ba 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,7 +1,7 @@ { "name": "spatial-data-studio-frontend", "private": true, - "version": "1.9.1", + "version": "1.10.0", "type": "module", "scripts": { "dev": "vite", diff --git a/package-lock.json b/package-lock.json index 0569483..83b7abb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "spatial-data-studio", - "version": "1.9.1", + "version": "1.10.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "spatial-data-studio", - "version": "1.9.1", + "version": "1.10.0", "workspaces": [ "packages/viewer", "packages/studio-ui", @@ -22,7 +22,7 @@ }, "cirro-studio": { "name": "spatial-data-studio-cirro", - "version": "1.9.1", + "version": "1.10.0", "dependencies": { "@cirrobio/api-client": "0.13.39", "@cirrobio/sdk": "0.13.39", @@ -82,7 +82,7 @@ }, "frontend": { "name": "spatial-data-studio-frontend", - "version": "1.9.1", + "version": "1.10.0", "dependencies": { "@cirrobio/spatial-viewer": "*", "@cirrobio/studio-ui": "*", @@ -11389,7 +11389,7 @@ }, "packages/studio-ui": { "name": "@cirrobio/studio-ui", - "version": "1.9.1", + "version": "1.10.0", "license": "SEE LICENSE IN LICENSE.md", "peerDependencies": { "@cirrobio/spatial-viewer": "*", @@ -11401,7 +11401,7 @@ }, "packages/viewer": { "name": "@cirrobio/spatial-viewer", - "version": "1.9.1", + "version": "1.10.0", "license": "SEE LICENSE IN LICENSE.md", "dependencies": { "hyparquet": "^1.28.2", diff --git a/package.json b/package.json index 8e4617f..3685cc2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "spatial-data-studio", "private": true, - "version": "1.9.1", + "version": "1.10.0", "workspaces": [ "packages/viewer", "packages/studio-ui", diff --git a/packages/studio-ui/package.json b/packages/studio-ui/package.json index 1bd816f..9499ea0 100644 --- a/packages/studio-ui/package.json +++ b/packages/studio-ui/package.json @@ -1,6 +1,6 @@ { "name": "@cirrobio/studio-ui", - "version": "1.9.1", + "version": "1.10.0", "private": true, "description": "Spatial Data Studio's own controls (the canvas display settings and the pickers they use) and its Google Analytics page views, shared by the Studio app and Spatial Data Studio for Cirro.", "license": "SEE LICENSE IN LICENSE.md", diff --git a/packages/viewer/package.json b/packages/viewer/package.json index b4d3602..d442fd0 100644 --- a/packages/viewer/package.json +++ b/packages/viewer/package.json @@ -1,6 +1,6 @@ { "name": "@cirrobio/spatial-viewer", - "version": "1.9.1", + "version": "1.10.0", "description": "Host-agnostic WebGL spatial/embedding canvases and the .zarr.zip checkpoint reader from Spatial Data Studio.", "license": "SEE LICENSE IN LICENSE.md", "sideEffects": false, diff --git a/packages/viewer/src/canvas/CanvasOverlays.tsx b/packages/viewer/src/canvas/CanvasOverlays.tsx index 3d696f3..29b8fcc 100644 --- a/packages/viewer/src/canvas/CanvasOverlays.tsx +++ b/packages/viewer/src/canvas/CanvasOverlays.tsx @@ -1,4 +1,4 @@ -import type { ReactNode } from 'react'; +import { useState, type ReactNode } from 'react'; import { VIRIDIS_CSS_GRADIENT } from './colorUtils'; import { CELL_LEGEND, CHANNEL_LEGEND, DRAW_HINT, LEGEND_ROW, LOADING_CUE, SWATCH, TILE_STATUS, @@ -117,16 +117,24 @@ export function CellColorLegend({ title: string; scale?: number; }) { + // Folded to its title, a long legend gives the tissue under it back. + const [folded, setFolded] = useState(false); if (!(visible && legend)) return null; return (
-
setFolded((f) => !f)} + aria-expanded={!folded} + title={`${title} (click to ${folded ? 'show' : 'hide'} the legend)`} + style={{ + ...TRUNCATE, display: 'block', maxWidth: LEGEND_MAX_PX, padding: 0, border: 0, background: 'none', cursor: 'pointer', + font: 'inherit', fontSize: 11, fontWeight: 500, color: themeColor('text'), marginBottom: folded ? 0 : 4, + }} > - {title} -
- {legend.kind === 'categorical' ? ( + {folded ? '▸' : '▾'} {title} + + {folded ? null : legend.kind === 'categorical' ? ( ) : legend.kind === 'too-many-categories' ? (
diff --git a/packages/viewer/src/canvas/Minimap.tsx b/packages/viewer/src/canvas/Minimap.tsx index e2018fc..6159a06 100644 --- a/packages/viewer/src/canvas/Minimap.tsx +++ b/packages/viewer/src/canvas/Minimap.tsx @@ -31,11 +31,13 @@ interface Props { invertY: boolean; onNavigate: (target: [number, number]) => void; onNavigateEnd: () => void; + // How far below the overlays' top edge it sits. + top: number; } export default function Minimap({ imageUrl, positions, colors, worldToCanvas, extent, viewport, canvasSize, - invertX, invertY, onNavigate, onNavigateEnd, + invertX, invertY, onNavigate, onNavigateEnd, top, }: Props) { const [ex0, ey0, ex1, ey1] = extent; const ew = Math.max(ex1 - ex0, 1e-9); @@ -113,14 +115,13 @@ export default function Minimap({ onNavigateEnd(); }, [onNavigateEnd]); - // Positioned below the Spatial/Embeddings/Tables switch, which owns the same corner. return (
)}