Skip to content

NickAkhmetov/Add slider controls to numeric legends#2365

Merged
NickAkhmetov merged 9 commits intomainfrom
nickakhmetov/fix-2347
Dec 3, 2025
Merged

NickAkhmetov/Add slider controls to numeric legends#2365
NickAkhmetov merged 9 commits intomainfrom
nickakhmetov/fix-2347

Conversation

@NickAkhmetov
Copy link
Copy Markdown
Collaborator

Fixes #2347

Background

This PR adds slider controls to the legend package and updates the legend package to use TypeScript.

The min/max values on numeric legends now allow users to click and drag/use keyboard controls to set the min/max values for the legend.

Change List

  • Add legend controls for slider.
  • Convert legend package to native TS.

Checklist

  • Have tested PR with one or more demo configurations
  • Documentation added, updated, or not applicable
Screen.Recording.2025-12-01.124230.mp4
Screen.Recording.2025-12-01.124313.mp4

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 2, 2025

Size Change: +92.8 kB (+1.26%)

Total Size: 7.44 MB

Filename Size Change
./packages/main/prod/dist/index-********.js 235 kB +92.8 kB (+65.39%) 🆘
./packages/main/prod/dist/lzw-********.js 0 B -2.07 kB (removed) 🏆
./packages/main/prod/dist/ReactNeuroglancer-********.js 0 B -1.67 MB (removed) 🏆
./packages/main/prod/dist/lzw-CFcni1-O.js 2.07 kB +2.07 kB (new file) 🆕
./packages/main/prod/dist/ReactNeuroglancer-Dp-ZkbIj.js 1.67 MB +1.67 MB (new file) 🆕
ℹ️ View Unchanged
Filename Size Change
./packages/main/prod/dist/blosc-********.js 612 kB 0 B
./packages/main/prod/dist/chunk-INHXZS53-********.js 558 B 0 B
./packages/main/prod/dist/deflate-oPeRim-T.js 0 B -208 B (removed) 🏆
./packages/main/prod/dist/higlass-********.js 3.57 MB 0 B
./packages/main/prod/dist/index.min.js 1.38 kB 0 B
./packages/main/prod/dist/jpeg-********.js 15.6 kB 0 B
./packages/main/prod/dist/lerc-********.js 89.3 kB 0 B
./packages/main/prod/dist/lz4-********.js 43.9 kB 0 B
./packages/main/prod/dist/OrbitControls-********.js 229 kB 0 B
./packages/main/prod/dist/packbits-********.js 541 B 0 B
./packages/main/prod/dist/pako.esm-********.js 37.1 kB 0 B
./packages/main/prod/dist/raw-********.js 133 B 0 B
./packages/main/prod/dist/troika-three-text.esm-********.js 179 kB 0 B
./packages/main/prod/dist/webimage-********.js 801 B 0 B
./packages/main/prod/dist/zstd-********.js 754 kB 0 B
./packages/main/prod/dist/deflate-********.js 208 B +208 B (new file) 🆕

compressed-size-action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 2, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 13.62% 9130 / 67033
🔵 Statements 13.62% 9130 / 67033
🔵 Functions 48.56% 525 / 1081
🔵 Branches 67.39% 1395 / 2070
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/legend/src/Legend.tsx 0% 0% 0% 0% 1-801
packages/legend/src/types.ts 100% 100% 100% 100%
packages/view-types/heatmap/src/HeatmapSubscriber.js 0% 0% 0% 0% 1-323
packages/view-types/scatterplot-embedding/src/EmbeddingScatterplotSubscriber.js 0% 0% 0% 0% 1-679
packages/view-types/spatial/src/SpatialSubscriber.js 0% 0% 0% 0% 1-732
Generated in workflow #4708 for commit 85c93a4 by the Vitest Coverage Report Action

@keller-mark
Copy link
Copy Markdown
Member

It looks really great! Can we fix these two minor UI things:

  • The opacity of the tooltip triangle
  • The offset of the text and axis line/ticks
Screenshot 2025-12-02 at 1 10 54 PM Screenshot 2025-12-02 at 1 12 54 PM

@NickAkhmetov
Copy link
Copy Markdown
Collaborator Author

There we go!

The opacity of the tooltip triangle

image

The offset of the text and axis line/ticks

image

// Determine if interactive slider should be shown
const showInteractiveSlider = (
setFeatureValueColormapRange
&& ['geneSelection', 'geneExpression'].includes(obsColorEncoding ?? '')
Copy link
Copy Markdown
Member

@keller-mark keller-mark Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
&& ['geneSelection', 'geneExpression'].includes(obsColorEncoding ?? '')
&& obsColorEncoding === 'geneSelection'

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change would make it so we don't display an interactive slider for the heatmap in e.g. https://vitessce.io/#?dataset=codeluppi-2018

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We show "Gene Expression" in the UI, but "geneExpression" should not be a valid value here

z.enum(['geneSelection', 'cellSetSelection', 'spatialChannelColor', 'spatialLayerColor', 'obsLabels']),

Copy link
Copy Markdown
Member

@keller-mark keller-mark Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah my bad, I see what you mean now, we do use this value here as a prop

obsColorEncoding="geneExpression"
so please ignore my suggestion above.

I guess this is why typescript is helpful. Can we leave a comment about this in the code here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added an explanatory comment, thanks for the clarification 👍🏻

.style('fill', foregroundColor);

if (hasSubLabel) {
g
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to render this text above the gradient but still below the slider handle?
Screenshot 2025-12-03 at 9 40 59 AM

http://localhost:3000/?dataset=spatialdata-visium_hd

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fixed now:
image

@keller-mark
Copy link
Copy Markdown
Member

A few small comments, then it looks good to merge

Co-authored-by: Mark Keller <7525285+keller-mark@users.noreply.github.com>
@NickAkhmetov NickAkhmetov merged commit 2164057 into main Dec 3, 2025
7 checks passed
@NickAkhmetov NickAkhmetov deleted the nickakhmetov/fix-2347 branch December 3, 2025 16:07
@github-actions github-actions bot mentioned this pull request Dec 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Colormap range slider input should be part of the legend

2 participants