Skip to content

fix regression: formatPrefix and precisionPrefix for a zero value - #165

Open
Fil wants to merge 1 commit into
mainfrom
fil/fix-zero-prefix
Open

Fil wants to merge 1 commit into
mainfrom
fil/fix-zero-prefix

Conversation

@Fil

@Fil Fil commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Since 3.1.1 (#147), exponent(0) returns NaN. formatPrefix(specifier, value) and precisionPrefix(step, value) derive the SI prefix from the exponent of value, so a value of 0 broke both:

  • precisionPrefix(1, 0) returned NaN instead of 0;
  • formatPrefix(",.0", 0)(1000) returned "NaN" instead of "1,000".

Both now use an exponent of 0 for a zero value, as before #147.

In d3-scale, this caused the "NaN" tick label of scaleLinear().domain([0, 0]).tickFormat(5, "s").

supersedes #159
related #162, #287

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.

1 participant