Functional Weave
Code in Python

charts.scale@1.1.0

impl/python/point_scale.py

563 bytes · the Python implementation · view raw

Imports name this capability’s declared dependencies, which fune builds next to it in your project; each one links to its page.

from typing import Sequence

from .charts_scale_band_scale import band_position, check_align, check_outer  ← bandScale, another function of this group · built into the same file, even by a slim install
from .math_round_float import round_float  ← from math.round-float ^1.0.0 · built alongside by fune


def point_scale(domain: Sequence[str], range: Sequence[float], value: str, padding: float, align: float) -> float:
    """The position of a category on an axis of evenly spaced points, as
    d3.scalePoint: a band scale with inner padding 1, so bands have no width."""
    check_outer(padding, "padding")
    check_align(align)
    return round_float(band_position(domain, range, value, 1, padding, align)[0], 6)