Function scaleThreshold

  • Constructs a new threshold scale with the specified range. The domain defaults to [0.5]. If range is not specified, it defaults to [0, 1]. Thus, the default threshold scale is equivalent to the Math.round function for numbers; for example threshold(0.49) returns 0, and threshold(0.51) returns 1.

    The first generic corresponds to the data type of domain values. The second generic corresponds to the data type of range values. The third generic corresponds to the data type of the unknown value.

    Type Parameters

    • Domain extends string | number | Date = number

    • Range = number

    • Unknown = never

    Parameters

    • Optional range: Iterable<Range>

      Array of range values.

    Returns ScaleThreshold<Domain, Range, Unknown>

  • Constructs a new threshold scale with the specified domain and range. Thus, the default threshold scale is equivalent to the Math.round function for numbers; for example threshold(0.49) returns 0, and threshold(0.51) returns 1.

    The first generic corresponds to the data type of domain values. The second generic corresponds to the data type of range values. The third generic corresponds to the data type of the unknown value.

    Type Parameters

    • Domain extends string | number | Date

    • Range

    • Unknown = never

    Parameters

    • domain: Iterable<Domain>

      Array of domain values.

    • range: Iterable<Range>

      Array of range values.

    Returns ScaleThreshold<Domain, Range, Unknown>