-
Notifications
You must be signed in to change notification settings - Fork 0
Add shape fill-by-column controls and outline defaults #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e69de3c
Enable shape fill color by column
xinaesthete a2a00e5
Document layer identity and annotation column invariants
xinaesthete e91d472
Refine shape stroke defaults for fill-driven colouring
xinaesthete a6d1d83
Invalidate shape colors with deck update triggers
xinaesthete 1da44a3
Align shape rows by position and improve tooltip fallbacks
xinaesthete 3c5fe30
Fix shape tooltip row index precedence
xinaesthete 763de3b
Aggregate hover tooltips across spatial layers
xinaesthete a4c8f80
Document shapes feature-state performance
xinaesthete e420180
Split SpatialCanvas barrel and widen shape state types
xinaesthete ea057d1
Fix shape fill color encoding for large columns
xinaesthete 3e60b46
Update agent guidance for SpatialData worktree
xinaesthete 929b138
Document labels and shapes feature identity convergence
xinaesthete be0b281
Cap hover tooltip aggregation to layer count
xinaesthete 063d8e2
Improve aggregated hover picking for overlapping labels
xinaesthete 6e7458d
Document feature-table association boundaries
xinaesthete File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| --- | ||
| sidebar_position: 6 | ||
| --- | ||
|
|
||
| # Feature table associations and annotation columns | ||
|
|
||
| This note records the intended foundation for linking SpatialData features to | ||
| table rows, tooltip values, and visual encodings. The current `SpatialCanvas` | ||
| demo supports table-driven shape fill colour and aggregated feature tooltips, | ||
| but some of that logic still lives too close to the demo UI. Before publishing | ||
| the first stable visualization API, these responsibilities should be pulled | ||
| into reusable core/layer utilities. | ||
|
|
||
| ## Reference semantics | ||
|
|
||
| Use Python `spatialdata` as the source of truth for association semantics. | ||
|
|
||
| - Tables annotate regions through the `region`, `region_key`, `instance_key` | ||
| triplet. `region_key` identifies which spatial element a row annotates, and | ||
| `instance_key` identifies which instance within that element the row | ||
| annotates. See the upstream | ||
| [table annotations tutorial](https://spatialdata.scverse.org/en/stable/tutorials/notebooks/notebooks/examples/tables.html) | ||
| and | ||
| [SpatialData design document](https://github.com/scverse/spatialdata/blob/main/docs/design_doc.md). | ||
| - Shapes are GeoDataFrames. Their semantic feature ids are the GeoDataFrame | ||
| index values, and extra GeoDataFrame columns are valid shape annotations. | ||
| The table `instance_key` should match those shape index values; row order is | ||
| not the association contract. | ||
| - Labels instances are raster label values, excluding background. Table | ||
| `instance_key` values annotate those label values. | ||
| - Points are not regions in the same sense as shapes/labels. They can carry | ||
| annotations directly and may also participate in future feature-key based | ||
| workflows, but they should not be forced into the region-table model by | ||
| default. | ||
|
|
||
| In TypeScript terms, `featureId` should mean the canonical SpatialData | ||
| instance id. `featureIndex` should mean render/order position only. A | ||
| zero-based `featureIndex` can match a table row only when the upstream element | ||
| index is actually a zero-based range and has been exposed as the feature id. | ||
|
|
||
| ## Desired API shape | ||
|
|
||
| `@spatialdata/core` should expose a single canonical alignment helper for | ||
| regions: | ||
|
|
||
| ```ts | ||
| type FeatureTableAlignment = { | ||
| rowIndexByFeatureIndex: Int32Array; | ||
| rowIndexByFeatureId?: Map<string, number>; | ||
| resolveRowIndex(feature: { | ||
| featureId: string; | ||
| featureIndex: number; | ||
| rowIndex?: number; | ||
| }): number | undefined; | ||
| }; | ||
| ``` | ||
|
|
||
| The exact type may change, but the principle should not: tooltip resolution, | ||
| click/hover events, table-driven fill colour, filtering, and downstream | ||
| applications should all use one shared resolver. Avoid adding one-off helpers | ||
| such as `resolveShapeFillColorRowIndex` in `SpatialCanvas`. | ||
|
|
||
| The resolver should: | ||
|
|
||
| - Load association metadata from `region`, `region_key`, and `instance_key`. | ||
| - Filter rows by the target region/element. | ||
| - Match table rows to canonical feature ids, not to render order. | ||
| - Preserve unmatched features explicitly, rather than silently inventing a row. | ||
| - Treat positional fallback as a compatibility path only when the element ids | ||
| are known to be positional ids. | ||
|
|
||
| ## Package boundaries | ||
|
|
||
| `@spatialdata/core` should own semantic association: | ||
|
|
||
| - Reading table keys and annotation metadata. | ||
| - Loading element feature ids / instances. | ||
| - Building `FeatureTableAlignment`. | ||
| - Exposing shape/label/point annotation columns in a consistent way. | ||
|
|
||
| `@spatialdata/layers` should own reusable deck/layer helpers: | ||
|
|
||
| - Shape/label feature state runtimes. | ||
| - Pick datum interpretation and logical layer id normalization for composite | ||
| layers where needed. | ||
| - Optional column-to-colour encoders when they are renderer-agnostic and useful | ||
| to downstream apps. | ||
|
|
||
| `@spatialdata/vis` and `SpatialCanvas` should remain UI glue: | ||
|
|
||
| - Choosing which column to use. | ||
| - Displaying property panels. | ||
| - Loading the requested columns through core helpers. | ||
| - Passing resolved feature state into deck layers. | ||
|
|
||
| The demo UI can exercise a feature before the public API is final, but new | ||
| semantic rules should not be invented in `SpatialCanvas`. | ||
|
|
||
| ## Annotation column roadmap | ||
|
|
||
| Column choices in the demo should eventually include more than associated table | ||
| obs columns: | ||
|
|
||
| - Associated table obs columns, excluding `instance_key` and `region_key`. | ||
| - Extra annotation columns stored directly on shape elements. | ||
| - Future entries corresponding to `vars` in `X` / `layers` for expression-like | ||
| matrices. | ||
|
|
||
| Those sources should be surfaced through a common annotation-column discovery | ||
| API so downstream apps do not need to know whether a value came from AnnData | ||
| obs, a GeoDataFrame column, or a matrix-backed feature. | ||
|
|
||
| ## Current branch status | ||
|
|
||
| The current `SpatialCanvas` behaviour is acceptable as demo functionality: | ||
|
|
||
| - Shape fill colour can be driven by a chosen table column. | ||
| - Tooltips can aggregate multiple visible layers under the cursor. | ||
| - Multiple layer configs may represent the same element with different visual | ||
| properties. | ||
|
|
||
| However, these are not yet the desired foundations for a first stable | ||
| library-facing API. Before publishing, revisit the implementation with this | ||
| checklist: | ||
|
|
||
| 1. Move feature-to-row association into a core helper with tests against the | ||
| SpatialData table semantics above. | ||
| 2. Replace local row-index precedence rules in tooltip, fill-colour, and pick | ||
| event paths with that helper. | ||
| 3. Move reusable colour encoders and feature-state helpers out of the demo UI | ||
| when downstream apps need them. | ||
| 4. Keep `SpatialCanvas` as the consumer of these utilities, not the owner of | ||
| the semantics. | ||
| 5. Add fixture coverage for non-matching row order, missing rows, mixed-region | ||
| tables, labels values, and shape annotation columns. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.