Skip to content

fix(deck.gl): use interval notation for Polygon legend bucket labels#41400

Merged
rusackas merged 4 commits into
masterfrom
fix/issue-40786-deckgl-legend-shared-endpoints
Jun 25, 2026
Merged

fix(deck.gl): use interval notation for Polygon legend bucket labels#41400
rusackas merged 4 commits into
masterfrom
fix/issue-40786-deckgl-legend-shared-endpoints

Conversation

@rusackas

Copy link
Copy Markdown
Member

SUMMARY

The deck.gl Polygon legend builds each bucket label by pairing adjacent breakpoints as a - b, so every interior breakpoint shows up in two labels — e.g. 1 - 81, 81 - 212, 212 - 369, where 81 and 212 each appear twice and the ranges read as overlapping. The binning itself is fine (coloring uses d3 scaleThreshold, which is half-open, so a value of exactly 81 lands in exactly one bucket); it's only the label text that's ambiguous.

This swaps getBuckets over to half-open interval notation — [1, 81), [81, 212), [212, 369] — with the final bucket closed on the right so the max value is still included. That matches what the color scale actually does and reads as a clean, non-overlapping partition. As the issue notes, just incrementing the lower bound (82 - 212) doesn't generalize, since breakpoints and values can be fractional — interval notation sidesteps that.

The Legend formatter learned to recognize interval-notation keys so it still number-formats each bound (via the chart's d3 format) while preserving the brackets. The legacy a - b delimiter path is untouched, so the manual color-breakpoints legend keeps formatting as before.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before: 1 - 81, 81 - 212, 212 - 369 (shared endpoints)
After: [1, 81), [81, 212), [212, 369] (clean partition)

TESTING INSTRUCTIONS

  1. Create a deck.gl Polygon chart with a numeric metric.
  2. Leave Bucket break points empty (use the default Number of buckets).
  3. Check the legend — bins now read as [a, b) intervals with no shared endpoints, and number formatting still applies to each bound.

Unit tests cover it too: getBuckets asserts the non-overlapping interval labels, and a new Legend.test.tsx pins both the interval formatting and the legacy a - b path.

ADDITIONAL INFORMATION

The Polygon legend built bucket labels by pairing adjacent breakpoints
as "a - b", so every interior breakpoint showed up in two labels (e.g.
"1 - 81", "81 - 212"), reading as overlapping ranges. The underlying
binning is correct (d3 scaleThreshold is half-open), only the labels
were ambiguous.

Switch getBuckets to half-open interval notation ("[1, 81)", "[81, 212)",
... with the final bucket closed "[212, 369]") so the labels form a clean,
non-overlapping partition that matches the actual coloring. The Legend
formatter now recognizes interval-notation keys and number-formats each
bound while preserving the brackets, keeping d3 format support intact.

Fixes #40786

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dosubot dosubot Bot added the viz:charts:deck.gl Related to deck.gl charts label Jun 24, 2026
@bito-code-review

bito-code-review Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #bc3410

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset-frontend/plugins/preset-chart-deckgl/src/utils.test.ts - 1
    • Duplicated test helper function · Line 497-497
      The `accessor` function at line 497 duplicates the identical `const accessor = (d: any) => d.value;` already declared at line 53 inside the `getBreakPoints` describe block. Consider extracting both `accessor` and `buildFeatures` to file scope (after imports) to reduce duplication and improve maintainability. BITO.md rule [6262] also encourages tests to verify business logic directly — shared helpers make this clearer.
Review Details
  • Files reviewed - 4 · Commit Range: b84ca44..b84ca44
    • superset-frontend/plugins/preset-chart-deckgl/src/components/Legend.test.tsx
    • superset-frontend/plugins/preset-chart-deckgl/src/components/Legend.tsx
    • superset-frontend/plugins/preset-chart-deckgl/src/utils.test.ts
    • superset-frontend/plugins/preset-chart-deckgl/src/utils.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.30435% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.47%. Comparing base (6f12d17) to head (2e5f4db).
⚠️ Report is 23 commits behind head on master.

Files with missing lines Patch % Lines
...gins/preset-chart-deckgl/src/components/Legend.tsx 89.47% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #41400      +/-   ##
==========================================
+ Coverage   64.44%   64.47%   +0.02%     
==========================================
  Files        2655     2655              
  Lines      145473   145495      +22     
  Branches    33575    33580       +5     
==========================================
+ Hits        93747    93801      +54     
+ Misses      50027    49995      -32     
  Partials     1699     1699              
Flag Coverage Δ
javascript 68.82% <91.30%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rusackas rusackas requested a review from DamianPendrak June 25, 2026 08:23
Swap the cryptic interval-label regex in the Legend formatter for a small
named parseInterval() helper. Same behavior — open bracket [ or (, close
bracket ] or ), exactly one comma, non-empty bounds — but it reads as plain
steps instead of a regex.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Comment thread superset-frontend/plugins/preset-chart-deckgl/src/utils.test.ts Outdated
Comment thread superset-frontend/plugins/preset-chart-deckgl/src/utils.test.ts Outdated
@netlify

netlify Bot commented Jun 25, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 9c3f223
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a3d5a4262e67500087241e8
😎 Deploy Preview https://deploy-preview-41400--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@rusackas rusackas requested a review from kgabryje June 25, 2026 17:03

@DamianPendrak DamianPendrak left a comment

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.

Tested locally. Looks good!

rusackas and others added 2 commits June 25, 2026 10:35
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…xture

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rusackas rusackas merged commit aac02ab into master Jun 25, 2026
66 checks passed
@rusackas rusackas deleted the fix/issue-40786-deckgl-legend-shared-endpoints branch June 25, 2026 19:23
@bito-code-review

Copy link
Copy Markdown
Contributor

Bito Automatic Review Skipped – PR Already Merged

Bito scheduled an automatic review for this pull request, but the review was skipped because this PR was merged before the review could be run.
No action is needed if you didn't intend to review it. To get a review, you can type /review in a comment and save it

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deck.gl Polygon legend labels share endpoints (cosmetic / ambiguous range labels)

2 participants