Represents something that can be measured, often over a period of time (to create a timeseries). Apps will typically use many different metrics stored in a MetricCatalog.

The Metric itself does not contain any data. It only contains the metadata that defines the metric (name, data source, thresholds, etc.). To fetch data, see e.g. fetchData.

Hierarchy

  • Metric

Constructors

Properties

categorySet?: CategorySet

The set of categories used to categorize metric values. Populated from categorySetId.

categorySetId?: string

References a set of categories that this metric should use for grading / categorizing values (e.g. "vaccine-categories"). The available CategorySet definitions are defined when constructing the MetricCatalog via categorySets.

Use with either categoryThresholds or categoryValues.

categoryThresholds?: number[]

Thresholds used for grading the metric. These correspond to the categories specified by categorySetId and there should be one fewer threshold than there are categories.

categoryValues?: unknown[]

A list of discrete metric values to be used for categorizing this metric's values (e.g. value 0 should be categorized as "fail" category, 1 categorized as "pass" category).

dataReference?: MetricDataReference

Specifies how to fetch data for this metric. See MetricDataReference and MetricDataProvider

extendedName: string

A longer name for the metric used when space is not a concern (e.g. "Cases per 100k population")

extra?: Record<string, unknown>

Arbitrary extra metadata related to the metric. This is not used by any bultin

formatOptions: NumberFormatOptions

Specifies options used to format the metric value when it is displayed.

id: string

A unique ID that can be used to reference this metric (e.g. "cases_per_100k").

maxValue?: number

Maximum possible value for the given metric.

minValue?: number

Minimum possible value for the given metric.

name: string

The default user-facing display name of the metric (e.g. "Cases per 100k").

Accessors

Methods

  • Formats the provided value for display purposes, using this metric's formatting logic.

    Returns

    The formatted value.

    Parameters

    • value: unknown

      The value to be formatted.

    • nullValueCopy: string = ""

      Optional copy to be used if the value is null, else an empty string will be used.

    Returns string

  • Looks up the color to use for the specified value either using the defined metric categories or metric thresholds.

    Returns

    Color to use for value.

    Parameters

    • value: unknown

      Value to get color for.

    Returns string

  • Rounds the provided value to the appropriate number of significant digits based on this metric's formatting logic.

    Returns

    Rounded value.

    Parameters

    • value: unknown

      Value to be rounded.

    Returns null | number

Generated using TypeDoc