Skip to content

Add an automatic SQL color scale legend widget - #11193

Merged
ibgreen merged 13 commits into
masterfrom
codex/sql-color-scale-widget
Nov 19, 2026
Merged

ibgreen merged 13 commits into
masterfrom
codex/sql-color-scale-widget

Conversation

@ibgreen

@ibgreen ibgreen commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Follow up of #11159

Background

SQL color scales derive domains from layer data. Applications need a legend that follows the scales and the layers drawn in each view.

Change List

  • Add the experimental, collapsible _ColorScaleWidget
  • Expose experimental Layer._getResolvedColorScales() and its types
  • Discover scales using the screen pass’s viewport eligibility
  • Show scale types, significant digits, and horizontal quantile breaks
  • Demonstrate quantile polygons and a continuous point overlay
  • Unit tests
  • Documentation

Core and widgets builds, lint, Node and Chromium tests passed.


Note

Low Risk
Low risk as changes introduce an opt-in experimental widget and non-breaking, backward-compatible additions to layer visibility tracking and scale metadata.

Overview
Adds an experimental _ColorScaleWidget to @deck.gl/widgets that automatically generates legends for SQL color accessors on visible layers.

To power the widget, Layer exposes an experimental _getResolvedColorScales() method returning scale descriptors and color samplers, preserving active scales while queries re-evaluate. Additionally, DeckRenderer and LayersPass now track viewport-eligible drawable layers and pass renderedLayers through to Widget onRedraw lifecycle methods.

The widget renders collapsible legends supporting categorical swatches, continuous color ramps, and discrete or quantile bins with adaptive numeric precision. It also includes comprehensive test coverage, documentation, and an interactive documentation demo.

Reviewed by Cursor Bugbot for commit ffa12e5. Bugbot is set up for automated code reviews on this repo. Configure here.

@coveralls

coveralls commented Nov 18, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 82.648% (+0.1%) from 82.545% — codex/sql-color-scale-widget into master

@ibgreen
ibgreen force-pushed the codex/sql-color-scale-widget branch from 2c75b52 to d067e8a Compare November 18, 2026 21:23
@ibgreen
ibgreen force-pushed the codex/sql-color-scales branch from 9419c73 to 18e2f61 Compare November 18, 2026 21:23
@ibgreen
ibgreen force-pushed the codex/sql-color-scale-widget branch from d067e8a to c5da73e Compare November 18, 2026 21:37
@ibgreen
ibgreen marked this pull request as ready for review November 18, 2026 21:57
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T21:58:39.732778Z c5da73e Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c5da73e3bf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@greptile-apps

greptile-apps Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The follow-up changes appear safe to merge.

Summary

Adds an experimental legend that follows SQL color scales on layers eligible to draw in each view.

  • Layers expose the SQL color scales currently applied to their colors.
  • Widgets receive the drawable layers selected for each screen view.
  • The color scale widget shows legends for layers that draw in its views.

The Line example’s export-name fix is in dependent PR #11192; that part of this assessment depends on the stacked PR.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[SQL color accessors] --> B[Resolved scales on Layer]
  C[Screen pass filters] --> D[Eligible layers per view]
  D --> E[Color scale widget]
  B --> E
  E --> F[Collapsible legends]
  F --> G[Scrollable quantile breaks]
Loading

Reviews (5) · Last reviewed commit: "Prevent overlap in horizontal quantile l..." · Reviewed by Greptile

Comment thread modules/widgets/src/stylesheet.css Resolved
Comment thread modules/widgets/src/stylesheet.css Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread modules/widgets/src/stylesheet.css Resolved

@ibgreen ibgreen left a comment

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.

One small classified-legend edge case: repeated quantile breaks can render duplicate intervals and swatches. With Arrow values [1, 1, 1, 1] and SCALE_QUANTILE(value, 3, PALETTE('#000000', '#aaaaaa', '#ffffff')), all map rows use white, but ColorLegend renders two identical white 1 – 1 entries. I verified this against the actual accessor and widget source with a VNode harness (not a browser). Consider building legend intervals from unique boundaries and special-casing a singleton extent to one labeled swatch; add a tied-values fixture.

Base automatically changed from codex/sql-color-scales to master November 19, 2026 13:45
@ibgreen
ibgreen force-pushed the codex/sql-color-scale-widget branch from c5da73e to e959f31 Compare November 19, 2026 13:53
Comment thread modules/widgets/src/index.ts Resolved

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e959f31. Configure here.

Comment thread modules/core/src/lib/layer.ts Resolved
Comment thread modules/widgets/src/stylesheet.css Resolved
@ibgreen
ibgreen merged commit ef166cf into master Nov 19, 2026
9 checks passed
@ibgreen
ibgreen deleted the codex/sql-color-scale-widget branch November 19, 2026 14:37
chrisgervang pushed a commit that referenced this pull request Nov 19, 2026
Brings in master, including #11240. The examples-v10 and website import
conflicts take #11240's version, which already imports `/legacy`. The
"Heatmap filtering" whats-new section, which an earlier merge here dropped by
mistake, comes back with master's update.

Master added `_ColorScaleWidget` to @deck.gl/widgets (#11193), so the root
wraps it too, as the wrappers test requires for every widget class.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

@chrisgervang chrisgervang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed ffa12e5 after merge; follow-ups below.

No P1s.

Labels: P1 settle before this is merged, P2 can follow, Non-blocking optional.


Generated by Claude Code

}
}

test('_ColorScaleWidget respects screen filters and its attached viewport', async () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

P2: The tests cover continuous, quantile and composite scales. Ordinal swatches and threshold or quantize intervals render through their own branches and have no test.

Could we add ordinal and threshold cases?


Generated by Claude Code

return scales.map(([accessor, scale]) => ({
layerId: layer.id,
accessor,
label: scales.length === 1 ? layer.id : `${layer.id} · ${formatAccessorLabel(accessor)}`,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Non-blocking: Legends are titled with the layer id and accessor, such as Readings · fill color. Could the title prefer descriptor.label and units when a scale sets them?


Generated by Claude Code

viewports: Viewport[];
layers: Layer[];
/** Drawable layers that passed the screen filters in each viewport. */
renderedLayers?: ReadonlyMap<Viewport, ReadonlySet<Layer>>;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

P2: onRedraw now passes renderedLayers to every widget, but the onRedraw entry in widget.md lists only viewports and layers. Custom widgets can use it, so it is public API.

Could we add a renderedLayers bullet to that entry?


Generated by Claude Code

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

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.

4 participants