Type class
NumberFormatter class. Formats numbers according to specified formats.
@todo Apply translations to suffixes/prefixes
Sources
NumberFormatter can be used (imported) via one of the following packages.
/** * -------------------------------------------------------- * Import from: "core.ts" * Use like: am4core.NumberFormatter * -------------------------------------------------------- */ import * as am4core from "@amcharts/amcharts4/core";
/** * -------------------------------------------------------- * Include via: <script src="core.js"></script> * Access items like: am4.NumberFormatter * -------------------------------------------------------- */
Inheritance
NumberFormatter extends BaseObject
.
NumberFormatter is not extended by any other symbol.
Properties
bigNumberPrefixes # |
Type Prefixes for big numbers. It's an array of objects of number/prefix pairs. [ { "number": 1e+3, "suffix": "K" }, { "number": 1e+6, "suffix": "M" }, { "number": 1e+9, "suffix": "G" }, { "number": 1e+12, "suffix": "T" }, { "number": 1e+15, "suffix": "P" }, { "number": 1e+18, "suffix": "E" }, { "number": 1e+21, "suffix": "Z" }, { "number": 1e+24, "suffix": "Y" } ] If the number is bigger than the E.g. as per above Please note that for this transformation to be enabled, you need to enable it specific modifier in your format setting. The modifier for big/small number modification is "a": {myfield.formatNumber("#,###.00a")} Click here Tutorial on number formatting |
---|---|
bytePrefixes # |
Type Basically the same as The modifier is "b". {myfield.formatNumber("#,###.00b")} The above Click here Tutorial on number formatting |
clonedFrom # |
Type Inherited from Reference to the original object this object was cloned from. We need to keep this so we can disassociate it from source object when this object is disposed. |
config # |
Type Inherited from Use this property to set JSON-based config. When set, triggers processing routine, which will go through all properties, and try to apply values, create instances, etc. Use this with caution, as it is a time-consuming process. It's used for initialchart setup only, not routine operations. |
forceLTR # |
Type |
id # |
Type Inherited from Sets the user-defined id of the element. |
intlLocales # |
Type Locales if you are using date formats in @see (@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat) about using Intl for number formatting |
language # |
Type A reference to Formatter will use language to translate various items, like number suffixes, etc. |
negativeBase # |
Type Default Negative base for negative numbers. Click here Tutorial on number formatting |
numberFormat # |
Type Default Number format. Click here Tutorial on number formatting |
smallNumberPrefixes # |
Type Prefixes for big numbers. It's an array of objects of number/prefix pairs. [ { "number": 1e-24, "suffix": "y" }, { "number": 1e-21, "suffix": "z" }, { "number": 1e-18, "suffix": "a" }, { "number": 1e-15, "suffix": "f" }, { "number": 1e-12, "suffix": "p" }, { "number": 1e-9, "suffix": "n" }, { "number": 1e-6, "suffix": "μ" }, { "number": 1e-3, "suffix": "m" } ] If the number is smaller than the E.g. as per above Please note that for this transformation to be enabled, you need to enable it specific modifier in your format setting. The modifier for big/small number modification is "a": {myfield.formatNumber("#,###.00a")} IMPORTANT: The order of the suffixes is important. The list must start from the smallest number and work towards bigger ones. Click here Tutorial on number formatting |
smallNumberThreshold # |
Type Any number smaller than this will be considered "small" number, which will trigger special formatting if "a" format modifier is used. @since 4.6.8 |
sprite # |
Type Holds reference to parent |
uid # |
Type Inherited from Returns object's internal unique ID. |
There are 4 inherited items currently hidden from this list. |
Methods
clone( cloneId?: ) |
Returns Inherited from Makes a copy of this object and returns the clone. Try to avoid cloning complex objects like chart, create new instances if you need them. |
---|---|
constructor() |
Returns Constructor |
copyFrom( object: ) |
Returns Inherited from Copies all properties and related data from different element. |
dispose() |
Returns |
format( value: ) |
Returns Formats the number according to specific format. |
getCurrentThemes() |
Returns Inherited from Returns a list of themes that should be applied to this element. It could either be a list of themes set explicitly on this element, or system-wide. |
isDisposed() |
Returns Inherited from Returns if this object has been already been disposed. |
There are 4 inherited items currently hidden from this list. |
Events
NumberFormatter does not have any events.
Adapters
NumberFormatter does not have any adapters.