Scale providers
Import LinearScale, BarScale, UTCScale, and their types from @pibbl/core/viz. Use the core JSX runtime.
Each provider requires id, domain, and range, with optional reverse,
style, and children. BarScale also accepts paddingInner and paddingOuter.
There is no type prop. The corresponding props are LinearScaleProps,
BarScaleProps, and UTCScaleProps (see UTC domains).
ScaleId is a nonempty string or symbol. Nested providers shadow the nearest
matching ID; siblings and independent roots cannot see each other’s providers.
LinearDomain contains two finite, unequal numbers, ascending or descending.
ScaleRange is a finite numeric pair, "width", or "height". Allocation ranges
start at zero and end at the local allocated extent. reverse swaps endpoints;
use it with height to make larger values appear higher. Domain, range, and reverse
accept core SignalValue inputs. Signal resolution is shallow.
ScaleLayoutStyle contains width, height, and core layout-item styles. Whole
styles and direct fields may be core signals. Scale does not paint, transform,
reserve gutters, or create a global chart rectangle. Its children receive the
same allocation; put gutters and placement in ordinary core layout.
ResolvedScale is ResolvedContinuousScale | ResolvedBandScale. The linear snapshot has:
type,domain, andrangedescribe the mapping.framehas local x/y zero and the allocation’s width/height.map(value)maps finite values with linear extrapolation, without clamping.invert(pixel)reverses that mapping. A zero-span range maps to its endpoint but cannot be inverted.ticks(count = 5)returns evenly spaced values including both domain ends. Count must be an integer from 2 through 100. These are not calendar or nice ticks.
Use useLinearScale to read the scale signal. Definitions are
lazy; malformed resolved inputs throw on evaluation. Nonfinite arithmetic results
also throw. Updating a signal or allocation refreshes the existing scale signal;
equivalent domain/range/frame values suppress downstream invalidation.
A scale provider and consumer must share one rendering instance. Put the complete
scale subtree inside a Layer; lookup across a Layer boundary is unsupported.
UTC calendar scales are available; see UTC domains.
Local time, logarithmic, and auto-domain scales remain deferred.
Band scales
Section titled “Band scales”Use BarScale with an explicit ordered BandDomain of strings or finite
numbers (BandCategory). Identity uses SameValueZero: 1 and "1" are distinct;
-0 and 0 are the same category. Duplicate entries reject. Input order is
preserved, and empty domains are valid. Unknown categories map to undefined.
paddingInner defaults to 0 and is a fraction of the step in [0, 1].
paddingOuter defaults to 0 and is a finite nonnegative number of steps per side.
For n categories, step = extent / max(1, n - paddingInner + 2 * paddingOuter).
Bandwidth = step * (1 - paddingInner); remaining space is centered. Empty domains
have zero step/bandwidth. Collapsed ranges have zero bandwidth. Reverse changes
category placement, while each map(category) remains the lower pixel edge.
Read useBarScale(id).get() for the immutable ResolvedBandScale: domain,
range, frame, step, bandwidth, and map(category). There is no numeric
inversion or tick method. Labels can use map(category) + bandwidth / 2.
Domain, padding, reverse, and range accept signals and follow local allocation.
For nested bands, BandScaleRange additionally accepts
{ bandwidthOf: ancestorId }. It resolves to [0, ancestor.bandwidth],
reacting to ancestor domain, padding, and allocation changes. The reference
must identify a visible ancestor band scale in the same rendering instance.
Nearest matching scope wins, as with useLinearScale. Missing references and wrong
scale families reject. Ancestor-only lookup prevents circular references.
Zero ancestor bandwidth produces a collapsed range. The inner frame remains
the layout allocation; only its range uses the ancestor bandwidth. Linear
scales do not accept this range form.
API details from source
Section titled “API details from source”
LinearScale
Section titled “LinearScale”Provides a named linear mapping to descendant visualization components.
LinearScale: (props: LinearScaleProps) => PibblNodeRelated API: LinearScale, LinearScaleProps, PibblNode.
Parameters
Section titled “Parameters”props— Identity, domain, range, and children. See LinearScaleProps.
Returns
Section titled “Returns”Descendant content within the scale scope.
View source — packages/core/src/features/viz/lib/linear-scale-component.ts:10
BarScale
Section titled “BarScale”Provides categorical bands, including nested groups sized to a parent band.
BarScale: (props: BarScaleProps) => PibblNodeRelated API: BarScale, BarScaleProps, PibblNode.
Parameters
Section titled “Parameters”props— Categories, spacing, range, and children. See BarScaleProps.
Returns
Section titled “Returns”Descendant content within the scale scope.
View source — packages/core/src/features/viz/lib/bar-scale.ts:11
UTCScale
Section titled “UTCScale”Provides a named utc mapping to descendant visualization components.
UTCScale: (props: UTCScaleProps) => PibblNodeRelated API: UTCScale, UTCScaleProps, PibblNode.
Parameters
Section titled “Parameters”props— Identity, domain, range, and children. See UTCScaleProps.
Returns
Section titled “Returns”Descendant content within the scale scope.
View source — packages/core/src/features/viz/lib/utc-scale-component.ts:10
ScaleId
Section titled “ScaleId”A string or symbol identifying a scale within visualization context.
type ScaleId = string | symbolRelated API: ScaleId.
See also
Section titled “See also”View source — packages/core/src/features/viz/lib/types.ts:23
LinearDomain
Section titled “LinearDomain”The two numeric endpoints of a continuous scale domain.
type LinearDomain = readonly [number, number]Related API: LinearDomain.
See also
Section titled “See also”View source — packages/core/src/features/viz/lib/types.ts:30
BandCategory
Section titled “BandCategory”A string or number used as a discrete band-scale category.
type BandCategory = string | numberRelated API: BandCategory.
See also
Section titled “See also”View source — packages/core/src/features/viz/lib/types.ts:102
BandDomain
Section titled “BandDomain”The ordered categories allocated by a band scale.
type BandDomain = readonly BandCategory[]Related API: BandDomain, BandCategory.
See also
Section titled “See also”View source — packages/core/src/features/viz/lib/types.ts:110
BarScaleProps
Section titled “BarScaleProps”Authored inputs for BandScale, including the declared data and presentation options.
interface BarScaleProps extends Omit< LinearScaleProps, "domain" | "range">Related API: BarScaleProps, LinearScaleProps.
See also
Section titled “See also”View source — packages/core/src/features/viz/lib/types.ts:120
Properties and methods
Section titled “Properties and methods”
domain
readonly domain: SignalValue<BandDomain>Related API: SignalValue, BandDomain.
Data values or endpoints accepted by the scale. See SignalValue, BandDomain.
View source — packages/core/src/features/viz/lib/types.ts:127
range
readonly range: SignalValue<BandScaleRange>Related API: SignalValue, BandScaleRange.
Logical output coordinates produced by the scale. See SignalValue, BandScaleRange.
View source — packages/core/src/features/viz/lib/types.ts:132
paddingInner (optional)
readonly paddingInner?: SignalValue<number> | undefinedRelated API: SignalValue.
Relative spacing between adjacent categorical bands. See SignalValue.
View source — packages/core/src/features/viz/lib/types.ts:134
paddingOuter (optional)
readonly paddingOuter?: SignalValue<number> | undefinedRelated API: SignalValue.
Relative spacing outside the first and last categorical bands. See SignalValue.
View source — packages/core/src/features/viz/lib/types.ts:136
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:74
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:86
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:91
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:93
BandScaleRange
Section titled “BandScaleRange”A logical range or the bandwidth of another scale for nested band layouts.
type BandScaleRange = | ScaleRange | { /** Identifier of a parent band scale whose bandwidth supplies this range. See {@link ScaleId}. */ readonly bandwidthOf: ScaleId; }Related API: BandScaleRange, ScaleRange, ScaleId.
See also
Section titled “See also”View source — packages/core/src/features/viz/lib/types.ts:45
ResolvedBandScale
Section titled “ResolvedBandScale”A resolved categorical mapping with its frame, bandwidth, and step.
interface ResolvedBandScaleRelated API: ResolvedBandScale.
See also
Section titled “See also”View source — packages/core/src/features/viz/lib/types.ts:159
Properties and methods
Section titled “Properties and methods”
type
readonly type: "band"The literal “band” identifying this variant. See ResolvedBandScale.
View source — packages/core/src/features/viz/lib/types.ts:161
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:163
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:165
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:167
bandwidth
readonly bandwidth: numberWidth allocated to one categorical band. See ResolvedBandScale.
View source — packages/core/src/features/viz/lib/types.ts:169
step
readonly step: numberDistance between successive band starts. See ResolvedBandScale.
View source — packages/core/src/features/viz/lib/types.ts:171
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:178
ScaleRange
Section titled “ScaleRange”An explicit numeric range or a range derived from layout width or height.
type ScaleRange = "width" | "height" | readonly [number, number]Related API: ScaleRange.
See also
Section titled “See also”View source — packages/core/src/features/viz/lib/types.ts:37
ScaleLayoutStyle
Section titled “ScaleLayoutStyle”Sizing and parent-layout participation of a scale’s coordinate frame.
type ScaleLayoutStyle = Pick<BoxStyle, "width" | "height"> & LayoutItemStyleRelated API: ScaleLayoutStyle, BoxStyle, LayoutItemStyle.
See also
Section titled “See also”View source — packages/core/src/features/viz/lib/types.ts:58
Properties and methods
Section titled “Properties and methods”
width (optional)
width?: Length | undefinedRelated API: Length.
Horizontal extent in the units of the containing geometry or surface. See Length.
height (optional)
height?: Length | undefinedRelated API: Length.
Vertical extent in the units of the containing geometry or surface. See Length.
left (optional)
left?: number | `${number}%` | undefinedLeft edge coordinate or inset. See Length.
View source — packages/core/src/lib/style/positioning.ts:127
top (optional)
top?: number | `${number}%` | undefinedTop edge value or top envelope guide. See Length.
View source — packages/core/src/lib/style/positioning.ts:129
alignSelf (optional)
alignSelf?: "auto" | "center" | "end" | "flex-end" | "flex-start" | "start" | "stretch" | undefinedThis child’s cross-axis or block-axis alignment override. See LayoutItemStyle.
justifySelf (optional)
justifySelf?: "auto" | "center" | "end" | "start" | "stretch" | undefinedThis child’s inline-axis alignment override. See LayoutItemStyle.
flexBasis (optional)
flexBasis?: Length | undefinedRelated API: Length.
Initial main-axis size before flex growth or shrinkage. See Length.
flexGrow (optional)
flexGrow?: number | undefinedRelative share of positive free space assigned to this child. See LayoutItemStyle.
flexShrink (optional)
flexShrink?: number | undefinedRelative factor used when reducing main-axis size. See LayoutItemStyle.
gridColumnStart (optional)
gridColumnStart?: number | undefinedExplicit starting grid column. See LayoutItemStyle.
gridColumnSpan (optional)
gridColumnSpan?: number | undefinedNumber of columns occupied by this child. See LayoutItemStyle.
gridRowStart (optional)
gridRowStart?: number | undefinedExplicit starting grid row. See LayoutItemStyle.
gridRowSpan (optional)
gridRowSpan?: number | undefinedNumber of rows occupied by this child. See LayoutItemStyle.
transition (optional)
transition?: PibblTransitionBinding | undefinedRelated API: PibblTransitionBinding.
Visibility-transition binding applied to this primitive and its captured descendants. See SystemStyle.
custom (optional)
custom?: unknownApplication-defined style payload passed through the runtime. See SystemStyle.
filter (optional)
filter?: PibblFilter | readonly PibblFilter[] | undefinedRelated API: PibblFilter.
Ordered pixel-only filters applied to the receiving primitive and its descendants. See PibblFilter.
LinearScaleProps
Section titled “LinearScaleProps”Authored inputs for LinearScale, including the declared data and presentation options.
interface LinearScalePropsRelated API: LinearScaleProps.
See also
Section titled “See also”SignalStyle
View source — packages/core/src/features/viz/lib/types.ts:72
Properties and methods
Section titled “Properties and methods”
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:74
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:79
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:84
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:86
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:91
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:93
ResolvedLinearScale
Section titled “ResolvedLinearScale”A resolved continuous scale with forward mapping, inversion, and tick generation.
interface ResolvedLinearScaleRelated API: ResolvedLinearScale.
See also
Section titled “See also”View source — packages/core/src/features/viz/lib/types.ts:188
Properties and methods
Section titled “Properties and methods”
type
readonly type: "linear"The literal “linear” identifying this variant. See ResolvedLinearScale.
View source — packages/core/src/features/viz/lib/types.ts:190
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:192
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:194
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:196
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:202
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:209
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:216
ResolvedScale
Section titled “ResolvedScale”A numeric or categorical mapping snapshot. See ResolvedContinuousScale.
type ResolvedScale = ResolvedContinuousScale | ResolvedBandScale | ResolvedPointScaleRelated API: ResolvedScale, ResolvedContinuousScale, ResolvedBandScale, ResolvedPointScale.
View source — packages/core/src/features/viz/lib/types.ts:251
Properties and methods
Section titled “Properties and methods”
type
readonly type: "band" | "linear" | "log" | "point" | "symlog" | "utc"The literal “band” identifying this variant. See ResolvedBandScale. The literal “linear” identifying this variant. See ResolvedLinearScale. Logarithmic mapping discriminant. See LogScaleProps. Categorical point discriminant. See PointScaleProps. Signed logarithmic discriminant. See SymlogScaleProps. UTC calendar scale discriminant. See UTCScaleProps.
View source — packages/core/src/features/viz/lib/types.ts:161
domain
readonly domain: BandDomain | LinearDomainRelated API: BandDomain, LinearDomain.
Data values or endpoints accepted by the scale. See BandDomain. Data values or endpoints accepted by the scale. See LinearDomain.
View source — packages/core/src/features/viz/lib/types.ts:163
range
readonly range: readonly [number, number]Logical output coordinates produced by the scale. See ResolvedBandScale. Logical output coordinates produced by the scale. See ResolvedLinearScale.
View source — packages/core/src/features/viz/lib/types.ts:165
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:167
map
map: ((value: BandCategory) => number | undefined) | ((value: number) => number)Related API: BandCategory.
Maps a category to its band coordinate, or returns undefined for an unknown category. See ResolvedBandScale . Maps a numeric domain value to a logical range coordinate. See ResolvedLinearScale.
Parameters
Section titled “Parameters”-
value— Category to locate in the domain. See BandCategory. -
value— Numeric domain coordinate.
Returns
Section titled “Returns”The category’s range position, or undefined if it is absent from the domain.
The corresponding range coordinate.
View source — packages/core/src/features/viz/lib/types.ts:178
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”- Scales and axes: Create band and linear scales with a typed axis and inspect resolved mappings. Plain source
- UTC dates across New Year: Keep month, day, and year visible when a calendar axis crosses into a new year. Plain source
Documentation version
Section titled “Documentation version”Documentation built with @pibbl/core 0.0.2, revision 380919b. ALPHA — NOT FOR PRODUCTION USE.