Skip to content

Refactor reverse ramp control into ColorRampControls component#1139

Open
nakul-py wants to merge 1 commit intogeojupyter:mainfrom
nakul-py:reverese-ramp
Open

Refactor reverse ramp control into ColorRampControls component#1139
nakul-py wants to merge 1 commit intogeojupyter:mainfrom
nakul-py:reverese-ramp

Conversation

@nakul-py
Copy link
Collaborator

@nakul-py nakul-py commented Feb 25, 2026

Description

Now ColorRampControls is the final source of truth for Reverse ramp working.

Screencast.From.2026-02-25.21-12-36.mp4

Checklist

  • PR has a descriptive title and content.
  • PR description contains references to any issues the PR resolves, e.g. Resolves #XXX.
  • PR has one of the labels: documentation, bug, enhancement, feature, maintenance
  • Checks are passing.
    Failing lint checks can be resolved with:
    • pre-commit run --all-files
    • jlpm run lint
  • If you wish to be cited for your contribution, CITATION.cff contains an author entry for yourself

📚 Documentation preview: https://jupytergis--1139.org.readthedocs.build/en/1139/
💡 JupyterLite preview: https://jupytergis--1139.org.readthedocs.build/en/1139/lite
💡 Specta preview: https://jupytergis--1139.org.readthedocs.build/en/1139/lite/specta

@nakul-py nakul-py self-assigned this Feb 25, 2026
@github-actions
Copy link
Contributor

Binder 👈 Launch a Binder on branch nakul-py/jupytergis/reverese-ramp

@nakul-py nakul-py added the enhancement New feature or request label Feb 25, 2026
@nakul-py nakul-py requested review from arjxn-py, martinRenou and mfisher87 and removed request for mfisher87 February 25, 2026 15:50
@mfisher87 mfisher87 changed the title Refactor Reverse ramp into ColorRampControls Refactor reverse ramp control into ColorRampControls component Feb 25, 2026
@nakul-py
Copy link
Collaborator Author

nakul-py commented Feb 25, 2026

Tests are failing 😣. Why?

@mfisher87
Copy link
Member

Looks like an outage or degraded service on anaconda.org:

      Download error (28) Timeout was reached [https://conda.anaconda.org/conda-forge/noarch/repodata.json.zst]

@mfisher87
Copy link
Member

No incidents logged: https://anaconda.statuspage.io/

@github-actions
Copy link
Contributor

Integration tests report: appsharing.space

@nakul-py
Copy link
Collaborator Author

No incidents logged: anaconda.statuspage.io

Now all the checks are passed automatically.

@mfisher87
Copy link
Member

I'll try and review this in an hour or so!

Copy link
Member

@mfisher87 mfisher87 left a comment

Choose a reason for hiding this comment

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

Minor change request. This looks really good, thanks for your work @nakul-py ! Always nice to see a PR that removes more code than it adds :)

Comment on lines +83 to +91
const ramp = colorMaps.filter(c => c.name === rampName);

canvas.width = canvasWidth;
canvas.height = canvasHeight;

for (let i = 0; i <= 255; i++) {
ctx.beginPath();

const color = ramp[0].colors[i];
const color = reverse ? ramp[0].colors[255 - i] : ramp[0].colors[i];
Copy link
Member

Choose a reason for hiding this comment

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

What do you think of reversing the ramp as early as possible? I'd like to eliminate the magic number 255 as much as possible :)

Suggested change
const color = reverse ? ramp[0].colors[255 - i] : ramp[0].colors[i];
const ramp = colorMaps.filter(c => c.name === rampName)[0];
const colors = reverse ? ramp.colors.reverse() : ramp.colors;
canvas.width = canvasWidth;
canvas.height = canvasHeight;
for (let i = 0; i <= 255; i++) {
ctx.beginPath();
const color = colors[i];

Copy link
Member

Choose a reason for hiding this comment

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

Or maybe something like this is better?

const ramp = colorMaps.filter(c => c.name === rampName)[0];
if (reverse) {
  ramp.colors = ramp.colors.reverse();
}

This way we only have one source of truth for the colors we'll be using instead of creating a copy?

flex: 0 1 auto;
display: inline-flex;
align-items: center;
gap: 0.4rem;
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious why we need a CSS change for this refactor? I have to jump to a meeting really soon so I didn't have time to check out what this CSS change does :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Refactor color ramp "reverse" control into ColorRampControls component

2 participants