fix(deck.gl): use interval notation for Polygon legend bucket labels#41400
Conversation
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>
Code Review Agent Run #bc3410Actionable Suggestions - 0Additional Suggestions - 1
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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>
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
DamianPendrak
left a comment
There was a problem hiding this comment.
Tested locally. Looks good!
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…xture Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Bito Automatic Review Skipped – PR Already Merged |
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, where81and212each appear twice and the ranges read as overlapping. The binning itself is fine (coloring uses d3scaleThreshold, which is half-open, so a value of exactly81lands in exactly one bucket); it's only the label text that's ambiguous.This swaps
getBucketsover 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
Legendformatter learned to recognize interval-notation keys so it still number-formats each bound (via the chart's d3 format) while preserving the brackets. The legacya - bdelimiter 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
[a, b)intervals with no shared endpoints, and number formatting still applies to each bound.Unit tests cover it too:
getBucketsasserts the non-overlapping interval labels, and a newLegend.test.tsxpins both the interval formatting and the legacya - bpath.ADDITIONAL INFORMATION