Skip to content

Documentation / @finchart/core / index / OHLCAccessor

Class: OHLCAccessor ​

Defined in: packages/core/src/data/accessors.ts:51

Pulls display x/y coordinates out of a point.

Implements ​

Constructors ​

Constructor ​

new OHLCAccessor(): OHLCAccessor

Returns ​

OHLCAccessor

Properties ​

gapless ​

readonly gapless: true = true

Defined in: packages/core/src/data/accessors.ts:65

A bar can never produce a gap — getY returns close, and assertFinite already guarantees all four are finite at the data gate. close: null is a rejection at this accessor, not a gap.

Implementation of ​

CoordinateAccessor.gapless


uniqueX ​

readonly uniqueX: true = true

Defined in: packages/core/src/data/accessors.ts:73

One bar per x. A repeated x on bars is never "two points at one moment" — it is the same candle handed over twice (an inclusive REST boundary after a reconnect), and it would draw twice and answer probe with either one. Loud at every door (duplicate-x).

Implementation of ​

CoordinateAccessor.uniqueX

Methods ​

assertFinite() ​

assertFinite(point, index, label?): void

Defined in: packages/core/src/data/accessors.ts:106

Checks all four. getY only reads close and valueExtent only reads low/high, so open passes through no gate at all and leaks through without this check.

null is a rejection, not a gap — a bar is a bundle of four, and if one is missing there's nothing left to draw. A missing bar is already expressed as "don't include the point," so giving null a meaning here would make it mean "price zero." Volume is the one field with the other rule: a bar without volume is still a bar, so null (and absence) is a gap there — only a value that is present and not a finite number is rejected. OHLC_GAP_FIELDS names that group for the same machine check.

Lays out the four fields by hand — the machine, not a runtime check, guards against a leak. Four hand-laid lines are more than twice as fast as a loop over the array (the indirection cost of iterator allocation plus a dynamic lookup per point). This spot is also on the tick path: a derived registration's updateLast runs a full setData every frame.

Readability is bought with a test instead of a runtime check — ohlc-fields.test.ts confirms every field in OHLC_FIELDS is actually rejected, so if a fifth field appears and this isn't updated, that test goes red.

Parameters ​

point ​

OHLC

index ​

number

label? ​

string = "data"

Returns ​

void

Implementation of ​

CoordinateAccessor.assertFinite


getX() ​

getX(point): number

Defined in: packages/core/src/data/accessors.ts:52

Where to place it. Can't be absent.

A point with no x isn't whitespace — it's a point that must be dropped. If you don't know where to put it, you can't even draw a gap for it.

Parameters ​

point ​

OHLC

Returns ​

number

Implementation of ​

CoordinateAccessor.getX


getY() ​

getY(point): number

Defined in: packages/core/src/data/accessors.ts:56

What to draw. null means there's no value (whitespace).

Where there's no value the line breaks, the value range (valueExtent) doesn't count that point, and decimation doesn't swallow that spot.

Can also return undefined — meaning "couldn't read it." For the manager to point out a mismatched field name like {x, value}, that value has to surface here.

Consumers already receive all of this uniformly through isGap (line, area, histogram, baseline).

Parameters ​

point ​

OHLC

Returns ​

number

Implementation of ​

CoordinateAccessor.getY


getYRange() ​

getYRange(point): object

Defined in: packages/core/src/data/accessors.ts:76

One bar's data value span — low to high. A candidate for snapping.

Parameters ​

point ​

OHLC

Returns ​

object

max ​

max: number

min ​

min: number

Implementation of ​

CoordinateAccessor.getYRange