Interface ScalePoint<Domain>

Point scales are a variant of band scales with the bandwidth fixed to zero. Point scales are typically used for scatterplots with an ordinal or categorical dimension. The unknown value of a point scale is always undefined: they do not allow implicit domain construction.

The generic corresponds to the data type of domain elements.

interface ScalePoint {
    align(): number;
    align(align): ScalePoint<Domain>;
    bandwidth(): number;
    copy(): ScalePoint<Domain>;
    domain(): Domain[];
    domain(domain): ScalePoint<Domain>;
    padding(): number;
    padding(padding): ScalePoint<Domain>;
    range(): [number, number];
    range(range): ScalePoint<Domain>;
    rangeRound(range): ScalePoint<Domain>;
    round(): boolean;
    round(round): ScalePoint<Domain>;
    step(): number;
    (x): number;
}

Type Parameters

  • Domain extends {
        toString(): string;
    }

  • Given a value in the input domain, returns the corresponding point derived from the output range. If the given value is not in the scale’s domain, returns undefined.

    Parameters

    • x: Domain

      A value from the domain.

    Returns number

Methods

  • Returns the current alignment which defaults to 0.5.

    Returns number

  • Sets the alignment to the specified value which must be in the range [0, 1].

    The alignment determines how any leftover unused space in the range is distributed. A value of 0.5 indicates that the leftover space should be equally distributed before the first point and after the last point; i.e., the points should be centered within the range. A value of 0 or 1 may be used to shift the points to one side, say to position them adjacent to an axis.

    The default value is 0.5.

    Parameters

    • align: number

      Value for alignment setting in [0, 1] interval.

    Returns ScalePoint<Domain>

  • Return 0.

    Returns number

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

    Returns ScalePoint<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 point, the second domain value to the second point, and so on. Domain values are stored internally in an InternMap from primitive value to index; the resulting index is then used to determine the point. Thus, a point scale’s values must be coercible to a primitive value, and the primitive domain value uniquely identifies the corresponding point.

    Parameters

    • domain: Iterable<Domain>

      Array of domain values.

    Returns ScalePoint<Domain>

  • Returns the current outer padding which defaults to 0. The outer padding determines the ratio of the range that is reserved for blank space before the first point and after the last point.

    Returns number

  • Sets the outer padding to the specified value which must be in the range [0, 1]. The outer padding determines the ratio of the range that is reserved for blank space before the first point and after the last point.

    The default is 0.

    Parameters

    • padding: number

      Value for outer padding in [0, 1] interval.

    Returns ScalePoint<Domain>

  • Returns the scale’s current range, which defaults to [0, 1].

    Returns [number, number]

  • Sets the scale’s range to the specified two-element array of numbers. If the elements in the given array are not numbers, they will be coerced to numbers. The default range is [0, 1].

    Parameters

    • range: Iterable<NumberValue>

      A two-element array of numeric values.

    Returns ScalePoint<Domain>

  • Sets the scale’s range to the specified two-element array of numbers while also enabling rounding. If the elements in the given array are not numbers, they will be coerced to numbers.

    Rounding is sometimes useful for avoiding antialiasing artifacts, though also consider the shape-rendering “crispEdges” styles.

    Parameters

    • range: Iterable<NumberValue>

      A two-element array of numeric values.

    Returns ScalePoint<Domain>

  • Returns the current rounding status for the scale: enabled (= true) or disabled (= false).

    Returns boolean

  • Enables or disables rounding accordingly. If rounding is enabled, the position of each point will be integers. Rounding is sometimes useful for avoiding antialiasing artifacts, though also consider the shape-rendering “crispEdges” styles. Note that if the width of the domain is not a multiple of the cardinality of the range, there may be leftover unused space, even without padding! Use point.align to specify how the leftover space is distributed.

    Parameters

    • round: boolean

      Enable rounding (= true), disable rounding (= false).

    Returns ScalePoint<Domain>

  • Returns the distance between the starts of adjacent points.

    Returns number