Bu sayfa henüz Türkçe diline çevrilmedi, bu yüzden İngilizce gösteriliyor.
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
/> | Prop | Type | Notes |
|---|---|---|
symbol | string | The stream's symbol. Default 'BTCUSDT'. |
timeframe | TimeFrame | The stream's interval. Default '5m'. |
theme | 'dark' | 'light' | Theme | Default 'dark'. |
chartType | ChartType | Default 'candlestick'. |
data | OHLCBar[] | 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). Bars that go on from those given before, the last one changed or bars added after it, go in as live ticks and the view isn't reset, in all three: in a new array ([...bars, next]), and in Vue and Svelte the same array pushed onto or changed too. A change to one of the last three bars before the forming one, its time the same, goes in as a correction (updateBar), so the view isn't reset either: in a new array in all three, and in Vue and Svelte in place too. Any other bars are a new series, as are yours after a stream gave the chart bars of its own. |
adapter | DataAdapter | The stream's source; Binance without one. |
stream | boolean | false: no stream at all, the chart waits for data. Default true. |
historyLimit | number | Bars the stream loads first. Default 500. |
indicators | IndicatorSpec[] | 'rsi', or { id, params, position }; one whose inputs change is put back with them. |
features | FeaturesConfig | What users can do on the chart; changes after mount apply too. |
signalMarkers / tradeZones | arrays | Buy and sell marks and trades; a replay shows them as it reaches them. |
signalMarkerStyle / tradeZoneStyle | styles | Their colours and labels. |
overrides | ChartStyleOverrides | The chart's look by key (see Styling). |
autoScale | boolean | Default true. |
watermarkText | string | Text behind the bars. |
options | Partial<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) => void | After the chart mounts (Vue: the ready event). |
Need something beyond the props? Reach the underlyingChartviaonReady, a ref (React / Vue), orbind:chart(Svelte) for the full API — drawings, trading, execution adapters, plugins, resizable panes, and more.
Powered by badge
To credit TradeCanvas in your app, place the badge: the words, the TC mark and the wordmark as one link to tradecanvas.dev, read by screen readers as “Powered by TradeCanvas”. It takes the text colour around it, so it follows a light or dark theme; only the mark's candle keeps the brand's amber.
<script lang="ts">
import { PoweredBy } from '@tradecanvas/svelte'
</script>
<PoweredBy size={14} /> import { createPoweredBy } from '@tradecanvas/chart/brand'
statusBar.append(createPoweredBy({ height: 14 })) size (Svelte) or height is the mark's height in pixels, from 12: 14–16 fits a status strip, 24 a footer. The words are set in your page's face and never fall under 10 px. href and target (default _blank) go to the link; poweredByHtml() gives the markup, and TRADECANVAS_MARK_SVG and TRADECANVAS_WORDMARK_SVG the art alone.
The badge has an entry of its own, @tradecanvas/chart/brand, which reaches none of the chart, so a page that shows the badge and no chart, such as a landing page's footer, stays a few kilobytes. The main entry exports the same names. The Svelte PoweredBy imports from it.