Skip to content
EliteChart

ChartOptions

Documentation


Documentation / @elitechart/core / ChartOptions

Defined in: options.ts:29

Chart creation options. Pass to createChart as the second argument.

Example

code
import { createChart } from '@elitechart/core';
import { darkTheme } from '@elitechart/themes';

const chart = createChart(el, {
  series,
  kind: 'candle',
  priceScale: 'log',
  theme: darkTheme,
  initialVisibleBars: 200,
  onReady: () => console.log('mounted'),
});

Properties

contextMenu?

code
readonly optional contextMenu?: boolean;

Defined in: options.ts:55

Show the right-click context menu on drawings. Defaults to true. Menu items: Duplicate, Bring to front, Send to back, Lock/Unlock, Delete.


floatingToolbar?

code
readonly optional floatingToolbar?: boolean;

Defined in: options.ts:50

Show the per-drawing floating toolbar when a drawing is selected. Defaults to true. Set false to opt out (e.g. when the embedding app provides its own drawing chrome).


initialVisibleBars?

code
readonly optional initialVisibleBars?: number;

Defined in: options.ts:40

Number of bars visible at startup, counted from the most recent. Defaults to min(120, bars.length).


kind?

code
readonly optional kind?: SeriesKind;

Defined in: options.ts:33

How to visualize the series. Defaults to 'candle'.


magnet?

code
readonly optional magnet?: "off" | "weak" | "strong";

Defined in: options.ts:80

Magnet mode — snap crosshair + drawing anchors to the nearest OHLC value. Defaults to 'off'.

  • 'off' — no snapping, pointer used as-is.
  • 'weak' — snap only when the pointer is within ~10 px of an OHLC value.
  • 'strong' — always snap to the closest OHLC value on the nearest bar.

onError?

code
readonly optional onError?: (err, context) => void;

Defined in: options.ts:101

Error hook for listener exceptions. Defaults to console.error.

Parameters

err

unknown

context

string

Returns

void


onReady?

code
readonly optional onReady?: () => void;

Defined in: options.ts:99

Called once when the chart is fully initialised.

Returns

void


onRequestHistory?

code
readonly optional onRequestHistory?: (arg) => void;

Defined in: options.ts:97

Invoked when the user pans past the first bar in the series. The embedder fetches more historical bars from its datafeed and calls chart.setSeries(...) with the extended range. Debounced so rapid pans fire once.

When omitted, panning past the first bar just shows empty space — the viewport continues to shift but no data loads.

Parameters

arg
earliestLoadedTime

TimestampMs

Returns

void


persistentTool?

code
readonly optional persistentTool?: boolean;

Defined in: options.ts:87

When true, drawing tools stay active after placement so the user can drop multiple instances without re-clicking the toolbar. Commonly exposed as a "stay in drawing mode" / pin affordance. Defaults to false.


pricePadFraction?

code
readonly optional pricePadFraction?: number;

Defined in: options.ts:44

Fractional padding above/below the visible price range. Defaults to 0.08 (8%).


priceScale?

code
readonly optional priceScale?: PriceScaleKind;

Defined in: options.ts:35

Price-axis scaling. Defaults to 'linear'.


series

code
readonly series: Series;

Defined in: options.ts:31

The initial series to render.


showOhlcvLegend?

code
readonly optional showOhlcvLegend?: boolean;

Defined in: options.ts:71

Paint the canvas-side OHLCV legend (the small O … H … L … C … V string at the chart's top-left, updated to follow the crosshair). Defaults to true. Set false when the embedder ships its own symbol/price/OHLCV header (e.g. EliteChart's <HeroPrice />) to avoid duplicate paint paths for the same data.


theme?

code
readonly optional theme?: ChartForgeTheme;

Defined in: options.ts:42

Theme to apply on mount. Defaults to the built-in dark fallback.


useInternalDialogs?

code
readonly optional useInternalDialogs?: boolean;

Defined in: options.ts:63

Open the built-in AlertsDialog and SettingsDialog when "Manage alerts…" / "Settings…" are picked from the chart-context menu. Defaults to true. Set false when the embedder ships richer replacements and wants to react to the chart-context:manage-alerts / chart-context:settings events directly.