Framework wrappers

Idiomatic wrappers for React, Vue, and Svelte. All three expose the same prop surface and hand you the underlying Chart instance.

Install

npm install @tradecanvas/react   # or @tradecanvas/vue · @tradecanvas/svelte
npm install @tradecanvas/chart   # the core (peer of each wrapper)

React

import { TradeCanvas, type TradeCanvasRef } from '@tradecanvas/react'
import { BinanceAdapter } from '@tradecanvas/chart'
import { useRef } from 'react'

function App() {
  const chartRef = useRef<TradeCanvasRef>(null)

  return (
    <TradeCanvas
      ref={chartRef}
      symbol="BTCUSDT"
      timeframe="5m"
      theme="dark"
      adapter={new BinanceAdapter()}
      onReady={(chart) => {
        chart.on('orderPlace', e => console.log(e.payload))
      }}
    />
  )
}

Vue

<script setup lang="ts">
import { TradeCanvas } from '@tradecanvas/vue'
import { BinanceAdapter } from '@tradecanvas/chart'

const adapter = new BinanceAdapter()
</script>

<template>
  <TradeCanvas
    symbol="BTCUSDT"
    timeframe="5m"
    theme="dark"
    :adapter="adapter"
    @ready="(chart) => console.log('ready', chart)"
  />
</template>

Svelte

<script lang="ts">
  import { TradeCanvas } from '@tradecanvas/svelte'
  import { BinanceAdapter } from '@tradecanvas/chart'

  const adapter = new BinanceAdapter()
</script>

<TradeCanvas
  symbol="BTCUSDT"
  timeframe="5m"
  theme="dark"
  {adapter}
  onReady={(chart) => console.log('ready', chart)}
/>

Shared props

Bars of your own, indicators with their inputs, and a chart that never opens a stream of its own:

<script lang="ts">
  import { TradeCanvas } from '@tradecanvas/svelte'
  import type { Chart } from '@tradecanvas/chart'

  let { bars } = $props()
  let chart = $state<Chart | null>(null)
</script>

<TradeCanvas
  data={bars}
  stream={false}
  indicators={['rsi', { id: 'ema', params: { period: 50 } }]}
  features={{ replay: true }}
  bind:chart
/>
PropTypeNotes
symbolstringThe stream's symbol. Default 'BTCUSDT'.
timeframeTimeFrameThe stream's interval. Default '5m'.
theme'dark' | 'light' | ThemeDefault 'dark'.
chartTypeChartTypeDefault 'candlestick'.
dataOHLCBar[]Bars of your own, shown as they are. Given at mount, no stream is opened; given later, a stream already open stays (stream=false closes it). In Vue and Svelte, a bar pushed onto the same array, or its last bar changed, goes in as a live tick and the view stays where it is; a new array is a new series.
adapterDataAdapterThe stream's source; Binance without one.
streambooleanfalse: no stream at all, the chart waits for data. Default true.
historyLimitnumberBars the stream loads first. Default 500.
indicatorsIndicatorSpec[]'rsi', or { id, params, position }; one whose inputs change is put back with them.
featuresFeaturesConfigWhat users can do on the chart; changes after mount apply too.
signalMarkers / tradeZonesarraysBuy and sell marks and trades; a replay shows them as it reaches them.
signalMarkerStyle / tradeZoneStylestylesTheir colours and labels.
overridesChartStyleOverridesThe chart's look by key (see Styling).
autoScalebooleanDefault true.
watermarkTextstringText behind the bars.
optionsPartial<ChartOptions>Chart options the props don't cover (maxBarSpacing, rightMargin, renderer…), merged over the component's defaults at mount. Later changes are not applied; chartType, theme and autoScale always come from their props.
onReady(chart) => voidAfter the chart mounts (Vue: the ready event).
Need something beyond the props? Reach the underlying Chart via onReady, a ref (React / Vue), or bind:chart (Svelte) for the full API — drawings, trading, execution adapters, plugins, resizable panes, and more.