Skip to content

Documentation / @finchart/core / index / SimpleDecimation

Class: SimpleDecimation<T> ​

Defined in: packages/core/src/data/decimation.ts:200

Skips at a fixed interval — keeps every nth point without swallowing gaps.

Because it picks by index, a gap could just fall out. If it did, the line would reconnect straight across a value that shouldn't be there — so this goes through preservingHoles and decimates each segment separately.

Type Parameters ​

T ​

T extends BaseDataPoint = BaseDataPoint

Implements ​

Constructors ​

Constructor ​

new SimpleDecimation<T>(coordinates?): SimpleDecimation<T>

Defined in: packages/core/src/data/decimation.ts:210

Takes coordinates. For a point type with no y field, improvising point.y ?? null on the spot would turn "no such field" into "this is a gap," making every point a gap and letting preservingHoles collapse the whole window into one point. If omitted, the default accessor assumes {x, y} shape.

Parameters ​

coordinates? ​

CoordinateAccessor<T> = ...

Returns ​

SimpleDecimation<T>

Properties ​

coordinates ​

protected readonly coordinates: CoordinateAccessor<T>

Defined in: packages/core/src/data/decimation.ts:211

Methods ​

decimate() ​

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

Defined in: packages/core/src/data/decimation.ts:214

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[]

Implementation of ​

DecimationStrategy.decimate