AnyChart
API Reference
Still have questions?
Contact support
Top
You are looking at an outdated 7.8.0 version of this document. Switch to the 8.2.1 version to see the up to date information.

namespace anychart.format Improve this Doc

Namespace for format.

Functions Overview

dateTime()Formats date by pattern.
number()Formats number.
subs()Formats for string substitution.

Functions Description

dateTime

Formats date by pattern.

Params:

Name Type Description
date number | Date UTC timestamp or Date object.
pattern string Format of date.
timeZone number Adjust with time zone. Indicate minutes WEST of UTC to be used as a constant time zone offset.

Returns:

string - Formatted value.

Try it:

number

Formats number with given settings.

Params:

Name Type Default Description
number number
Number for formatting.
decimalsCount number
2
Desired number of decimals.
decimalPoint string
"."
String to modify the decimal separator.
groupsSeparator string
""
String to separate every three digits.
scale Object | boolean
false
Automatic scaling (divides by factor and substitutes suffix). If pass "true", will be used default scale.
zeroFillDecimals boolean
false
Whether to fill in the remaining decimal places zeros.
scaleSuffixSeparator string
""
Additive between the suffix of scale and the number. Works only with scaling.

Returns:

string - Formatted value.

Try it:

Formats number using object.

Params:

Name Type Description
number number Number for formatting.
settings Object Object with settings.

Returns:

string - Formatted value.

Try it:

subs

Formats for string substitution. For example: subs("foo%s hot%s", "bar", "dog") becomes "foobar hotdog".

Params:

Name Type Description
string string The string containing the pattern.
var_args * The items to substitute into the pattern.

Returns:

string - A copy of {@code str} in which each occurrence of {@code %s} has been replaced an argument from {@code var_args}.

Try it: