Numeric
Piwik\Plugins\CoreVisualizations\Metrics\Formatter\
Numeric
A metrics formatter that prettifies metric values without returning string values.
Results of this class can be converted to numeric values and processed further in some way.
Methods
The class defines the following methods:
getPrettyNumber()ash; Returns a prettified string representation of a number. Inherited fromFormattergetPrettyTimeFromSeconds()ash; Returns a prettified time value (in seconds). Inherited fromFormattergetPrettySizeFromBytes()ash; Returns a prettified memory size value. Inherited fromFormattergetPrettyMoney()ash; Returns a pretty formatted monetary value using the currency associated with a site. Inherited fromFormattergetPrettyPercentFromQuotient()ash; Returns a percent string from a quotient value. Inherited fromFormatterformatMetrics()ash; Formats all metrics, including processed metrics, for a DataTable. Inherited fromFormatter
getPrettyNumber()
Returns a prettified string representation of a number. The result will have
thousands separators and a decimal point specific to the current locale, eg,
'1,000,000.05' or '1.000.000,05'.
Signature
It accepts the following parameter(s):
$value$precision
It returns a
stringvalue.
getPrettyTimeFromSeconds()
Returns a prettified time value (in seconds).
Signature
- It accepts the following parameter(s):
$numberOfSeconds(int) — The number of seconds.$displayTimeAsSentence(bool) — If set to true, will output"5min 17s", if false"00:05:17".$round(bool) — Whether to round to the nearest second or not.
- It returns a
stringvalue.
getPrettySizeFromBytes()
Returns a prettified memory size value.
Signature
It accepts the following parameter(s):
$size(string|int|float) — The size in bytes.$unit(string) — The specific unit to use, if any. If null, the unit is determined by $size.$precision(int) — The precision to use when rounding.
Returns:
string— eg,'128 M'or'256 K'.
getPrettyMoney()
Returns a pretty formatted monetary value using the currency associated with a site.
Signature
- It accepts the following parameter(s):
$value(int|string) — The monetary value to format.$idSite(int) — The ID of the site whose currency will be used.
- It returns a
stringvalue.
getPrettyPercentFromQuotient()
Returns a percent string from a quotient value. Forces the use of a '.' decimal place.
Signature
It accepts the following parameter(s):
$value(float) —
It returns a
stringvalue.
formatMetrics()
Formats all metrics, including processed metrics, for a DataTable. Metrics to format are found through report metadata and DataTable metadata.
Signature
- It accepts the following parameter(s):
$dataTable(DataTable) — The table to format metrics for.$report(Report|null) — The report the table belongs to.$metricsToFormat(string[]|null) — Allow a list of names of metrics to format.$formatAll(boolean) — If true, will also apply formatting to non-processed metrics like revenue. This parameter is not currently supported and subject to change.
- It does not return anything or a mixed result.