Function calculateShowValuesAs

  • „Show values as“ over a list of values in display order – DOM-free, for own area models. Percentages are fractions (0.667); the reference is the list itself (percentOfRowTotal is not applicable to a list: the values are returned unchanged). Values that are no numbers → undefined.

    Parameters

    • values: ArrayLike<unknown>

      the raw values in display order

    • mode: ShowValuesAs

      the mode

    Returns (number | undefined)[]

    the shown values

    Example

    calculateShowValuesAs([2598, 1047, 250], "percentOfColumnTotal");   // [0.667…, 0.268…, 0.064…]
    calculateShowValuesAs([10, 20, 20, 5], "rank"); // [3, 1, 1, 4]
    calculateShowValuesAs([10, 20, 5], "runningTotal"); // [10, 30, 35]
    calculateShowValuesAs([10, 20, 5], "differenceFromPrevious"); // [undefined, 10, -15]

    Since

    1.1.95