Symlog and point scales
Import from @pibbl/core/viz. Each family has its own provider and hook with a
fixed return type. There is no family selector or argument-dependent return.
SymlogScale
Section titled “SymlogScale”SymlogScale(props: SymlogScaleProps): PibblNode accepts all LinearScaleProps
and constant?: SignalValue<number> (default 1). id, domain, and range are
required. reverse defaults to false; style and children are optional.
The domain is two distinct finite numbers with a finite nonzero span; negative,
zero, positive, and descending endpoints are supported. Range is "width",
"height", or two finite coordinates. Reversal affects range only.
useSymlogScale(id: ScaleId): Signal<ResolvedSymlogScale> returns a stable shared
readonly signal. Its frozen snapshot has type: "symlog", frozen domain and
range, frame, constant, and:
map(value: number): number: appliessign(value) * log1p(abs(value)/constant)before linear interpolation. Near zero it is approximately linear; farther away it compresses large magnitudes. Finite values outside the domain extrapolate.invert(pixel: number): number: applies the inverse signedexpm1transform. Original range endpoints return exact domain endpoints. Negative zero becomes zero.ticks(count = 5): readonly number[]: readable 1/2/5 decimal ticks in data space, usinglinearTicks(domain, { count }). Count is a target, not exact; at most 100 values are returned. Count must be an integer 2–100. Aligned zero appears when the domain crosses zero. Endpoints appear only if aligned.
constant must be finite and positive, in the same units as the data. Changing
it changes geometry; it is not only a formatting choice. No automatic nicening
or clamping occurs. All provider inputs except identity/children accept the same
signals as LinearScale. Changes to constant publish new snapshots. Hook .get()
tracks dependencies; provider unmount releases its subscriptions.
Invalid domains, ranges, constants, nonfinite map/invert inputs or outputs,
collapsed transformed domains, and collapsed-range inversion throw RangeError.
A collapsed range can still map. Tick precision limits match linearTicks.
Missing/mismatched hook IDs and invalid reverse/identity follow existing scale
errors. Existing numeric axes, marks, ScaleAdjust, and inspection queries work
with symlog, including signed coordinates and zero.
PointScale
Section titled “PointScale”PointScale(props: PointScaleProps): PibblNode requires id, domain, and
range. Domain is an ordered array of unique strings or finite numbers; numeric
1 and string "1" differ, while 0 and -0 are duplicates. Empty and singleton
domains are valid. Range, reverse (default false), style, and children have the
same meaning as LinearScale. padding?: SignalValue<number> defaults to zero;
it is nonnegative outer spacing in step units, not pixels. Zero padding places
first and last categories at the range endpoints. Categories never sort themselves;
reverse the domain array to change order, or reverse the range to flip mapping.
usePointScale(id: ScaleId): Signal<ResolvedPointScale> returns a stable shared
readonly signal. Snapshot fields: type: "point", frozen domain and range,
frame, resolved padding, and nonnegative step. There is no bandwidth.
map(category: BandCategory): number | undefined: the category’s point, or undefined for an unknown category. No domain mutation occurs.invert(pixel: number): BandCategory | undefined: nearest-category lookup, not a continuous inverse. Ties choose the first category in domain order; outside coordinates choose the nearest endpoint. Empty domains return undefined. Singleton or collapsed ranges choose the first category.ticks(count = 5): BandDomain: at most count categories, sampled in domain order. Count is an integer 0–100; zero returns an empty frozen array, one returns the first category. Counts of two or more retain endpoints.
Empty domains have step zero; singleton categories map to the range midpoint.
Collapsed ranges place all categories at that pixel. Padding arithmetic must
remain finite. Invalid/duplicate categories throw TypeError; invalid padding,
range/allocation, invert coordinate, or count throws RangeError. No implicit
category coercion occurs. Domain, range, reverse, padding, and styles accept
signals; snapshots update with allocation, and unmount releases subscriptions.
Axis ticks use the exact point (no half-band offset). ScaleAdjust accepts
string/number point coordinates for ordinary custom marks; unknown categories
throw RangeError. Its continuous coordinates still require numbers. Numeric
LineSeries, PointSeries, PlotSeries, and numeric inspection queries do not
accept PointScale: use the hook for custom mark coordinates and invert for
category inspection. This preserves their numeric contracts.
Minimal runnable composition
Section titled “Minimal runnable composition”The signed Census example is editable and uses both providers and hooks with real data. This minimal mount also demonstrates both families and categorical custom-mark placement:
import { Circle, Group, pibbl } from "@pibbl/core";import { Axis, PointScale, SymlogScale, ScaleAdjust } from "@pibbl/core/viz";export default function mount(canvas: HTMLCanvasElement) { return pibbl( canvas, <Group style={{ translateX: 60, translateY: 30 }}> <PointScale id="state" domain={["A", "B", "C"]} range={[0, 120]}> <SymlogScale id="change" domain={[-100, 100]} range={[0, 240]} constant={10} > <Axis scale="state" position="left" tickValues={["A", "B", "C"]} /> <Axis scale="change" position="top" /> <ScaleAdjust x={-30} xScale="change" y="B" yScale="state"> <Circle style={{ radius: 5, fill: "teal" }} /> </ScaleAdjust> </SymlogScale> </PointScale> </Group>, );}Keep category identities visible when resizing. Units and the symlog transition constant belong in chart context because equal distances do not represent equal additive changes.
Scale snapshots are computed lazily. Domain/mapping validation occurs when a
consumer reads the scale signal (for example, an Axis or a hook’s .get()),
not merely because an otherwise unused provider appears in the tree.
API details from source
Section titled “API details from source”
SymlogScale
Section titled “SymlogScale”Provides a named symlog mapping to descendant visualization components.
SymlogScale: (props: SymlogScaleProps) => PibblNodeRelated API: SymlogScale, SymlogScaleProps, PibblNode.
Parameters
Section titled “Parameters”props— Identity, domain, range, and constant. See SymlogScaleProps.
Returns
Section titled “Returns”Descendant content within the scale scope.
View source — packages/core/src/features/viz/lib/symlog-scale-component.ts:10
useSymlogScale
Section titled “useSymlogScale”Reads an ancestor symlog scale as a stable shared readonly signal.
useSymlogScale: (id: ScaleId) => Signal<ResolvedSymlogScale>Related API: useSymlogScale, ScaleId, Signal, ResolvedSymlogScale.
Parameters
Section titled “Parameters”id— Ancestor scale identity. See ScaleId.
Returns
Section titled “Returns”The reactive mapping. See ResolvedSymlogScale.
View source — packages/core/src/features/viz/lib/use-symlog-scale.ts:10
SymlogScaleProps
Section titled “SymlogScaleProps”Signed logarithmic scale inputs. See LinearScaleProps.
interface SymlogScaleProps extends LinearScalePropsRelated API: SymlogScaleProps, LinearScaleProps.
View source — packages/core/src/features/viz/lib/types.ts:259
Properties and methods
Section titled “Properties and methods”
constant (optional)
readonly constant?: SignalValue<number> | undefinedRelated API: SignalValue.
Positive linear-to-log transition constant in domain units, default 1.
View source — packages/core/src/features/viz/lib/types.ts:261
id
readonly id: ScaleIdRelated API: ScaleId.
Stable identifier of this resource or connection. See ScaleId.
View source — packages/core/src/features/viz/lib/types.ts:75
domain
readonly domain: SignalValue<LinearDomain>Related API: SignalValue, LinearDomain.
Data values or endpoints accepted by the scale. See SignalValue, LinearDomain .
View source — packages/core/src/features/viz/lib/types.ts:80
range
readonly range: SignalValue<ScaleRange>Related API: SignalValue, ScaleRange.
Logical output coordinates produced by the scale. See SignalValue, ScaleRange .
View source — packages/core/src/features/viz/lib/types.ts:85
reverse (optional)
readonly reverse?: SignalValue<boolean> | undefinedRelated API: SignalValue.
Whether to reverse the direction of the mapping or guide. See SignalValue.
View source — packages/core/src/features/viz/lib/types.ts:87
style (optional)
Full type declaration
readonly style?: SignalValue<Readonly<{ left?: SignalValue<number | `${number}%` | undefined>; top?: SignalValue<number | `${number}%` | undefined>; width?: SignalValue<Length | undefined>; height?: SignalValue<Length | undefined>; alignSelf?: SignalValue<"auto" | "center" | "end" | "flex-end" | "flex-start" | "start" | "stretch" | undefined>; justifySelf?: SignalValue<"auto" | "center" | "end" | "start" | "stretch" | undefined>; flexBasis?: SignalValue<Length | undefined>; flexGrow?: SignalValue<number | undefined>; flexShrink?: SignalValue<number | undefined>; gridColumnStart?: SignalValue<number | undefined>; gridColumnSpan?: SignalValue<number | undefined>; gridRowStart?: SignalValue<number | undefined>; gridRowSpan?: SignalValue<number | undefined>; transition?: SignalValue<PibblTransitionBinding | undefined>; custom?: unknown; filter?: SignalValue<PibblFilter | readonly PibblFilter[] | undefined>; }>> | undefinedRelated API: SignalValue, Length, PibblTransitionBinding, PibblFilter.
Declared presentation and layout properties. See SignalValue, SignalStyle, ScaleLayoutStyle.
View source — packages/core/src/features/viz/lib/types.ts:92
children (optional)
readonly children?: PibblNodeRelated API: PibblNode.
Descendant content or the callback that supplies it. See PibblNode.
View source — packages/core/src/features/viz/lib/types.ts:94
ResolvedSymlogScale
Section titled “ResolvedSymlogScale”Signed logarithmic mapping through zero. See ResolvedLinearScale.
interface ResolvedSymlogScale extends Omit<ResolvedLinearScale, "type">Related API: ResolvedSymlogScale, ResolvedLinearScale.
View source — packages/core/src/features/viz/lib/types.ts:264
Properties and methods
Section titled “Properties and methods”
type
readonly type: "symlog"Signed logarithmic discriminant. See SymlogScaleProps.
View source — packages/core/src/features/viz/lib/types.ts:266
constant
readonly constant: numberPositive transition constant. See SymlogScaleProps.
View source — packages/core/src/features/viz/lib/types.ts:268
domain
readonly domain: LinearDomainRelated API: LinearDomain.
Data values or endpoints accepted by the scale. See LinearDomain.
View source — packages/core/src/features/viz/lib/types.ts:193
range
readonly range: readonly [number, number]Logical output coordinates produced by the scale. See ResolvedLinearScale.
View source — packages/core/src/features/viz/lib/types.ts:195
frame
readonly frame: Readonly<LayoutBox>Related API: LayoutBox.
Resolved layout frame containing the scale. See LayoutBox.
View source — packages/core/src/features/viz/lib/types.ts:197
map
map: (value: number) => numberMaps a numeric domain value to a logical range coordinate. See ResolvedLinearScale.
Parameters
Section titled “Parameters”value— Numeric domain coordinate.
Returns
Section titled “Returns”The corresponding range coordinate.
View source — packages/core/src/features/viz/lib/types.ts:203
invert
invert: (pixel: number) => numberRelated API: invert.
Maps a logical range coordinate back into the numeric domain. See ResolvedLinearScale .
Parameters
Section titled “Parameters”pixel— Coordinate in the scale’s pixel range.
Returns
Section titled “Returns”The corresponding numeric domain value.
View source — packages/core/src/features/viz/lib/types.ts:210
ticks
ticks: (count?: number) => readonly number[]Returns representative numeric tick values for the requested count. See ResolvedLinearScale.
Parameters
Section titled “Parameters”count— Suggested number of ticks.
Returns
Section titled “Returns”Tick values in domain coordinates.
View source — packages/core/src/features/viz/lib/types.ts:217
PointScale
Section titled “PointScale”Provides a named point mapping to descendant visualization components.
PointScale: (props: PointScaleProps) => PibblNodeRelated API: PointScale, PointScaleProps, PibblNode.
Parameters
Section titled “Parameters”props— Identity, domain, range, and padding. See PointScaleProps.
Returns
Section titled “Returns”Descendant content within the scale scope.
View source — packages/core/src/features/viz/lib/point-scale-component.ts:10
usePointScale
Section titled “usePointScale”Reads an ancestor point scale as a stable shared readonly signal.
usePointScale: (id: ScaleId) => Signal<ResolvedPointScale>Related API: usePointScale, ScaleId, Signal, ResolvedPointScale.
Parameters
Section titled “Parameters”id— Ancestor scale identity. See ScaleId.
Returns
Section titled “Returns”The reactive mapping. See ResolvedPointScale.
View source — packages/core/src/features/viz/lib/use-point-scale.ts:10
PointScaleProps
Section titled “PointScaleProps”Equally spaced categorical positions. See LinearScaleProps.
interface PointScaleProps extends Omit<LinearScaleProps, "domain">Related API: PointScaleProps, LinearScaleProps.
View source — packages/core/src/features/viz/lib/types.ts:271
Properties and methods
Section titled “Properties and methods”
domain
readonly domain: SignalValue<BandDomain>Related API: SignalValue, BandDomain.
Ordered unique string or finite numeric categories; accepts signals. See BandDomain.
View source — packages/core/src/features/viz/lib/types.ts:273
padding (optional)
readonly padding?: SignalValue<number> | undefinedRelated API: SignalValue.
Nonnegative outer padding in step units, default 0.
View source — packages/core/src/features/viz/lib/types.ts:275
id
readonly id: ScaleIdRelated API: ScaleId.
Stable identifier of this resource or connection. See ScaleId.
View source — packages/core/src/features/viz/lib/types.ts:75
range
readonly range: SignalValue<ScaleRange>Related API: SignalValue, ScaleRange.
Logical output coordinates produced by the scale. See SignalValue, ScaleRange .
View source — packages/core/src/features/viz/lib/types.ts:85
reverse (optional)
readonly reverse?: SignalValue<boolean> | undefinedRelated API: SignalValue.
Whether to reverse the direction of the mapping or guide. See SignalValue.
View source — packages/core/src/features/viz/lib/types.ts:87
style (optional)
Full type declaration
readonly style?: SignalValue<Readonly<{ left?: SignalValue<number | `${number}%` | undefined>; top?: SignalValue<number | `${number}%` | undefined>; width?: SignalValue<Length | undefined>; height?: SignalValue<Length | undefined>; alignSelf?: SignalValue<"auto" | "center" | "end" | "flex-end" | "flex-start" | "start" | "stretch" | undefined>; justifySelf?: SignalValue<"auto" | "center" | "end" | "start" | "stretch" | undefined>; flexBasis?: SignalValue<Length | undefined>; flexGrow?: SignalValue<number | undefined>; flexShrink?: SignalValue<number | undefined>; gridColumnStart?: SignalValue<number | undefined>; gridColumnSpan?: SignalValue<number | undefined>; gridRowStart?: SignalValue<number | undefined>; gridRowSpan?: SignalValue<number | undefined>; transition?: SignalValue<PibblTransitionBinding | undefined>; custom?: unknown; filter?: SignalValue<PibblFilter | readonly PibblFilter[] | undefined>; }>> | undefinedRelated API: SignalValue, Length, PibblTransitionBinding, PibblFilter.
Declared presentation and layout properties. See SignalValue, SignalStyle, ScaleLayoutStyle.
View source — packages/core/src/features/viz/lib/types.ts:92
children (optional)
readonly children?: PibblNodeRelated API: PibblNode.
Descendant content or the callback that supplies it. See PibblNode.
View source — packages/core/src/features/viz/lib/types.ts:94
ResolvedPointScale
Section titled “ResolvedPointScale”Zero-width categorical point positions. See ResolvedBandScale.
interface ResolvedPointScale extends Omit< ResolvedBandScale, "type" | "bandwidth">Related API: ResolvedPointScale, ResolvedBandScale.
View source — packages/core/src/features/viz/lib/types.ts:278
Properties and methods
Section titled “Properties and methods”
type
readonly type: "point"Categorical point discriminant. See PointScaleProps.
View source — packages/core/src/features/viz/lib/types.ts:283
padding
readonly padding: numberResolved outer padding. See PointScaleProps.
View source — packages/core/src/features/viz/lib/types.ts:285
invert
invert: (pixel: number) => BandCategory | undefinedRelated API: invert, BandCategory.
Finds the nearest category, clamping outside coordinates; ties choose first domain order.
Parameters
Section titled “Parameters”pixel— Finite range coordinate.
Returns
Section titled “Returns”Category or undefined for an empty domain. See BandCategory.
View source — packages/core/src/features/viz/lib/types.ts:291
ticks
ticks: (count?: number) => BandDomainRelated API: BandDomain.
Selects evenly spaced categories including endpoints when count permits.
Parameters
Section titled “Parameters”count— Integer maximum count 0–100, default 5.
Returns
Section titled “Returns”Frozen categories in domain order. See BandDomain.
View source — packages/core/src/features/viz/lib/types.ts:297
domain
readonly domain: BandDomainRelated API: BandDomain.
Data values or endpoints accepted by the scale. See BandDomain.
View source — packages/core/src/features/viz/lib/types.ts:164
range
readonly range: readonly [number, number]Logical output coordinates produced by the scale. See ResolvedBandScale.
View source — packages/core/src/features/viz/lib/types.ts:166
frame
readonly frame: Readonly<LayoutBox>Related API: LayoutBox.
Resolved layout frame containing the scale. See LayoutBox.
View source — packages/core/src/features/viz/lib/types.ts:168
step
readonly step: numberDistance between successive band starts. See ResolvedBandScale.
View source — packages/core/src/features/viz/lib/types.ts:172
map
map: (value: BandCategory) => number | undefinedRelated API: BandCategory.
Maps a category to its band coordinate, or returns undefined for an unknown category. See ResolvedBandScale .
Parameters
Section titled “Parameters”value— Category to locate in the domain. See BandCategory.
Returns
Section titled “Returns”The category’s range position, or undefined if it is absent from the domain.
View source — packages/core/src/features/viz/lib/types.ts:179
Implementation guidance for agents
Section titled “Implementation guidance for agents”Read the Data visualization companion for ownership, adaptation, failure modes, and verification. Agent start provides the version-selection workflow.
Complete minimal examples
Section titled “Complete minimal examples”- Daily inventory changes: Negative means shipped; positive means received. Plain source
- Checkpoints in a review: Categories have equal spacing, not numeric distance. Plain source
Documentation version
Section titled “Documentation version”Documentation built with @pibbl/core 0.0.2, revision 2dccb19. ALPHA — NOT FOR PRODUCTION USE.