Skip to content

trim tick format when no precision can be derived - #294

Open
Fil wants to merge 1 commit into
mainfrom
fil/fix-tickformat-trim
Open

Fil wants to merge 1 commit into
mainfrom
fil/fix-tickformat-trim

Conversation

@Fil

@Fil Fil commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

When the precision functions return NaN, tickFormat now trims insignificant trailing zeros instead of using the default precision.

This happens:

  • when the domain is a single value (the step is zero: a flat line at 5 was labeled "5.000000", at 0.5 "0.500000"; Flat line plot gets wrong y-axis tick mark observablehq/plot#2348);
  • when the largest absolute value in the domain equals the step (precisionRound(step, step) is NaN since d3-format 3.1.1: [-1, 1] with tickFormat(2, "r") was labeled "−1.00000", "0", "1.00000"), and
  • when the domain is invalid (now " >-,~f").

Depends on d3/d3-format#165 (formatPrefix with a zero value) for the "s" type with a [0, 0] domain.

Not sure if we need to reflect the dependency as a hard requirement in package.json?

supersedes #287
supersedes d3/d3-format#162
closes #286
closes observablehq/plot#2076

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.

The default tickFormat with a collapsed domain lacks sufficient precision The default tickFormat with a collapsed domain lacks sufficient precision

2 participants