@pond-ts/charts API Reference
    Preparing search index...

    Interface ScaleBand

    A d3-scale-shaped ordinal band scale for a categorical x-axis — the transpose view's "columns on x" (categorical-axis RFC, Phase 1). It exposes the slice of the d3 scale surface @pond-ts/charts actually uses, so it drops in wherever the container's xScale goes (the same trick TradingTimeScale uses for a discontinuous time axis).

    Numeric slot-index domain (the load-bearing choice). The domain is [0, n] — one unit slot per category, slot i occupying [i, i+1]not a string[]. So the pixel mapping stays linear and the container's numeric domain / auto-fit / range pipeline is untouched; a bar layer draws each category with the ordinary barSpanPx(i, i+1, …). The category-ness lives in three methods only:

    • ScaleBand.ticks → the band centres (i + 0.5), one per category;
    • ScaleBand.invert → snaps a pixel to the nearest slot's centre (the categorical crosshair UX, and it keeps the +xScale.invert call sites happy);
    • ScaleBand.label → the category name at a slot (the axis formatter).

    The category labels are carried alongside for ScaleBand.label; the numeric domain is authoritative for geometry.

    interface ScaleBand {
        bandwidth(): number;
        copy(): ScaleBand;
        domain(): [number, number];
        domain(next: readonly [number, number]): ScaleBand;
        invert(pixel: number): number;
        label(value: number): string;
        range(): [number, number];
        range(next: readonly [number, number]): ScaleBand;
        step(): number;
        tickFormat(count?: number, specifier?: string): (value: number) => string;
        ticks(count?: number): number[];
        (value: number): number;
    }
    • Slot value (i = left edge, i + 0.5 = centre) → pixel. Linear.

      Parameters

      • value: number

      Returns number

    Index

    Methods

    • One slot's width in pixels (|range| / slots). The bar's gap insets within it.

      Returns number

    • Pixel → the nearest slot's centre value (i + 0.5), clamped to a real slot.

      Parameters

      • pixel: number

      Returns number

    • The category name at slot value v (categories[floor(v)]), or ''.

      Parameters

      • value: number

      Returns string

    • Slot pitch in pixels — same as bandwidth (padding is the bar's gap).

      Returns number

    • A formatter mapping a slot value → the category name (the numeric specifier is ignored — a category axis labels by name, not a number format). Present so the scale is a safe drop-in wherever the container resolves a tickFormat.

      Parameters

      • Optionalcount: number
      • Optionalspecifier: string

      Returns (value: number) => string

    • One tick per category, at its band centre (i + 0.5).

      Parameters

      • Optionalcount: number

      Returns number[]