near-zero and near-100 rounding option

Open
#109 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
38/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
d3, javascript

Research direction

Start by reading the percent-formatting implementation and its tests to find where rounding and format options are handled. Add a flag for displaying values that round to 0% or 100% as threshold labels such as <0.1% or >99.9%, then verify the new behavior with tests covering values near both endpoints.

Written by the indexing model from the issue text.

Description

Right now using a simple percent format like:

const f = format('.1%')

Gives misleading results near 0 and 100:

f(0.0001) // 0.0%
f(0.9999) // 100.0%

Even though these are technically correct from a rounding perspective, they lead to confusion for users because it reads as "absolute". Which is why it's common to instead refer these as:

<0.1%
>99.9%

It would be really nice if there was a flag for this style of percentage formatting.

Dominant language
JavaScript
Stars
643
Forks
107
Avg merge
6h 25m
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from d3/d3-format

All issues in d3/d3-format

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.