public class Formatter extends com.google.gwt.core.client.JavaScriptObject implements IsFunction
Formatter
instances can be created with D3.format(String)
or
with the create(String)
method.
The format specifier is modeled after Python 3.1's built-in format specification mini-language.
The general form of a specifier is [[fill]align][sign][#][0][width][,][.precision][type].
The fill
can be any character other than "{" or "}". The presence of a fill character is signaled by the character following it, which must be one of the align options.
The align
can be:
sign
can be:
The "#"
option is only valid for binary, octal, or hexadecimal output. If present, it specifies that the output will be prefixed by "0b", "0o", or "0x", respectively.
The "0"
option enables zero-padding.
The width
defines the minimum field width. If not specified, then the width will be determined by the content.
The comma (",")
option enables the use of a comma for a thousands separator.
The precision
indicates how many digits should be displayed
after the decimal point for a value formatted with types "f" and "%",
or before and after the decimal point for a value formatted with types "g", "r" and "p".
The available type
values are:
Modifier | Constructor and Description |
---|---|
protected |
Formatter() |
Modifier and Type | Method and Description |
---|---|
static Formatter |
create(String specifier)
Create a new instance of
Formatter . |
String |
format(double d)
Return a String representation of the specified number formatted
according to the specifier of this
Formatter . |
Copyright © 2015 gwt-d3. All rights reserved.