Skip to content

fix(deck): compile all color scale properties on a layer - #781

Merged
igorDykhta merged 3 commits into
mainfrom
igr/deck-map-fixes
Jul 1, 2026
Merged

igorDykhta merged 3 commits into
mainfrom
igr/deck-map-fixes

Conversation

@igorDykhta

@igorDykhta igorDykhta commented Jul 1, 2026 •

Copy link
Copy Markdown
Collaborator

Previously applyColorScale only resolved the first color scale property found on a layer. If a layer defined both getFillColor and getLineColor (or getSourceColor/getTargetColor on arc layers) as color scales, only the first was compiled — the second remained unresolved.

  • Add getAllColorScales() and loop in applyColorScale to compile every color scale property
  • Fix extractColorScaleLegends to render legends for all color scale properties
  • Add tests for multi-color-scale layers and dual-color arc layers

Summary by CodeRabbit

  • New Features
    • Layers can now provide multiple color scale configurations at once; each supported color property is compiled separately with its own update triggers.
    • Arc layers can scale both source and target colors together.
  • Bug Fixes
    • Legend generation now produces legends for each configured color scale accessor, skipping failures for individual accessors instead of blocking all legends.
    • Legend titles now respect per-accessor title overrides and use the appropriate fallback when no override is provided.
  • Tests
    • Expanded coverage for multi–color-scale compilation and legend extraction behavior.

Signed-off-by: Ihor Dykhta <[email protected]>
@igorDykhta igorDykhta self-assigned this Jul 1, 2026
@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 84565a62-66f0-443f-841c-56b2535aeb5c

📥 Commits

Reviewing files that changed from the base of the PR and between 7c55090 and a32150c.

📒 Files selected for processing (3)
  • packages/deck/__tests__/createDeckJsonConfiguration.test.ts
  • packages/deck/src/json/colorScaleFunction.ts
  • packages/deck/src/json/extractColorScaleLegends.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/deck/src/json/extractColorScaleLegends.ts
  • packages/deck/src/json/colorScaleFunction.ts

📝 Walkthrough

Walkthrough

This PR adds support for multiple color-scale accessors per layer. It updates color-scale detection, JSON config compilation, and legend extraction to process all matching accessors, and adds tests for multi-accessor layers and legend behavior.

Changes

Multiple color scale support

Layer / File(s) Summary
Add getAllColorScales helper
packages/deck/src/json/colorScaleFunction.ts
Adds ColorScalePropName, introduces getAllColorScales to collect all matching color-scale entries, and makes getColorScale return the first match from that list.
Apply multiple color scales in JSON config compilation
packages/deck/src/json/createDeckJsonConfiguration.ts
Switches config compilation to getAllColorScales; applyColorScale now iterates over every discovered scale pair, compiling each prop and merging its updateTriggers.
Extract legends for multiple color scales
packages/deck/src/json/extractColorScaleLegends.ts
Switches legend extraction to getAllColorScales, resolves titles per accessor, and builds legends per scale with per-entry error skipping.
Tests for multi-accessor color scale compilation
packages/deck/__tests__/createDeckJsonConfiguration.test.ts
Adds coverage for multiple color-scale props on scatterplot and arc layers, plus legend extraction cases for multiple legends, per-accessor titles, and partial failure handling.

Estimated code review effort: 2 (Simple) | ~12 minutes

Possibly related PRs

  • sqlrooms/sqlrooms#746: Both PRs modify the same Deck JSON legend/color-scale plumbing and change how color-scale accessors are detected and translated into legends.

Suggested reviewers: ilyabo

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: compiling all color scale properties on a layer.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch igr/deck-map-fixes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Signed-off-by: Ihor Dykhta <[email protected]>
@igorDykhta igorDykhta changed the title fix: fixes for color scales fix(deck): compile all color scale properties on a layer Jul 1, 2026
@igorDykhta
igorDykhta marked this pull request as ready for review July 1, 2026 17:02

@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: 7c5509035f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/deck/src/json/extractColorScaleLegends.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
packages/deck/src/json/colorScaleFunction.ts (1)

34-59: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Missing tsdoc on new exported API surface.

ColorScalePropName, getColorScale, and getAllColorScales are new/modified exported symbols with no tsdoc.

As per coding guidelines, "Add tsdoc to exported types and functions in @sqlrooms/* packages."

📝 Example tsdoc additions
+/** Names of layer accessor props that can carry a color scale. */
 export type ColorScalePropName =
   | 'getFillColor'
   | 'getLineColor'
   | 'getColor'
   | 'getSourceColor'
   | 'getTargetColor';

+/**
+ * Returns the first color scale entry found on the layer props, if any.
+ * `@deprecated` Prefer {`@link` getAllColorScales} when a layer may define multiple color scale accessors.
+ */
 export function getColorScale(props: Record<string, unknown>):
   ...

+/** Returns every color scale entry found across all known accessor props on the layer. */
 export function getAllColorScales(props: Record<string, unknown>): Array<{
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/deck/src/json/colorScaleFunction.ts` around lines 34 - 59, Add tsdoc
for the new exported API in colorScaleFunction.ts: document ColorScalePropName,
getColorScale, and getAllColorScales. Use concise tsdoc comments on each
exported type/function describing what color scale properties they cover and
what each function returns, keeping the docs aligned with the existing
getAllColorScales/getColorScale behavior.

Source: Coding guidelines

packages/deck/src/json/extractColorScaleLegends.ts (1)

53-119: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

No test coverage for multi-scale legend extraction.

extractColorScaleLegends now loops and builds a legend per color scale, but only createDeckJsonConfiguration.test.ts gained multi-accessor tests; no test exercises this file's new looping/per-legend error-handling behavior (e.g. a layer with getFillColor + getLineColor, or getSourceColor + getTargetColor, producing two distinct legends).

As per coding guidelines, "Add or update tests when changing behavior or public API, when practical."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/deck/src/json/extractColorScaleLegends.ts` around lines 53 - 119,
Add tests for extractColorScaleLegends to cover the new per-color-scale loop and
fallback behavior. In the tests for extractColorScaleLegends, use a layer with
multiple resolved color scales (for example getFillColor plus getLineColor, or
getSourceColor plus getTargetColor) and assert that it returns a separate legend
for each scale. Also verify the error-handling path by making one color scale
fail in buildColorScaleLegend while another succeeds, and confirm the successful
legend is still returned.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/deck/src/json/colorScaleFunction.ts`:
- Around line 34-59: Add tsdoc for the new exported API in
colorScaleFunction.ts: document ColorScalePropName, getColorScale, and
getAllColorScales. Use concise tsdoc comments on each exported type/function
describing what color scale properties they cover and what each function
returns, keeping the docs aligned with the existing
getAllColorScales/getColorScale behavior.

In `@packages/deck/src/json/extractColorScaleLegends.ts`:
- Around line 53-119: Add tests for extractColorScaleLegends to cover the new
per-color-scale loop and fallback behavior. In the tests for
extractColorScaleLegends, use a layer with multiple resolved color scales (for
example getFillColor plus getLineColor, or getSourceColor plus getTargetColor)
and assert that it returns a separate legend for each scale. Also verify the
error-handling path by making one color scale fail in buildColorScaleLegend
while another succeeds, and confirm the successful legend is still returned.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5be8aff6-b4c9-47be-9108-68cba21d5af8

📥 Commits

Reviewing files that changed from the base of the PR and between c6ad8a7 and 7c55090.

📒 Files selected for processing (4)
  • packages/deck/__tests__/createDeckJsonConfiguration.test.ts
  • packages/deck/src/json/colorScaleFunction.ts
  • packages/deck/src/json/createDeckJsonConfiguration.ts
  • packages/deck/src/json/extractColorScaleLegends.ts

Signed-off-by: Ihor Dykhta <[email protected]>
@igorDykhta
igorDykhta requested a review from ilyabo July 1, 2026 17:29
@igorDykhta
igorDykhta merged commit 70af2a8 into main Jul 1, 2026
4 checks passed
@igorDykhta
igorDykhta deleted the igr/deck-map-fixes branch July 1, 2026 22:13
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.

2 participants