New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

d3plus-format

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3plus-format

Shorthand formatters for common number types.

  • 0.1.20
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
828
decreased by-42.06%
Maintainers
1
Weekly downloads
 
Created
Source

d3plus-format

NPM Release Build Status Dependency Status Gitter

Shorthand formatters for common number types.

Installing

If you use NPM, run npm install d3plus-format --save. Otherwise, download the latest release. The released bundle supports AMD, CommonJS, and vanilla environments. You can also load directly from d3plus.org:

<script src="https://d3plus.org/js/d3plus-format.v0.1.full.min.js"></script>

API Reference

  • formatAbbreviate - Formats a number to an appropriate number of decimal places and rounding, adding suffixes if applicable (ie. 1200000 to "1.2M").
  • formatAbbreviate - An extension to d3's format function that adds more string formatting types and localizations.

The new specifier strings added by d3plus-format are:

  • .3~a - abbreviated decimal notation with a numeric suffix (ie. "k", "M", "B", etc). This is an alias of the formatAbbreviate function.
  • formatLocale - A set of default locale formatters used when assigning suffixes and currency in numbers.
NameDefaultDescription
separator""Separation between the number with the suffix.
suffixes[]List of suffixes used to format numbers.
grouping[3]The array of group sizes,
delimiters{thousands: ",", decimal: "."}Decimal and group separators.
currency["$", ""]The currency prefix and suffix.

d3plus.formatAbbreviate(n, locale) <>

Formats a number to an appropriate number of decimal places and rounding, adding suffixes if applicable (ie. 1200000 to "1.2M").

This is a global function.

ParamTypeDescription
nNumber | StringThe number to be formatted.
localeObject | StringThe locale config to be used. If value is an object, the function will format the numbers according the object. The object must include suffixes, delimiter and currency properties.

d3plus.formatAbbreviate(specifier) <>

An extension to d3's format function that adds more string formatting types and localizations.

The new specifier strings added by d3plus-format are:

  • .3~a - abbreviated decimal notation with a numeric suffix (ie. "k", "M", "B", etc). This is an alias of the formatAbbreviate function.

This is a global function.


d3plus.formatDefaultLocale(definition) <>

An extension to d3's formatDefaultLocale function that allows setting the locale globally for formatters.

This is a global function.


formatLocale <>

A set of default locale formatters used when assigning suffixes and currency in numbers.

NameDefaultDescription
separator""Separation between the number with the suffix.
suffixes[]List of suffixes used to format numbers.
grouping[3]The array of group sizes,
delimiters{thousands: ",", decimal: "."}Decimal and group separators.
currency["$", ""]The currency prefix and suffix.

This is a global namespace.


Documentation generated on Tue, 22 Dec 2020 15:36:19 GMT

Keywords

FAQs

Package last updated on 22 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc