@reincharts/widget

The batteries-included <TradingChart> component.

npm install @reincharts/widget

Everything here is also re-exported by the umbrella package reincharts.

Components

NameDescription
MainSeriesThe main series element for a chart type.
TradingChartA batteries-included stock chart: toolbar (symbol search, intervals, chart types, indicators, compare, layouts, replay, screenshot, fullscreen, theme), drawing tools, legends with controls, indicator settings, context menu, object tree, range presets and scale modes, multi-chart layouts with sync — in data mode (data) or datafeed mode (datafeed).
WidgetIconA small inline SVG line icon (stroke = currentColor).

Functions

NameDescription
applyPresetShows a range preset: from the preset start to the last bar (plus the usual right margin).
chartDataChart data for a chart type: the bars unchanged, or the transform's new bars.
chartTypeInfoInfo of a chart type (candles for unknown ids).
defaultStateA state with every required field.
layoutCountNumber of charts in a layout.
normalizeStateValidates 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.
parseStateParses a JSON string (or object) produced by serializeState / save().
presetStartStart time (ms) of a range preset ending at last (the last bar time), in UTC calendar terms.
reduceStatePure state reducer behind every TradingChart interaction.
serializeStateJSON string of a state (stable field order, no undefined values).

Constants

NameDescription
CHART_TYPE_IDSEvery chart type id, in chart type menu order (unknown ids in a saved state fall back to "candles").
CHART_TYPESEvery chart type, in menu order.
LAYOUTSEvery multi-chart layout id, in layout menu order.
PRICE_PANEId of the main (price) pane.
RANGE_PRESETSRange buttons of the bottom bar, in display order ("All" fits every loaded bar).
SCALE_MODESEvery price scale mode: linear, logarithmic, percent change from the first visible bar, indexed to 100.

Types

NameDescription
ChartTypeMain series styles offered by the chart type menu.
ChartTypeInfoDescribes one chart type of the chart type menu.
IndicatorConfigAn indicator to start with: a registry id ("rsi") or an object with inputs / styles.
IndicatorStateOne indicator on the chart (serializable).
LayoutKindMulti-chart grid: one chart, two side by side ("2h"), two stacked ("2v"), one big + two ("3") or 2×2 ("4").
MainSeriesPropsProps passed to the main series.
RangePresetBottom bar range buttons.
ScaleModePrice scale mode of the main pane.
StateActionAn action of reduceState: one user change (pick a symbol, add an indicator, load a state...).
TradingChartBarAn OHLCV bar for data mode: a date (Date) or time (ms epoch) plus prices.
TradingChartHandleImperative API of <TradingChart ref>.
TradingChartPropsProps of <TradingChart>.
TradingChartSettingsUser preferences edited in the settings dialog (missing fields fall back to the TradingChart props).
TradingChartStateWhole-layout state of a TradingChart.
WidgetIconNameName of a built-in widget icon.
WidgetIconPropsProps of WidgetIcon.

On this page