import type { TimeUnit } from "./Time"; import { Entity, IEntitySettings, IEntityPrivate } from "./Entity"; export interface IDurationFormatterSettings extends IEntitySettings { /** * Format for every duration that is not given its own format. Overrides * `durationFormats`. */ durationFormat?: string; /** * Values below this are negative: they use the negative part of the format * (after the first `|`) and get a minus sign. A value equal to it uses the * zero part (after the second `|`). * * @default 0 */ negativeBase?: number; /** * Unit of the numbers being formatted: `"millisecond"`, `"second"`, * `"minute"`, `"hour"`, `"day"`, `"week"`, `"month"` or `"year"`. * * @see {@link https://www.amcharts.com/docs/v5/concepts/formatters/formatting-durations/#Base_unit} for more info * @default "second" */ baseUnit?: TimeUnit; /** * Formats picked when `durationFormat` is not set, by base unit and by the * largest unit the value reaches: `durationFormats[baseUnit][unit]`. Also * used by [[DurationAxis]]. */ durationFormats?: Partial>>>; /** * Data fields that hold durations. Text placeholders with these fields are * formatted as durations even without `formatDuration()`. * * @see {@link https://www.amcharts.com/docs/v5/concepts/formatters/data-placeholders/#Formatting_placeholders} for more info */ durationFields?: string[]; } export interface IDurationFormatterPrivate extends IEntityPrivate { } /** * Formats numbers as durations, such as `125` seconds as `"02:05"`. * * @see {@link https://www.amcharts.com/docs/v5/concepts/formatters/formatting-durations/} for more info */ export declare class DurationFormatter extends Entity { _settings: IDurationFormatterSettings; _privateSettings: IDurationFormatterPrivate; static className: string; static classNames: Array; protected _setDefaults(): void; /** * Collection of aliases for units. */ protected _unitAliases: { [index: string]: string; }; _beforeChanged(): void; /** * Formats a number as a duration. For example `1000` with base unit * `"second"` gives `"16:40"`: 16 minutes and 40 seconds. * * @param value Value to format * @param format Format to apply; `durationFormat` or a default from `durationFormats` if not given * @param base Base unit of the value; `baseUnit` if not given * @return Formatted number */ format(value: number | string, format?: string, base?: TimeUnit): string; /** * Parses supplied format into structured object which can be used to format * the number. * * @param format Format string, e.g. "hh:mm:ss" * @param base Override base unit * @return Parsed information */ protected parseFormat(format: string, base?: TimeUnit): any; /** * Applies parsed format to a numeric value. * * @param value Value * @param details Parsed format as returned by {parseFormat} * @return Formatted duration */ protected applyFormat(value: number, details: any): string; /** * Converts a value in `baseUnit` to milliseconds. * * @param value A source value * @param baseUnit Unit the value is in, such as `"second"` * @return Value in milliseconds */ toTimeStamp(value: number, baseUnit: TimeUnit): number; protected _toTimeUnit(code: string): TimeUnit | undefined; /** * Returns the format for `value`: `durationFormat` if set, otherwise the * entry of `durationFormats` for the largest unit the value reaches. * * With `maxValue`, the unit comes from the larger of the two, so a range of * values shares one format. With base unit `"second"`, `10` alone gets * `"ss"`, but with `maxValue` `600` it gets `"mm:ss"` and shows as `00:10`. * * @param value Value to format * @param maxValue Largest value of the range, used to pick the unit * @param baseUnit Base unit of the value; `baseUnit` if not given * @return Format */ getFormat(value: number, maxValue?: number, baseUnit?: TimeUnit): string; /** * Returns the largest unit the value holds more than one of: 100 seconds * is `"minute"`, 59 seconds is still `"second"`. * * @param value Source duration value * @param baseUnit Base unit; `baseUnit` setting if not given * @return Time unit */ getValueUnit(value: number, baseUnit?: TimeUnit): TimeUnit | undefined; /** * Converts a value in `baseUnit` to milliseconds. * * @param value Source duration value * @param baseUnit Base unit; `baseUnit` setting if not given * @return Value in milliseconds */ getMilliseconds(value: number, baseUnit?: TimeUnit): number; protected _getUnitValue(timeUnit: TimeUnit): number; protected _getUnitValues(): any; } //# sourceMappingURL=DurationFormatter.d.ts.map