Giter VIP home page Giter VIP logo

Comments (3)

robatwilliams avatar robatwilliams commented on May 3, 2024 1

D3 4.12.2:

d3.format('.2')(undefined) // "NaN"
d3.format('.2')(null) // "0"
d3.format('.2')(NaN) // "NaN"

These are the string representations of what Number() returns when given the above test values.

I don't think any chosen output would suit everyone in this case, so it would be best handled by wrapping the formatter.

NaN at least draws attention to missing data so you can do something about it - whether that be formatting expected missing data to empty string, or fixing a bug that results in unexpectedly missing data. Perhaps a change could be made to draw attention to the null case in the same way.

from d3-format.

mbostock avatar mbostock commented on May 3, 2024

Yes, the locale should be able to specify what to display for NaN input. For example in U.S. English Iā€™d probably use "N/A" instead of "NaN". Likewise we might want to short-circuit some of the formatting logic. For example this:

d3.format('+%')(NaN)

Should probably return "N/A" (or "NaN"), not "+NaN%" as it currently does. But if the format has padding or alignment, that should probably be observed even while the value itself is formatted as "N/A".

from d3-format.

mbostock avatar mbostock commented on May 3, 2024

You can now localize NaN, but Iā€™d like to switch to using N/A by default instead of NaN for the next major release, so repurposing this issue.

from d3-format.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.