Skip to content

Documentation / @finchart/core / index / barIndexX

Function: barIndexX() ​

barIndexX(scale, probe?): XMapping

Defined in: packages/core/src/scale/x-mapping.ts:236

Converts x into a bar index before handing it to the scale. This is the coordinate system financial charts want.

A bar is always exactly one slot from its neighbor regardless of the x gap — weekends and market closures don't open up as blank space on screen, and pan/zoom moves evenly bar by bar too.

ts
browserDeps({ createXMapping: barIndexX })

The origin is the first bar ever seen, and it never moves after that. When prepend attaches history, the new bars extend into negative indices — existing bars keep their index, so the window (the domain) you were looking at still fits.

An x between bars (say, under the crosshair) is placed by linear interpolation between its neighbors. Outside either end, the edge spacing is carried on.

Parameters ​

scale ​

Scale

probe? ​

XMappingProbe

Returns ​

XMapping