Skip to content
pyautark (soon)

@urban-toolkit/autk-plot


@urban-toolkit/autk-plot / reduceBuckets

Function: reduceBuckets()

reduceBuckets(options): ReducedBucket[]

Defined in: transforms/kernel.ts:39

Groups rows into keyed buckets and reduces each bucket to a single value.

Parameters

options

Aggregation configuration with rows, bucketOf, valueOf, and reducer.

bucketOf

(row) => string | null

Assigns a bucket key to each row; return null to skip the row.

reducer

TransformReducer

Aggregation strategy applied within each bucket.

rows

Row[]

Input rows to aggregate.

valueOf?

(row) => number | null

Optional numeric extractor used for non-count reducers.

Returns

ReducedBucket[]

Reduced buckets with merged autkIds for selection linking.

Throws

Never throws. Rows with null keys or non-finite values are skipped.

Example

ts
const buckets = reduceBuckets({
  rows: data,
  bucketOf: row => String(row.category),
  valueOf: row => row.amount,
  reducer: 'sum',
});

Released under the MIT License.