Skip to content

Documentation / @finchart/indicators / PnfAggregation

Class: PnfAggregation ​

Defined in: indicators/src/point-and-figure-series.ts:89

Merges columns instead of thinning them — the aggregation pointAndFigureSeries declares. Picking one column out of a bucket would drop the others' high and low (the reason the default strategy is not used for candles either), so a bucket becomes one column spanning the bucket's lowest and highest box, of the last column's tone — its open and close at the ends that tone runs between, boxes the boxes the span holds, x the first column's and closedAt the last's (the candle whose close last extended the bucket) — so a merged column keeps every invariant a column has, and draws like one. Buckets split by index, one per pixel of budget, as candles do.

Implements ​

Constructors ​

Constructor ​

new PnfAggregation(boxSize): PnfAggregation

Defined in: indicators/src/point-and-figure-series.ts:92

Parameters ​

boxSize ​

number

Returns ​

PnfAggregation

Methods ​

decimate() ​

decimate(data, range, threshold): PointAndFigureColumn[]

Defined in: indicators/src/point-and-figure-series.ts:96

Decimates only the [range.start, range.end) window, not all of data.

Why the window is a range, not an array: if the caller copied the visible range with slice, that's a big new array every frame on large data, most of it thrown away unused. Why the range is required, not optional: if it were optional, a strategy that doesn't know the range could decimate the whole array and the type system wouldn't catch it.

screenXScan is a factory that opens a pass for screen-place lookups (see Viewport.screenXScan). A strategy that buckets by x (M4Decimation, LttbDecimation) has to bucket in that same space when the screen space differs. Each sweep opens one pass — the cursor belongs to that pass, so strategies and frames can't interfere with each other. If absent, x is the screen place (continuous coordinate space, the default).

gapFree is a fact the caller already knows — if true, this data is guaranteed gap-free, so the window scan that would otherwise find gap boundaries is skipped. Gap presence is a property of the array, not the window, so the viewport cache can't save this for you — only the side that owns the changes can maintain it incrementally.

Not merged with gapless — that's a static fact about the accessor, this is runtime state of the array.

False covers "don't know," not just "has gaps" — the safe default is false. Passing true incorrectly swallows gaps, and the line runs straight across a spot that should have no value.

Parameters ​

data ​

PointAndFigureColumn[]

range ​

IndexRange

threshold ​

number

Returns ​

PointAndFigureColumn[]

Implementation of ​

DecimationStrategy.decimate