Skip to content

charton API


charton API / @chart-on/core / index / NumericChart

Class: NumericChart ​

Defined in: packages/core/src/numeric/chart.ts:467

A chart whose horizontal axis is a plain number instead of time: order-book depth (price on x), yield curves (maturity on x), option chains (strike on x). It shares the time chart's WebGL2 renderer, theme tokens, fonts and price formats, so both look alike side by side, but has none of its time-based machinery: no candles, indicators, sessions, data source or drawings. Make one with createNumericChart.

Constructors ​

Constructor ​

new NumericChart(container, options?): NumericChart

Defined in: packages/core/src/numeric/chart.ts:514

Parameters ​

container ​

HTMLElement

options? ​

NumericChartOptionsPatch = {}

Returns ​

NumericChart

Properties ​

dpr ​

dpr: number = 1

Defined in: packages/core/src/numeric/chart.ts:476


height ​

height: number = 0

Defined in: packages/core/src/numeric/chart.ts:475


options ​

options: NumericChartOptions

Defined in: packages/core/src/numeric/chart.ts:469


plotHeight ​

plotHeight: number = 0

Defined in: packages/core/src/numeric/chart.ts:473


plotWidth ​

plotWidth: number = 0

Defined in: packages/core/src/numeric/chart.ts:472

Plot area, css px: the chart minus the price axis (right) and the x axis (bottom).


root ​

readonly root: HTMLDivElement

Defined in: packages/core/src/numeric/chart.ts:468


theme ​

theme: ChartTheme

Defined in: packages/core/src/numeric/chart.ts:470


width ​

width: number = 0

Defined in: packages/core/src/numeric/chart.ts:474

Methods ​

addHistogram() ​

addHistogram(options?): NumericHistogramSeries

Defined in: packages/core/src/numeric/chart.ts:571

Columns from base to each item's value, centred on its x.

Parameters ​

options? ​

Partial<NumericHistogramOptions> = {}

Returns ​

NumericHistogramSeries


addLine() ​

addLine(options?): NumericLineSeries

Defined in: packages/core/src/numeric/chart.ts:555

A line, step line (lineType: 'step') or area (area: true).

Parameters ​

options? ​

Partial<NumericLineOptions> = {}

Returns ​

NumericLineSeries


addPriceLine() ​

addPriceLine(options): NumericPriceLine

Defined in: packages/core/src/numeric/chart.ts:592

A horizontal line at price, with an optional title and axis label.

Parameters ​

options ​

Partial<NumericPriceLineOptions> & Pick<NumericPriceLineOptions, "price">

Returns ​

NumericPriceLine


applyOptions() ​

applyOptions(patch): void

Defined in: packages/core/src/numeric/chart.ts:630

Change options with a partial patch; horizontalScale and priceScale merge field by field.

Parameters ​

patch ​

NumericChartOptionsPatch

Returns ​

void


attachPrimitive() ​

attachPrimitive(primitive): () => void

Defined in: packages/core/src/numeric/chart.ts:609

Draw primitive on the chart. Returns a function that detaches this attachment only. Throws when it is attached already, and a ChartError (destroyed) after destroy(); when its attached throws, it is not attached and the error propagates.

Parameters ​

primitive ​

NumericPrimitive

Returns ​

() => void


coordinateFor() ​

coordinateFor(x, price?): { x: number; y: number | null; } | null

Defined in: packages/core/src/numeric/chart.ts:692

Chart-root css px of a data position; y is null without a price. Null before the chart has a size.

Parameters ​

x ​

number

price? ​

number | null

Returns ​

{ x: number; y: number | null; } | null


destroy() ​

destroy(): void

Defined in: packages/core/src/numeric/chart.ts:727

Returns ​

void


detachPrimitive() ​

detachPrimitive(primitive): void

Defined in: packages/core/src/numeric/chart.ts:625

Parameters ​

primitive ​

NumericPrimitive

Returns ​

void


fitContent() ​

fitContent(): void

Defined in: packages/core/src/numeric/chart.ts:658

Show every series' items, with the horizontal margin; the view follows new data again until the next pan or zoom.

Returns ​

void


getPriceRange() ​

getPriceRange(): object

Defined in: packages/core/src/numeric/chart.ts:680

The price range the vertical axis shows, low to high.

Returns ​

object

from ​

from: number

to ​

to: number


getSeries() ​

getSeries(): readonly NumericSeries[]

Defined in: packages/core/src/numeric/chart.ts:587

The series in drawing order (first drawn first).

Returns ​

readonly NumericSeries[]


getVisibleRange() ​

getVisibleRange(): object

Defined in: packages/core/src/numeric/chart.ts:665

The visible x range, left to right in value (from < to, also when inverted).

Returns ​

object

from ​

from: number

to ​

to: number


invalidate() ​

invalidate(): void

Defined in: packages/core/src/numeric/chart.ts:719

Redraw on the next animation frame.

Returns ​

void


on() ​

on<K>(event, listener): () => void

Defined in: packages/core/src/numeric/chart.ts:550

Subscribe to an event; returns the function that unsubscribes.

Type Parameters ​

K ​

K extends keyof NumericChartEvents

Parameters ​

event ​

K

listener ​

(payload) => void

Returns ​

() => void


pointAt() ​

pointAt(x, y): NumericPointerEvent | null

Defined in: packages/core/src/numeric/chart.ts:686

The data position at chart-root css px, or null outside the plot.

Parameters ​

x ​

number

y ​

number

Returns ​

NumericPointerEvent | null


removeSeries() ​

removeSeries(series): void

Defined in: packages/core/src/numeric/chart.ts:578

Parameters ​

series ​

NumericSeries

Returns ​

void


resize() ​

resize(): void

Defined in: packages/core/src/numeric/chart.ts:707

Re-read the container size; the chart also does this itself when the container resizes.

Returns ​

void


setCrosshairAt() ​

setCrosshairAt(point): void

Defined in: packages/core/src/numeric/chart.ts:701

Put the crosshair at a data position, or remove it with null. It stays at that position through pans, zooms and new data until the pointer moves.

Parameters ​

point ​

NumericPoint | null

Returns ​

void


setVisibleRange() ​

setVisibleRange(range): void

Defined in: packages/core/src/numeric/chart.ts:670

Show from to to on the horizontal axis. The view then stays there when data changes.

Parameters ​

range ​
from ​

number

to ​

number

Returns ​

void