Skip to content

Documentation / @finchart/core / index / DecimationStrategy

Interface: DecimationStrategy<T> ​

Defined in: packages/core/src/data/types.ts:255

Type Parameters ​

T ​

T extends BaseDataPoint = BaseDataPoint

Properties ​

indexAnchored? ​

readonly optional indexAnchored?: true

Defined in: packages/core/src/data/types.ts:261

Ask a data manager to retain an x anchor when indices shift after a prepend. An implementation using tiers must keep the anchor bar in each reduced array so its index remains a bucket boundary.

Methods ​

decimate() ​

decimate(data, range, threshold, screenXScan?, gapFree?): T[]

Defined in: packages/core/src/data/types.ts:292

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 ​

T[]

range ​

IndexRange

threshold ​

number

screenXScan? ​

() => (x) => number

gapFree? ​

boolean

Returns ​

T[]