หน้านี้ยังไม่ได้แปลเป็นภาษาไทย จึงแสดงเป็นภาษาอังกฤษ

Embeddable widget

Drop a fully configured trading chart into any page via a single <iframe> URL. No npm install, no build step.

Basic iframe

<iframe
  src="https://your-site/tradecanvas/embed/?symbol=BTCUSDT&timeframe=5m&theme=dark"
  width="800"
  height="500"
  style="border: 0; border-radius: 12px;"
></iframe>

URL parameters

ParamDefaultNotes
symbolBTCUSDTBinance symbol.
timeframe5m1m, 5m, 15m, 1h, 4h, 1d.
themedarkdark, light, darkTerminal.
chartTypecandlestickAny of the 25 types.
indicatorsnoneComma-separated ids, e.g. indicators=sma,rsi.
tradingfalseShow the trading panel.

In a phone app

The chart and the widget run in any WebView: React Native (react-native-webview), Capacitor, Tauri, a native app's own. Below 641 px wide the widget lays itself out for a phone: the toolbar keeps the symbol, the interval, the chart type and the indicators and puts the rest under “more”; the drawing tools wait behind a button over the chart; menus open as sheets from the bottom; a grid shows one chart at a time, with a tab for each. Wider, a toolbar that doesn't fit does the same. From about 320 px wide, or much narrower without items of your own on it, the status bar keeps its clock whole: short of room, the range presets fold under “more”, the longest first, then go to date, and last the market's status shrinks to a word (“Closed”). A finger does what a mouse does.

Under a finger (a device whose main pointer is coarse: a phone, a tablet at any width) no control of the widget is smaller than 32 px each way, in every look and density: buttons, fields and menu rows are raised to it, each row of the indicator legend is a finger tall, and a pane's buttons and its legend names take 32 px of a press around their drawing. Under a mouse a control takes 20 px of a press at least. One thing stays smaller: the corner of a drawing tool that opens its menu, which any larger would take the press of the tool itself.

Give the page a viewport that covers the screen. The widget keeps its sheets clear of the notch and the home bar, and above the on-screen keyboard.

<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">

Most WebViews report the page hidden when the app goes to the background: the chart then stops drawing by itself (pauseWhenHidden), and a stream silent too long reconnects when the app comes back. Where yours doesn't, pause it from the app.

// React Native (react-native-webview): the app tells the page
AppState.addEventListener('change', (state) => {
  webview.current?.injectJavaScript(state === 'active' ? 'chart.resume(); true;' : 'chart.suspend(); true;');
});

// Capacitor
import { App } from '@capacitor/app';
App.addListener('appStateChange', ({ isActive }) => (isActive ? chart.resume() : chart.suspend()));

A chart inside a screen that scrolls leaves vertical swipes to the screen.

new Chart(host, { pageScroll: true })   // a chart in a screen that scrolls

Tauri's content security policy must let the page reach the data feed's hosts. The widget also needs style-src 'unsafe-inline', for the one <style> element it adds, and img-src data:, for the small icons in its fields and checkboxes: without the first it shows unstyled, without the second its fields and checkboxes lose their icons. Copying the chart image needs nothing more.

// tauri.conf.json (Tauri 2): the feed's hosts, the widget's styles and icons
"app": {
  "security": {
    "csp": "default-src 'self'; connect-src 'self' https://api.binance.com wss://stream.binance.com:9443; style-src 'self' 'unsafe-inline'; img-src 'self' data:"
  }
}

Tauri adds a nonce to style-src for each <style> element in the page's own HTML (and a hash in its isolation pattern), and a browser ignores 'unsafe-inline' once a nonce is there, so the widget's styles are refused again. Keep the page's styles in stylesheet files, or list "style-src" under dangerousDisableAssetCspModification.

The chart draws at a pixel ratio of 2 at most (maxPixelRatio); destroy it (chart.destroy()) when its screen closes, and its canvas memory goes back at once.

Live page

Visit the embed route directly to preview without the docs chrome.