WebCola
Options
All
  • Public
  • Public/Protected
  • All
Menu

Unlike continuous scales, ordinal scales have a discrete domain and range. For example, an ordinal scale might map a set of named categories to a set of colors, or determine the horizontal positions of columns in a column chart.

The first element in the domain will be mapped to the first element in range, the second domain value to the second range value, and so on. If there are fewer elements in the range than in the domain, the scale will reuse values from the start of the range.

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

Type parameters

  • Domain: object

  • Range

Hierarchy

  • ScaleOrdinal

Callable

  • __call(x: Domain): Range
  • Given a value in the input domain, returns the corresponding value in the output range. If the given value is not in the scale’s domain, returns the unknown; or, if the unknown value is implicit (the default), then the value is implicitly added to the domain and the next-available value in the range is assigned to value, such that this and subsequent invocations of the scale given the same input value return the same output value.

    The first element in the domain will be mapped to the first element in range, the second domain value to the second range value, and so on. If there are fewer elements in the range than in the domain, the scale will reuse values from the start of the range.

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

    Parameters

    • x: Domain

      A value from the domain.

    Returns Range

Index

Methods

copy

  • copy()
  • Returns an exact copy of this ordinal scale. Changes to this scale will not affect the returned scale, and vice versa.

domain

  • domain(): Domain[]
  • domain(domain: Domain[])
  • Returns the scale's current domain.

    Returns Domain[]

  • Sets the domain to the specified array of values.

    The first element in domain will be mapped to the first element in the range, the second domain value to the second range value, and so on.

    Domain values are stored internally in a map from stringified value to index; the resulting index is then used to retrieve a value from the range. Thus, an ordinal scale’s values must be coercible to a string, and the stringified version of the domain value uniquely identifies the corresponding range value.

    Setting the domain on an ordinal scale is optional if the unknown value is implicit (the default). In this case, the domain will be inferred implicitly from usage by assigning each unique value passed to the scale a new value from the range. Note that an explicit domain is recommended to ensure deterministic behavior, as inferring the domain from usage will be dependent on ordering.

    Parameters

    • domain: Domain[]

      Array of domain values.

range

  • range(): Range[]
  • range(range: Range[])
  • Returns the scale's current range.

    Returns Range[]

  • Sets the range of the ordinal scale to the specified array of values.

    The first element in the domain will be mapped to the first element in range, the second domain value to the second range value, and so on.

    If there are fewer elements in the range than in the domain, the scale will reuse values from the start of the range.

    Parameters

    • range: Range[]

      Array of range values.

unknown

  • unknown(): Range | object
  • unknown(value: Range | object)
  • Returns the current unknown value, which defaults to "implicit".

    Returns Range | object

  • Sets the output value of the scale for unknown input values and returns this scale. The implicit value enables implicit domain construction. scaleImplicit can be used as a convenience to set the implicit value.

    Parameters

    • value: Range | object

      Unknown value to be used or scaleImplicit to set implicit scale generation.

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc