Skip to main content
100%

d3js Exercice 1 - number formats

✓ Published0🌍 Public
AAlainRo
Last edited Feb 22, 2018
Created on Oct 3, 2017

This example demonstrates how to format numbers in JavaScript using the d3-format module, highlighting the limitations of native floating-point arithmetic. It first shows the raw output of multiplying 0.1 by integers, then applies various format specifiers like `.1f`, `.2s`, and `.2s` with a custom French locale to control decimals, thousands separators, and SI-prefix notation. The code uses `d3.format` and `d3.formatDefaultLocale` from the d3-format v1 library, reading a hardcoded value (`x`) to illustrate different formatting outputs. The rendering approach is a simple HTML `<pre>` block with `document.writeln`.

AI-generated description

d3js Exercice 1 - number formats

Built with blockbuilder.org

mit Licensed

Similar vizzes