Functions
Functions exported by @reincharts/widget.
import { applyPreset, chartData, chartTypeInfo, ... } from "@reincharts/widget";applyPreset
Shows a range preset: from the preset start to the last bar (plus the usual right margin). Returns the preset start time when the data does not reach back that far (load more history and retry).
function applyPreset(engine: ChartEngine, preset: RangePreset): number | undefinedchartData
Chart data for a chart type: the bars unchanged, or the transform's new bars.
function chartData(type: ChartType, data: readonly any[]): readonly any[]chartTypeInfo
Info of a chart type (candles for unknown ids).
function chartTypeInfo(id: ChartType): ChartTypeInfodefaultState
A state with every required field.
function defaultState(overrides?: Partial<TradingChartState>): TradingChartStatelayoutCount
Number of charts in a layout.
function layoutCount(layout: LayoutKind | undefined): numbernormalizeState
Validates anything (parsed JSON, a partial object) into a complete state: unknown fields are dropped, invalid
values fall back to defaults, duplicate indicator ids are removed.
function normalizeState(value: unknown, defaults?: Partial<TradingChartState>): TradingChartStateparseState
Parses a JSON string (or object) produced by serializeState / save(). Invalid input yields defaults.
function parseState(
input: string | unknown,
defaults?: Partial<TradingChartState>,
): TradingChartStatepresetStart
Start time (ms) of a range preset ending at last (the last bar time), in UTC calendar terms.
Returns undefined for "All" (fit everything).
function presetStart(preset: RangePreset, last: number): number | undefinedreduceState
Pure state reducer behind every TradingChart interaction. Returns the same object when nothing changes.
function reduceState(state: TradingChartState, action: StateAction): TradingChartStateserializeState
JSON string of a state (stable field order, no undefined values).
function serializeState(state: TradingChartState): string