StyleCode - Number Pipeline

This pipeline controls the pretty-printing of numbers. The main behaviour is determined by the numbers property.

Selecting the scale and suffix

The common point between auto, simple, thousands, millions, percent and scientific is that they choose a scale and a suffix according to this table:

ModeScaleSuffix
simple1
thousands1000k
millions1000000m
percent0.01%
scientificThe power of ten P = 10^N such that P <= x < 10 P1eN
autoComplex, see below.

When numbers is auto, an algorithm examines a set of numbers and determines a scale among 10^9, 10^6, 10^3, 1, 10^-3, 10^-6 and 10^-9 (and associated prefixes b, m, k, ``, 10⁻³, 10⁻⁶ and 10⁻⁹), and a precision, by trying to get the most visually appealing reasult when this scale, prefix and precision are applied to all numbers in the set.

The details of this optimization are implementation-defined (outside the scope of this specification) but the general idea is that the algorithm attempts to minimize noise digits (displaying 1 as 1.00 creates two digits of noise) as well as lost digits (displaying 1.23 as 1 loses two digits of data).

Each number on an Envision dashboard belongs to exactly one set of numbers, which will be considered together for the purpose of this optimization. These sets are:

All other numbers are considered alone.

Selecting the precision

The number will be displayed in format "X.Y", and the precision determines the number of digits in Y (a value between 0 and 16). This is a form of rounding, so 10.996 displayed with a precision of 2 becomes "11.00".

If numbers is auto, this precision has already been selected in the previous step.

The algorithm computes the number of significant digits D by looking for a sequence 000 or 999 in the decimal expansion of the number. For example:

NumberDIdeal rendering
100"10"
10.0013"10.001"
10.00010"10"
10.3993"10.399"
10.39991"10.4"

This number of significant digits D is then clamped between minPrecision and precision according to the following formula:

D = max(minPrecision, min(precision, D))

In other words: D should be between minPrecision and precision, and minPrecision wins.

Rendering the number

The rendering format is [unit-left][integer][decimal-sep][fraction][suffix][unit-right], where:

Digits in [integer] and [fraction] are combined in groups of three and separated by thousandSeparator.

Examples

NumbernumbersunitunitPositionprecisionminPrecisionfractionSeparatorthousandSeparatorResult
1auto" USD"autoauto0"."" ""1 USD"
0.249percent""autoauto0"."" ""24.9%"
0.249scientific" m"autoauto0","" ""2,49e-1 m"
1999thousands"$"autoauto0"."" ""$2k"
1999simple"$"rightauto2"."",""1,999.00$

Time Value pipeline

When the numbers property is minutes and seconds, a distinct pipeline is used that ignores all the other properties (except units). The rules are:

If provided, the unit is displayed according to unit and unitPosition rules.