Skip to content

fix(nice): bound intervals crossing zero - #293

Open
awais-ur-rehman wants to merge 1 commit into
d3:mainfrom
awais-ur-rehman:feat/finite-nice-interval
Open

awais-ur-rehman wants to merge 1 commit into
d3:mainfrom
awais-ur-rehman:feat/finite-nice-interval

Conversation

@awais-ur-rehman

Copy link
Copy Markdown

Summary

nice(-1, 5, 1) repeatedly widens its domain until the step overflows, so a histogram with one requested threshold can produce NaN bounds. Use a minimum effective count of two for positive counts below two when the interval crosses zero, allowing the existing rounding loop to converge.

Fixes #292. Adds coverage for fractional counts, asymmetric intervals on either side of zero, and histogram bounds.

Breaking Changes

None.

Testing

  • npm test -- --run — 533 passed, 1 skipped.
  • npm run lint
  • npm run prepublishOnly

I used Codex to help reproduce the failure, implement the fix, and run the tests.

@Fil Fil mentioned this pull request Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

d3.nice(start, stop, 1) returns [-1e308, 1e308] when the interval contains zero, so d3.bin gives NaN bin bounds

1 participant