Skip to content

Documentation / @finchart/core / index / XCoordinates

Interface: XCoordinates ​

Defined in: packages/core/src/plot/capabilities.ts:203

Converts between screen x and data x.

Hit testing was the first thing a third party needed, and there was no door for it here. What @finchart/tools did instead was stash the draw context into a variable — no hit test was possible before the first render, and the stashed context went stale on the next frame.

XMapping isn't handed over as-is because it has rebuild on it — rebuilding the index is the chart's job, not an extension's. Only the two read directions are exposed here.

It's not an accident that only x is here — Plot owns x, Pane owns value. The value-side counterpart is ValueCoordinates.

Consumers: @finchart/tools

Methods ​

pixelAtX() ​

pixelAtX(x): number

Defined in: packages/core/src/plot/capabilities.ts:207

The screen x (px) where a data x lands.

Parameters ​

x ​

number

Returns ​

number


xAt() ​

xAt(pixel): number

Defined in: packages/core/src/plot/capabilities.ts:205

The data x under screen x (px). Between bars, this is a linear interpolation between the neighbors.

Parameters ​

pixel ​

number

Returns ​

number