import { AbstractFormatter } from '../Formatter'; import { DataType, TypedValue } from '../DataPrimitive'; import { DataPoint } from '../DataPoint'; /** * @class FormatByType * * Formats the value based on the value type and the provided config. For example * * ```js table | seriesByName("formatted") | formatByType(formattedConfig)', }, }, }} dataSources = {{ primary: { requestParams: { offset: 0, count: 20 }, data: { fields: [ { name: 'number' }, { name: 'formatted' }, ], columns: [ [-927916.96, -924916.9, -654089.75], [-927916.96, -924916.9, -654089.75], ], }, meta: { totalCount: 100 }, }, }} /> * ``` * * ## Config Object * * ### number * * * **unit?**: `string` to be appended or prepended to the value * * **unitPosition?**: `{"before" | "after"}` where should the `unit` be placed. Maps to numbro `prefix` or `postfix` * * **numberPrecision?**: `number` maps to numbro `mantissa` * * **mantissa?**: `number` number of decimal points to show * * **trimMantissa?**: `boolean` ending 0s in decimal points will be trimmed * * **thousandSeparated?**: `boolean` should show `,` for thousands * * **output?**: `"currency" | "percent" | "byte" | "time" | "ordinal" | "number"` value will be converted to one of thse formats * * **base?**: `"decimal" | "binary" | "general"` used for converting value to bytes * * **prefix?**: `string` string to be added in front of the value * * **postfix?**: `string` string to be appended to the value * * **forceAverage?**: `"trillion" | "billion" | "million" | "thousand"` can be used to force one the selected average * * **average?**: `boolean` rounds up the value to the closed average * * **totalLength?**: `number` used only for `average`. The number length to format data in * * **spaceSeparated?**: `boolean` used with `average` to introduce space between number and average * * **abbreviations?**: `{ thousand?: string; million?: string; billion?: string; trillion?: string; }` abbreviation values for averages. * * **negative?**: `"sign" | "parenthesis"` display sign or parenthesis for negative numbers * * **forceSign?**: `boolean` always show + or - sign * * * * For examples, refer [Numbro](https://numbrojs.com/format.html#format) * * #### time * * * **format**: valid moment format string. Refer - [moment display](https://momentjs.com/docs/#/displaying/) * * * */ export declare class FormatByType extends AbstractFormatter { private readonly config; constructor(config: Record); protected formatTypedValue(p: DataPoint): TypedValue; }