pieSlices
Import pieSlices from @pibbl/core/viz. Call pieSlices(data, { value, keyBy? }).
value is a numeric property key or (datum, index, data) accessor; keyBy
uses the same property/function convention as PlotSeries.
Returns a frozen array of frozen PieSliceGeometry records with datum, source index,
string key, value, fraction, startAngle, and endAngle. Datum references
are preserved, not frozen or copied. No sorting or input mutation occurs.
Values must be finite and nonnegative. Null and undefined become zero; other invalid values and an overflowing total throw. Zero/missing rows remain in the result with zero fraction and equal angles. Empty input returns an empty array; an all-zero dataset has no painted sectors. A zero fraction does not mean an equal share.
Angles use Canvas radians, clockwise from −π/2 (12 o’clock), covering one full
turn. Feed them directly to core Wedge style. Its exact filled-sector and
optional stroke geometry supplies normal Pibbl events, transforms, and clipping.
Decorative labels should set pointerEvents="none". Shared edges use ordinary
source paint order; there is no nearest-slice or chart-wide target.
Keys default to stringified source indices. Supply unique stable category IDs
for mutable data and use slice.key as the Pibbl element key. String and finite
number keys are accepted; duplicates after string conversion throw. Reordering
changes angles while preserving explicit keys; record objects are fresh on each
call.
The helper owns no rendering or reactive resources. Read data signals inside a
component or core computed and pass the resulting plain array. Compose Wedge,
custom labels, legends, and HoverCard with ordinary elements and handlers.
Angles are radius-independent, so custom annular Path geometry can reuse them;
core Wedge has no inner radius. Donut rendering, padding, sorting, and arbitrary
sweeps are outside this first slice.
API details from source
Section titled “API details from source”
pieSlices
Section titled “pieSlices”Pure source-ordered full-circle layout. Angles use Canvas radians, clockwise from the top.
pieSlices: <D>(data: readonly D[], { value: input, keyBy }: PieOptions<D>) => readonly PieSliceGeometry<D>[]Related API: pieSlices, PieOptions, PieSliceGeometry.
Parameters
Section titled “Parameters”-
data— Records whose values determine slice proportions. -
options— Value accessor and optional stable key accessor. See PieOptions.
Returns
Section titled “Returns”Ordered slice geometry associated with the input records. See PieSliceGeometry.
See also
Section titled “See also”View source — packages/core/src/features/viz/lib/pie-slices.ts:55
PieOptions
Section titled “PieOptions”Value and stable-key accessors used to derive pie-slice geometry.
interface PieOptions<D>Related API: PieOptions.
See also
Section titled “See also”View source — packages/core/src/features/viz/lib/pie-slices.ts:14
Properties and methods
Section titled “Properties and methods”
value
readonly value: LineAccessor<D>Related API: LineAccessor.
Value associated with this sample, input, or result. See LineAccessor.
View source — packages/core/src/features/viz/lib/pie-slices.ts:16
keyBy (optional)
readonly keyBy?: PlotKeyAccessor<D> | undefinedRelated API: PlotKeyAccessor.
Property or callback supplying stable identity for each datum. See PlotKeyAccessor.
View source — packages/core/src/features/viz/lib/pie-slices.ts:18
PieSliceGeometry
Section titled “PieSliceGeometry”A datum’s key, value, fraction, and angular interval in a pie layout.
interface PieSliceGeometry<D>Related API: PieSliceGeometry.
See also
Section titled “See also”View source — packages/core/src/features/viz/lib/pie-slices.ts:28
Properties and methods
Section titled “Properties and methods”
datum
readonly datum: DThe original data item selected by this result. See PieSliceGeometry.
View source — packages/core/src/features/viz/lib/pie-slices.ts:30
index
readonly index: numberIndex of the selected datum in its source data. See PieSliceGeometry.
View source — packages/core/src/features/viz/lib/pie-slices.ts:32
key
readonly key: stringStable identity used by the containing protocol. See PieSliceGeometry.
View source — packages/core/src/features/viz/lib/pie-slices.ts:34
value
readonly value: numberValue associated with this sample, input, or result. See PieSliceGeometry.
View source — packages/core/src/features/viz/lib/pie-slices.ts:36
fraction
readonly fraction: numberNormalized share or position represented by this value. See PieSliceGeometry.
View source — packages/core/src/features/viz/lib/pie-slices.ts:38
startAngle
readonly startAngle: numberAngle at which the arc or slice begins. See PieSliceGeometry.
View source — packages/core/src/features/viz/lib/pie-slices.ts:40
endAngle
readonly endAngle: numberAngle at which the arc or slice ends. See PieSliceGeometry.
View source — packages/core/src/features/viz/lib/pie-slices.ts:42
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”- Pie chart composition: Compute pie geometry and render labeled donut slices. Plain source
Documentation version
Section titled “Documentation version”Documentation built with @pibbl/core 0.0.2, revision 272a94a. ALPHA — NOT FOR PRODUCTION USE.