Units
Class in @bimworks/viewercommon.
API catalogue · @bimworks/viewercommon · Class
Formats values with their units as the BIM.works UI shows them
Members#
| Member | Kind | Description |
|---|---|---|
| constructor | Method | |
| convertUnit | Method | The display postfix of a unit ("m²" for SQUARE_METRE); unknown units are returned as they are |
| itemToString | Method | A value of any kind (number, string, value with unit, list) as text |
| toString | Method | The value with its unit, "[No value]" for null |
| valueToString | Method | A feature's value with its unit or symbol (as a BVL label carries it) as text: a yes/no as "true" or "false", a number in a unit with its decimals and postfi… |
constructor#
TypeScript#
constructor()convertUnit#
TypeScript#
static convertUnit(unit: string): stringThe display postfix of a unit ("m²" for SQUARE_METRE); unknown units are returned as they are
Parameters#
| Name | Type | Description |
|---|---|---|
unit |
string |
itemToString#
TypeScript#
static itemToString(item: unknown): stringA value of any kind (number, string, value with unit, list) as text
Parameters#
| Name | Type | Description |
|---|---|---|
item |
unknown |
toString#
TypeScript#
static toString(value: string | number | null | undefined, unit?: string): stringThe value with its unit, "[No value]" for null
Parameters#
| Name | Type | Description |
|---|---|---|
value |
string | number | null | undefined |
|
unit |
string |
valueToString#
TypeScript#
static valueToString(value: string | number | boolean | null | undefined, unit?: string | null, symbol?: string | null): stringA feature's value with its unit or symbol (as a BVL label carries it) as text: a yes/no as "true" or "false", a number in a unit with its decimals and postfix, a number without one (or UNITLESS) with two decimals at most, "" for null
Parameters#
| Name | Type | Description |
|---|---|---|
value |
string | number | boolean | null | undefined |
|
unit |
string | null |
|
symbol |
string | null |