Skip to content

TradingChartsView ​

TradingChartsView is the React component that places a native chart in your screen. Its props describe how the chart looks and behaves: the series type, pane layout, axes, gestures and event handlers.

Give the view a visible size through style and a unique, stable chartId. Pass that same ID to TradingCharts when loading history or sending updates. Data goes through those commands rather than a candle-array prop, so a feed can update the native store without replacing a large React prop on every tick.

The component also accepts React Native ViewProps, including accessibility props. Start with the first-chart example if you have not mounted a chart yet; use this page to look up individual options.

PropertyType / valuesDefaultDescription
chartIdstringRequiredUnique, non-empty ID used by the imperative API and native registry.
resolutionChartResolution{ unit: 'minute', multiplier: 1 }Raw-trade aggregation interval.
tradeAggregationTradeAggregationOptionsEpoch-aligned, ignore out-of-session tradesCalendar and bucket behavior for raw trades.
initialVisibleCountPositive integer100Number of candles targeted by the initial viewport.
defaultScalePositive number1Initial horizontal zoom applied after initialVisibleCount.
seriesChartSeriesOptions{ type: 'candlestick' }Main-series display type and value source.
panesChartPaneOptions[]One main panePane layout and pane price scales.
additionalSeriesAdditionalChartSeriesOptions[][]Series rendered in addition to the reserved main series.
panesResizablebooleantrue when multiple panes existEnables dragging pane separators.
themeChartThemeDark themeHigh-level color tokens.
appearanceChartAppearanceDerived from themeRole-specific native presentation.
formattersChartFormattersDerived from axis optionsRole-specific date and price formats.
xAxisXAxisOptionsVisible, time spacing, UTCTime-axis behavior and dimensions.
yAxisYAxisOptionsVisible on the rightMain price-axis behavior and formatting.
gesturesGestureOptionsAll enabledNative pan, horizontal zoom, and Y-scale gestures.
currentPriceCurrentPriceOptionsVisible with edge-pinned labelLatest-price line and badge behavior.
priceExtremesPriceExtremesOptionsVisibleVisible high/low labels.
crosshairCrosshairOptionsEnabled with tooltipCrosshair interaction and tooltip behavior.
onVisibleRangeChange(event) => voidundefinedReceives visible candle range changes.
onScaleChange(event) => voidundefinedReceives user-driven horizontal scale changes.
onYAxisScaleChange(event) => voidundefinedReceives user-driven main Y-scale changes.
onYAxisPress(event: YAxisPressEvent) => voidundefinedReceives taps on any visible pane Y-axis with local coordinates and the mapped price.
onPaneResize(event) => voidundefinedReceives interactive pane size changes.
onPriceScaleChange(event) => voidundefinedReceives per-pane price-scale changes.
onSelectedCandleChange(candle: OhlcCandle | null, seriesValues: ReadonlyArray<CrosshairSeriesValue>) => voidundefinedReceives crosshair selection changes and visible additional-series values.

Usage ​

tsx
import { useEffect } from 'react';
import {
  TradingCharts,
  TradingChartsView,
  type OhlcCandle,
} from 'react-native-trading-charts';

// Deterministic sample data. Replace this with your market-data feed.
const history: OhlcCandle[] = Array.from({ length: 80 }, (_, index) => {
  const open = 100 + Math.sin(index / 5) * 8;
  const close = 100 + Math.sin((index + 1) / 5) * 8;
  return {
    timestamp: 1_720_000_000_000 + index * 60_000,
    open,
    high: Math.max(open, close) + 2,
    low: Math.min(open, close) - 2,
    close,
    volume: 10 + index,
  };
});

const chartId = 'first-chart';

export function Example() {
  useEffect(() => {
    TradingCharts.setHistory(chartId, history);
  }, []);

  return (
    <TradingChartsView
      style={{ height: 420 }}
      chartId={chartId}
      resolution={{ unit: 'minute' }}
      series={{ type: 'candlestick' }}
    />
  );
}

Configuration reference ​

Follow the guide for a prop group when you need an example or the defaults of its nested options.

Prop groupDetailed options and defaults
series, additionalSeriesSeries types, additional series, indicators
resolution, tradeAggregationTime and aggregation
panes, panesResizablePane layout
theme, appearanceStyling
formatters, xAxis, yAxisAxes and formatting
gestures, initial scalesGestures and viewport
crosshairCrosshair and tooltips
currentPrice, priceExtremesPrice overlays
Event callbacksEvents

Invalid configuration throws TypeError during JS resolution. See each option's accepted ranges and the type reference.

Released under the MIT License.