Installations
npm install d3plus-format
Developer Guide
Typescript
No
Module System
ESM
Node Version
16.16.0
NPM Version
8.17.0
Score
76.9
Supply Chain
99.5
Quality
77.1
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
d3plus
Download Statistics
Total Downloads
197,852
Last Day
96
Last Week
625
Last Month
3,571
Last Year
36,738
GitHub Statistics
1 Stars
165 Commits
5 Watching
2 Branches
8 Contributors
Package Meta Information
Latest Version
1.2.8
Package Id
d3plus-format@1.2.8
Unpacked Size
388.26 kB
Size
101.17 kB
File Count
12
NPM Version
8.17.0
Node Version
16.16.0
Publised On
20 Aug 2024
Total Downloads
Cumulative downloads
Total Downloads
197,852
Last day
-65.5%
96
Compared to previous day
Last week
-51.2%
625
Compared to previous week
Last month
-5.9%
3,571
Compared to previous month
Last year
20%
36,738
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
3
Dev Dependencies
1
d3plus-format
Shorthand formatters for common number types.
Installing
If using npm, npm install d3plus-format
. Otherwise, you can download the latest release from GitHub or load from a CDN.
1import modules from "d3plus-format";
d3plus-format can be loaded as a standalone library or bundled as part of D3plus. ES modules, AMD, CommonJS, and vanilla environments are supported. In vanilla, a d3plus
global is exported:
1<script src="https://cdn.jsdelivr.net/npm/d3plus-format@1"></script> 2<script> 3 console.log(d3plus); 4</script>
Examples
Live examples can be found on d3plus.org, which includes a collection of example visualizations using d3plus-react. These examples are powered by the d3plus-storybook repo, and PRs are always welcome. :beers:
API Reference
- format - 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 theformatAbbreviate
function.
- formatAbbreviate - Formats a number to an appropriate number of decimal places and rounding, adding suffixes if applicable (ie.
1200000
to"1.2M"
). - formatDate - A default set of date formatters, which takes into account both the interval in between in each data point but also the start/end data points.
- formatDefaultLocale - An extension to d3's formatDefaultLocale function that allows setting the locale globally for formatters.
- formatLocale - A set of default locale formatters used when assigning suffixes and currency in numbers.
Name | Default | Description |
---|---|---|
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.format(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 theformatAbbreviate
function.
This is a global function.
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.
Param | Type | Description |
---|---|---|
n | Number | String | The number to be formatted. |
locale | Object | String | The 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.formatDate(d, dataArray, [formatter]) <>
A default set of date formatters, which takes into account both the interval in between in each data point but also the start/end data points.
This is a global function.
Param | Type | Default | Description |
---|---|---|---|
d | Date | The date string to be formatted. | |
dataArray | Array | The full array of ordered Date Objects. | |
[formatter] | function | d3.timeFormat | An optional instance of d3.timeFormat to be used for localization. |
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.
Name | Default | Description |
---|---|---|
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, 20 Aug 2024 20:27:12 GMT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/NodeCI.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/d3plus/d3plus-format/NodeCI.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/NodeCI.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/d3plus/d3plus-format/NodeCI.yml/main?enable=pin
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 1 out of 1 npmCommand dependencies pinned
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/NodeCI.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
Project has not signed or included provenance with any releases.
Details
- Warn: release artifact v1.2.8 not signed: https://api.github.com/repos/d3plus/d3plus-format/releases/171150359
- Warn: release artifact v1.2.7 not signed: https://api.github.com/repos/d3plus/d3plus-format/releases/137592583
- Warn: release artifact v1.2.6 not signed: https://api.github.com/repos/d3plus/d3plus-format/releases/112820393
- Warn: release artifact v1.2.5 not signed: https://api.github.com/repos/d3plus/d3plus-format/releases/111327228
- Warn: release artifact v1.1.3 not signed: https://api.github.com/repos/d3plus/d3plus-format/releases/112819654
- Warn: release artifact v1.2.8 does not have provenance: https://api.github.com/repos/d3plus/d3plus-format/releases/171150359
- Warn: release artifact v1.2.7 does not have provenance: https://api.github.com/repos/d3plus/d3plus-format/releases/137592583
- Warn: release artifact v1.2.6 does not have provenance: https://api.github.com/repos/d3plus/d3plus-format/releases/112820393
- Warn: release artifact v1.2.5 does not have provenance: https://api.github.com/repos/d3plus/d3plus-format/releases/111327228
- Warn: release artifact v1.1.3 does not have provenance: https://api.github.com/repos/d3plus/d3plus-format/releases/112819654
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
14 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
2.5
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More