Skip to content

CandlestickLayerConfig

Renders OHLC price data as candlesticks, with directional styling for candle bodies, wicks, and the active value marker.

Examples

JSX - Minimal configuration

tsx
<Candlesticks />

JSX - Full configuration

tsx
<Candlesticks
  id="price-candles"
  inputs={[
    { key: 'open', source: { type: 'price', field: 'open' } },
    { key: 'high', source: { type: 'price', field: 'high' } },
    { key: 'low', source: { type: 'price', field: 'low' } },
    { key: 'close', source: { type: 'price', field: 'close' } },
  ]}
  outputs={['open', 'high', 'low', 'close']}
  calculate={true}
  includeInAutoScale={true}
  series={{
    body: {
      up: { backgroundColor: '#10b981', borderColor: '#10b981', borderWidth: 0 },
      down: { backgroundColor: 'white', borderColor: '#ef4444', borderWidth: 1 },
      flat: { backgroundColor: '#999', borderColor: '#999', borderWidth: 0 },
    },
    wick: {
      up: { color: '#10b981', width: 1, style: 'solid' },
      down: { color: '#ef4444', width: 1, style: 'solid' },
      flat: { color: '#999', width: 1, style: 'solid' },
    },
  }}
  markers={{
    value: {
      mode: 'last-visible',
      showLine: true,
      showLabel: true,
      up: {
        line: { color: '#10b981', width: 1, style: 'dashed', dashes: [5, 5] },
        label: { backgroundColor: 'white', borderColor: '#10b981', color: '#10b981' },
      },
      down: {
        line: { color: '#ef4444', width: 1, style: 'dashed', dashes: [5, 5] },
        label: { backgroundColor: 'white', borderColor: '#ef4444', color: '#ef4444' },
      },
      flat: {
        line: { color: '#999', width: 1, style: 'dashed', dashes: [5, 5] },
        label: { backgroundColor: 'white', borderColor: '#999', color: '#999' },
      },
    },
  }}
  legend={{
    label: 'OHLC',
    fields: [
      { output: 'open', color: '#1a1a1a' },
      { output: 'high', color: '#1a1a1a' },
      { output: 'low', color: '#1a1a1a' },
      { output: 'close', color: '#1a1a1a' },
    ],
  }}
  yAxis={{ side: 'right', width: 80 }}
/>

Configuration Object - Full configuration

ts
{
  id: 'price-candles',
  type: 'price:candlesticks',
  inputs: [
    { key: 'open', source: { type: 'price', field: 'open' } },
    { key: 'high', source: { type: 'price', field: 'high' } },
    { key: 'low', source: { type: 'price', field: 'low' } },
    { key: 'close', source: { type: 'price', field: 'close' } },
  ],
  outputs: ['open', 'high', 'low', 'close'],
  calculate: true,
  includeInAutoScale: true,
  series: {
    body: {
      up: { backgroundColor: '#10b981', borderColor: '#10b981', borderWidth: 0 },
      down: { backgroundColor: 'white', borderColor: '#ef4444', borderWidth: 1 },
      flat: { backgroundColor: '#999', borderColor: '#999', borderWidth: 0 },
    },
    wick: {
      up: { color: '#10b981', width: 1, style: 'solid' },
      down: { color: '#ef4444', width: 1, style: 'solid' },
      flat: { color: '#999', width: 1, style: 'solid' },
    },
  },
  markers: {
    value: {
      mode: 'last-visible',
      showLine: true,
      showLabel: true,
      up: {
        line: { color: '#10b981', width: 1, style: 'dashed', dashes: [5, 5] },
        label: { backgroundColor: 'white', borderColor: '#10b981', color: '#10b981' },
      },
      down: {
        line: { color: '#ef4444', width: 1, style: 'dashed', dashes: [5, 5] },
        label: { backgroundColor: 'white', borderColor: '#ef4444', color: '#ef4444' },
      },
      flat: {
        line: { color: '#999', width: 1, style: 'dashed', dashes: [5, 5] },
        label: { backgroundColor: 'white', borderColor: '#999', color: '#999' },
      },
    },
  },
  legend: {
    label: 'OHLC',
    fields: [
      { output: 'open', color: '#1a1a1a' },
      { output: 'high', color: '#1a1a1a' },
      { output: 'low', color: '#1a1a1a' },
      { output: 'close', color: '#1a1a1a' },
    ],
  },
  yAxis: { side: 'right', width: 80 },
}

Properties

Base Props

BaseLayerConfig

type

  • Type: 'price:candlesticks'

series

  • Type: { body?: false | DirectionalBarConfig; wick?: false | DirectionalLineConfig }

Visual series configuration for candle body and wick.

markers

  • Type: { value?: false | DirectionalValueMarkerConfig }

Directional value marker configuration for candlesticks.

Defaults

PropertyDefault
id'candlestick-layer'
inputsopen, high, low, close price fields
outputs['open', 'high', 'low', 'close']
scale{ key: 'price_auto', domain: 'price', range: { type: 'auto' } }
scalePolicy'fixed'
includeInAutoScaletrue
offset0
period1
lookback0
valueLabelFormatter(value) => value.toFixed(2)
series.bodyUses theme.layers.candlesticks.series.body
series.wickUses theme.layers.candlesticks.series.wick
markers.valueUses theme.layers.candlesticks.markers.value
legendUses theme.layers.candlesticks.legend
yAxisUses theme.layers.candlesticks.yAxis

TypeScript

ts
interface CandlestickLayerConfig extends BaseLayerConfig {
  type: 'price:candlesticks';
  series?: {
    body?: false | DirectionalBarConfig;
    wick?: false | DirectionalLineConfig;
  };
  markers?: {
    value?: false | DirectionalValueMarkerConfig;
  };
}

React Candlesticks is available on npm and GitHub under the MIT License.