@tradecanvas/chart 1.3.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/README.md +131 -49
  2. package/dist/Chart.d.ts +724 -18
  3. package/dist/Chart.d.ts.map +1 -1
  4. package/dist/DataManager.d.ts +5 -0
  5. package/dist/DataManager.d.ts.map +1 -1
  6. package/dist/HistoryPager.d.ts +58 -0
  7. package/dist/HistoryPager.d.ts.map +1 -0
  8. package/dist/LayoutSession-CTZB90NX.cjs +2 -0
  9. package/dist/LayoutSession-CTZB90NX.cjs.map +1 -0
  10. package/dist/LayoutSession-CWn3sdbs.js +3967 -0
  11. package/dist/LayoutSession-CWn3sdbs.js.map +1 -0
  12. package/dist/PaneManager.d.ts.map +1 -1
  13. package/dist/ThemeManager.d.ts +5 -1
  14. package/dist/ThemeManager.d.ts.map +1 -1
  15. package/dist/chartA11y.d.ts +59 -0
  16. package/dist/chartA11y.d.ts.map +1 -0
  17. package/dist/charts/ChartTypeStrategy.d.ts +11 -4
  18. package/dist/charts/ChartTypeStrategy.d.ts.map +1 -1
  19. package/dist/grid/ChartGrid.d.ts +7 -1
  20. package/dist/grid/ChartGrid.d.ts.map +1 -1
  21. package/dist/i18n-CiQ8EDVs.js +1469 -0
  22. package/dist/i18n-CiQ8EDVs.js.map +1 -0
  23. package/dist/i18n-WsLA9SmD.cjs +2 -0
  24. package/dist/i18n-WsLA9SmD.cjs.map +1 -0
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.ts +24 -3
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +74 -89
  30. package/dist/index.js.map +1 -1
  31. package/dist/indicatorLabel.d.ts +7 -0
  32. package/dist/indicatorLabel.d.ts.map +1 -0
  33. package/dist/layout/LayoutManager.d.ts +50 -0
  34. package/dist/layout/LayoutManager.d.ts.map +1 -1
  35. package/dist/layout/priceAxisWidth.d.ts +2 -0
  36. package/dist/layout/priceAxisWidth.d.ts.map +1 -1
  37. package/dist/regularHours.d.ts +10 -0
  38. package/dist/regularHours.d.ts.map +1 -0
  39. package/dist/state/LayoutSession.d.ts +101 -0
  40. package/dist/state/LayoutSession.d.ts.map +1 -0
  41. package/dist/state/layoutStorage.d.ts +46 -0
  42. package/dist/state/layoutStorage.d.ts.map +1 -0
  43. package/dist/trading/wireExecution.d.ts +7 -3
  44. package/dist/trading/wireExecution.d.ts.map +1 -1
  45. package/dist/widget/ChartWidget.d.ts +283 -10
  46. package/dist/widget/ChartWidget.d.ts.map +1 -1
  47. package/dist/widget/ChartWidgetGrid.d.ts +166 -0
  48. package/dist/widget/ChartWidgetGrid.d.ts.map +1 -0
  49. package/dist/widget/DrawingTemplateStore.d.ts +29 -8
  50. package/dist/widget/DrawingTemplateStore.d.ts.map +1 -1
  51. package/dist/widget/WatchlistStore.d.ts +65 -0
  52. package/dist/widget/WatchlistStore.d.ts.map +1 -0
  53. package/dist/widget/WidgetAccountPanel.d.ts +72 -0
  54. package/dist/widget/WidgetAccountPanel.d.ts.map +1 -0
  55. package/dist/widget/WidgetAlertsPanel.d.ts +50 -3
  56. package/dist/widget/WidgetAlertsPanel.d.ts.map +1 -1
  57. package/dist/widget/WidgetBracketBar.d.ts +3 -1
  58. package/dist/widget/WidgetBracketBar.d.ts.map +1 -1
  59. package/dist/widget/WidgetChartNav.d.ts +36 -0
  60. package/dist/widget/WidgetChartNav.d.ts.map +1 -0
  61. package/dist/widget/WidgetCommandPalette.d.ts +5 -1
  62. package/dist/widget/WidgetCommandPalette.d.ts.map +1 -1
  63. package/dist/widget/WidgetContextMenu.d.ts +40 -0
  64. package/dist/widget/WidgetContextMenu.d.ts.map +1 -0
  65. package/dist/widget/WidgetDataWindow.d.ts +3 -1
  66. package/dist/widget/WidgetDataWindow.d.ts.map +1 -1
  67. package/dist/widget/WidgetDepthLadder.d.ts +3 -1
  68. package/dist/widget/WidgetDepthLadder.d.ts.map +1 -1
  69. package/dist/widget/WidgetDrawingSettings.d.ts +108 -0
  70. package/dist/widget/WidgetDrawingSettings.d.ts.map +1 -0
  71. package/dist/widget/WidgetDrawingSidebar.d.ts +26 -1
  72. package/dist/widget/WidgetDrawingSidebar.d.ts.map +1 -1
  73. package/dist/widget/WidgetDrawingStyle.d.ts +3 -1
  74. package/dist/widget/WidgetDrawingStyle.d.ts.map +1 -1
  75. package/dist/widget/WidgetDropdown.d.ts.map +1 -1
  76. package/dist/widget/WidgetGoToDate.d.ts +46 -0
  77. package/dist/widget/WidgetGoToDate.d.ts.map +1 -0
  78. package/dist/widget/WidgetHistoryPill.d.ts +23 -0
  79. package/dist/widget/WidgetHistoryPill.d.ts.map +1 -0
  80. package/dist/widget/WidgetHotkeySheet.d.ts +3 -1
  81. package/dist/widget/WidgetHotkeySheet.d.ts.map +1 -1
  82. package/dist/widget/WidgetIndicatorLegend.d.ts +98 -0
  83. package/dist/widget/WidgetIndicatorLegend.d.ts.map +1 -0
  84. package/dist/widget/WidgetIndicatorSettings.d.ts +62 -7
  85. package/dist/widget/WidgetIndicatorSettings.d.ts.map +1 -1
  86. package/dist/widget/WidgetIntervalInput.d.ts +34 -0
  87. package/dist/widget/WidgetIntervalInput.d.ts.map +1 -0
  88. package/dist/widget/WidgetLayoutsDialog.d.ts +39 -0
  89. package/dist/widget/WidgetLayoutsDialog.d.ts.map +1 -0
  90. package/dist/widget/WidgetLayoutsUI.d.ts +37 -0
  91. package/dist/widget/WidgetLayoutsUI.d.ts.map +1 -0
  92. package/dist/widget/WidgetLoadingOverlay.d.ts.map +1 -1
  93. package/dist/widget/WidgetNamePrompt.d.ts +31 -0
  94. package/dist/widget/WidgetNamePrompt.d.ts.map +1 -0
  95. package/dist/widget/WidgetObjectTree.d.ts +21 -3
  96. package/dist/widget/WidgetObjectTree.d.ts.map +1 -1
  97. package/dist/widget/WidgetOrderTicket.d.ts +49 -0
  98. package/dist/widget/WidgetOrderTicket.d.ts.map +1 -0
  99. package/dist/widget/WidgetReplayBar.d.ts +52 -7
  100. package/dist/widget/WidgetReplayBar.d.ts.map +1 -1
  101. package/dist/widget/WidgetSettings.d.ts +26 -2
  102. package/dist/widget/WidgetSettings.d.ts.map +1 -1
  103. package/dist/widget/WidgetStatusBar.d.ts +19 -1
  104. package/dist/widget/WidgetStatusBar.d.ts.map +1 -1
  105. package/dist/widget/WidgetStyles.d.ts +3 -1
  106. package/dist/widget/WidgetStyles.d.ts.map +1 -1
  107. package/dist/widget/WidgetSymbolInfo.d.ts +64 -0
  108. package/dist/widget/WidgetSymbolInfo.d.ts.map +1 -0
  109. package/dist/widget/WidgetSymbolSearch.d.ts +28 -5
  110. package/dist/widget/WidgetSymbolSearch.d.ts.map +1 -1
  111. package/dist/widget/WidgetToolbar.d.ts +42 -4
  112. package/dist/widget/WidgetToolbar.d.ts.map +1 -1
  113. package/dist/widget/WidgetTooltip.d.ts +43 -0
  114. package/dist/widget/WidgetTooltip.d.ts.map +1 -0
  115. package/dist/widget/WidgetWatchlist.d.ts +53 -13
  116. package/dist/widget/WidgetWatchlist.d.ts.map +1 -1
  117. package/dist/widget/chartMenu.d.ts +40 -0
  118. package/dist/widget/chartMenu.d.ts.map +1 -0
  119. package/dist/widget/drawingMenu.d.ts +21 -0
  120. package/dist/widget/drawingMenu.d.ts.map +1 -0
  121. package/dist/widget/escapeHtml.d.ts +3 -0
  122. package/dist/widget/escapeHtml.d.ts.map +1 -0
  123. package/dist/widget/focusTrap.d.ts +8 -0
  124. package/dist/widget/focusTrap.d.ts.map +1 -0
  125. package/dist/widget/i18n.d.ts +20 -63
  126. package/dist/widget/i18n.d.ts.map +1 -1
  127. package/dist/widget/iconSet.d.ts +26 -0
  128. package/dist/widget/iconSet.d.ts.map +1 -0
  129. package/dist/widget/icons.d.ts +5 -0
  130. package/dist/widget/icons.d.ts.map +1 -1
  131. package/dist/widget/index.cjs +2145 -405
  132. package/dist/widget/index.cjs.map +1 -1
  133. package/dist/widget/index.d.ts +18 -1
  134. package/dist/widget/index.d.ts.map +1 -1
  135. package/dist/widget/index.js +7376 -1274
  136. package/dist/widget/index.js.map +1 -1
  137. package/dist/widget/indicatorTemplates.d.ts +24 -0
  138. package/dist/widget/indicatorTemplates.d.ts.map +1 -0
  139. package/dist/widget/keyTarget.d.ts +11 -0
  140. package/dist/widget/keyTarget.d.ts.map +1 -0
  141. package/dist/widget/legendValues.d.ts +19 -0
  142. package/dist/widget/legendValues.d.ts.map +1 -0
  143. package/dist/widget/locales/ar.d.ts +4 -0
  144. package/dist/widget/locales/ar.d.ts.map +1 -0
  145. package/dist/widget/locales/de.d.ts +4 -0
  146. package/dist/widget/locales/de.d.ts.map +1 -0
  147. package/dist/widget/locales/en.d.ts +722 -0
  148. package/dist/widget/locales/en.d.ts.map +1 -0
  149. package/dist/widget/locales/es.d.ts +4 -0
  150. package/dist/widget/locales/es.d.ts.map +1 -0
  151. package/dist/widget/locales/fr.d.ts +4 -0
  152. package/dist/widget/locales/fr.d.ts.map +1 -0
  153. package/dist/widget/locales/he.d.ts +4 -0
  154. package/dist/widget/locales/he.d.ts.map +1 -0
  155. package/dist/widget/locales/id.d.ts +4 -0
  156. package/dist/widget/locales/id.d.ts.map +1 -0
  157. package/dist/widget/locales/index.cjs +2 -0
  158. package/dist/widget/locales/index.cjs.map +1 -0
  159. package/dist/widget/locales/index.d.ts +33 -0
  160. package/dist/widget/locales/index.d.ts.map +1 -0
  161. package/dist/widget/locales/index.js +10089 -0
  162. package/dist/widget/locales/index.js.map +1 -0
  163. package/dist/widget/locales/ja.d.ts +4 -0
  164. package/dist/widget/locales/ja.d.ts.map +1 -0
  165. package/dist/widget/locales/ko.d.ts +4 -0
  166. package/dist/widget/locales/ko.d.ts.map +1 -0
  167. package/dist/widget/locales/pt.d.ts +4 -0
  168. package/dist/widget/locales/pt.d.ts.map +1 -0
  169. package/dist/widget/locales/ru.d.ts +4 -0
  170. package/dist/widget/locales/ru.d.ts.map +1 -0
  171. package/dist/widget/locales/th.d.ts +4 -0
  172. package/dist/widget/locales/th.d.ts.map +1 -0
  173. package/dist/widget/locales/tr.d.ts +4 -0
  174. package/dist/widget/locales/tr.d.ts.map +1 -0
  175. package/dist/widget/locales/vi.d.ts +4 -0
  176. package/dist/widget/locales/vi.d.ts.map +1 -0
  177. package/dist/widget/locales/zh.d.ts +4 -0
  178. package/dist/widget/locales/zh.d.ts.map +1 -0
  179. package/dist/widget/locales/zhHant.d.ts +4 -0
  180. package/dist/widget/locales/zhHant.d.ts.map +1 -0
  181. package/dist/widget/orderTicket.d.ts +27 -0
  182. package/dist/widget/orderTicket.d.ts.map +1 -0
  183. package/dist/widget/settingsControls.d.ts +24 -0
  184. package/dist/widget/settingsControls.d.ts.map +1 -0
  185. package/dist/widget/types.d.ts +215 -13
  186. package/dist/widget/types.d.ts.map +1 -1
  187. package/dist/widget/widgetConfig.d.ts +1 -5
  188. package/dist/widget/widgetConfig.d.ts.map +1 -1
  189. package/dist/widget/widgetLayout.d.ts +22 -0
  190. package/dist/widget/widgetLayout.d.ts.map +1 -0
  191. package/dist/widget/widgetLocales.d.ts +17 -0
  192. package/dist/widget/widgetLocales.d.ts.map +1 -0
  193. package/dist/widget/widgetTimeframes.d.ts +28 -0
  194. package/dist/widget/widgetTimeframes.d.ts.map +1 -0
  195. package/dist/widget/widgetTimezones.d.ts +32 -0
  196. package/dist/widget/widgetTimezones.d.ts.map +1 -0
  197. package/dist/widget/widgetUI.d.ts +126 -0
  198. package/dist/widget/widgetUI.d.ts.map +1 -0
  199. package/package.json +8 -3
  200. package/dist/DragDropImporter-BazeSQPD.cjs +0 -2
  201. package/dist/DragDropImporter-BazeSQPD.cjs.map +0 -1
  202. package/dist/DragDropImporter-cURSpfUb.js +0 -1883
  203. package/dist/DragDropImporter-cURSpfUb.js.map +0 -1
  204. package/dist/charts/IndicatorPriceRange.d.ts +0 -20
  205. package/dist/charts/IndicatorPriceRange.d.ts.map +0 -1
package/README.md CHANGED
@@ -9,20 +9,24 @@ High-performance canvas trading chart with built-in indicators, drawing tools, a
9
9
  Most chart libraries make you choose: pretty charts with no trading features, or trading features with an ugly API. TradeCanvas gives you both.
10
10
 
11
11
  - **70 built-in indicators** — SMA, EMA, TEMA, VWMA, Hull MA, RSI, MACD, Bollinger, Envelope, Ichimoku, Pivot Points, Anchored VWAP, ZigZag, Linear Regression Channel, Awesome / Chaikin Oscillator, and more. No separate calculation library needed.
12
- - **40 drawing tools** — Trendlines (info line, trend angle, cross line), Fibonacci (retracement, extension, channel, time zones, speed resistance fan), horizontal/vertical lines, channels, pitchforks (Andrews, Schiff, modified Schiff), Gann fans / boxes, cyclic lines, harmonic patterns (XABCD, ABCD, head and shoulders, Elliott waves), date & price range, Long/Short Position, Volume Profile range. With undo/redo and full serialization.
13
- - **17 chart types** — Candlestick, line, area, bar, hollow candle, baseline, Heikin-Ashi, Renko, Kagi, Line Break, Point & Figure, Range Bars, Volume Candles, **Equivolume**, HLC Area, Step Line, Line+Markers.
12
+ - **69 drawing tools** — Trendlines (info line, trend angle, cross line), Fibonacci (retracement, extension, channel, time zones, speed resistance fan and arcs, circles, spiral, wedge), horizontal/vertical lines, channels, pitchforks and pitchfan, Gann fan / box / square, cycles, harmonic patterns (XABCD, cypher, ABCD, three drives, head and shoulders), Elliott waves, notes, callouts and marks, brush and path, forecast and projection, Long/Short Position with position sizing, Volume Profile range. Each with its own settings, alerts on trend lines, groups and layers, undo/redo and full serialization.
13
+ - **18 chart types** — Candlestick, line, area, bar, hollow candle, baseline, High-Low, Heikin-Ashi, Renko, Kagi, Line Break, Point & Figure, Range Bars, Volume Candles, **Equivolume**, HLC Area, Step Line, Line+Markers. Renko's box, Kagi's reversal and the like are yours to set.
14
14
  - **Pro-grade interaction** — pan freely past the last bar into empty future space (drawings can go there too), drag the price/time axes to scale, double-click to auto-fit, `Ctrl/⌘+drag` to select several drawings (then move, restyle or delete them together), `Shift+drag` to measure (bars × price Δ × %), `Alt+click` to pin a comparison tooltip, context cursors (crosshair, grabbing hand, resize arrows), axis-following price/time pill labels under the cursor, bar-hover highlight.
15
- - **Trading overlay** — Render open positions with entry line, P&L zone, and SL/TP markers. Orders as dashed lines. Drag SL/TP to modify. Cleanly opt-out via `features.trading: false` for non-trading projects.
15
+ - **Trading overlay** — Render open positions with entry line, P&L zone, and SL/TP markers. Orders as dashed lines. Drag SL/TP to modify, cancel / close / reverse from the buttons on each line, and see every fill marked on its bar. ChartWidget adds an order ticket that checks the order as you fill it in, and an account panel with positions, working orders and history. Cleanly opt-out via `features.trading: false` for non-trading projects.
16
16
  - **Real-time streaming** — Built-in Binance adapter. Plug in your own data source with the adapter interface.
17
17
  - **Strategy backtester** — `@tradecanvas/analytics` ships a bar-by-bar `Backtester` with virtual fills, commission/slippage models, portfolio tracking, and risk metrics (Sharpe, Sortino, Calmar, max drawdown). **Now with 4 ready-to-use reference strategies + Monte Carlo path-dependence analysis.**
18
- - **Replay mode** — `ReplayController` drives historical bars forward at controlled speed with start / pause / step / seek / setSpeed. *(new in 0.9)* The widget now ships a floating bottom scrubber UI (play/pause/step/seek + 0.5×–100× speed) on top of it.
18
+ - **Replay mode** — replay the chart's own bars from any point, in finer steps if you like (an hourly chart forming from 5-minute bars), with play / pause / step / seek / speed, and paper-trade on the replayed prices. The widget has a replay bar for it; `ReplayController` drives bars headless too.
19
+ - **Alerts** — on a price level, an indicator line, a drawing, or one line crossing another; on a move of some percent within some bars; only on closed bars; with an expiry. The widget's alerts panel sets all of them.
20
+ - **Compare and spread** — other symbols in percent on the price scale, on a scale or pane of their own, or as a spread or ratio, lined up with the chart by time.
21
+ - **Price formats** — prices in your own format or in fractions of a point (a bond in 32nds: 110'165) on every label; times your way; extended hours on or off; data export with the indicator lines.
19
22
  - **Volume Profile** *(new in 0.9)* — optional horizontal histogram of traded volume bucketed by price over the visible range, with point-of-control highlighting.
20
23
  - **Watchlist sidebar** *(new in 0.9)* — opt-in vertical panel listing symbols with last price, % change, mini sparkline. Click a row to switch chart.
21
24
  - **CSV / JSON drag-and-drop** *(new in 0.9)* — drop a file onto the chart, it parses and loads instantly. Detects header layouts, ISO/unix-s/unix-ms timestamps, and array-vs-object JSON shapes.
22
- - **Saved layouts** *(new in 0.9)* — opt-in per-symbol persistence of chart type + indicator stack + drawings + alerts to localStorage. Switch symbol, switch back, your setup is intact.
23
- - **Multi-chart grid** — `ChartGrid` for synchronized 2×2 / 2×3 layouts with linked crosshairs and shared time axis.
25
+ - **Named layouts** — save the chart under a name (symbol, interval, scale, indicators, drawings, alerts), open, rename, delete, auto-save the open one, `Ctrl/⌘+S`. Kept in the browser, or on your server through a four-call `LayoutStorage`. Per-symbol auto-persistence (`persistLayouts`) is there too.
26
+ - **Multi-chart** — `ChartWidgetGrid` puts up to six full widgets side by side, linked by symbol, interval, crosshair, time or drawings as you choose, and saves them as one layout. `ChartGrid` does the same for bare charts.
24
27
  - **Signal markers & trade zones** — render bot/algorithm output (directional arrows, entry→exit rectangles) as a first-class chart layer.
25
28
  - **Hotkey sheet** *(new in 0.9)* — press `?` in the widget to open a categorized keyboard-shortcut reference.
29
+ - **Extensible widget** — add your own toolbar buttons and right-click menu entries (`addToolbarButton`, `chartMenuItems`).
26
30
  - **Save/load chart state** — Persist drawings, indicators, theme, and chart type to JSON. Restore with one call.
27
31
  - **Zero dependencies** — The entire library is self-contained. No `d3`, no `chart.js`, no `fancy-canvas`.
28
32
 
@@ -53,7 +57,7 @@ const widget = new ChartWidget(document.getElementById('chart')!, {
53
57
  })
54
58
  ```
55
59
 
56
- That's it. Live data, all 70 indicators, all 40 drawing tools, command palette (`Ctrl+K`), symbol search (`Ctrl+P`), hotkey sheet (`?`), shift-drag measure, alt-click tooltip pin, and drag-drop CSV/JSON loading.
60
+ That's it. Live data, all 95 indicators, all 69 drawing tools, command palette (`Ctrl+K`), symbol search (`Ctrl+P`), hotkey sheet (`?`), shift-drag measure, alt-click tooltip pin, and drag-drop CSV/JSON loading.
57
61
 
58
62
  ## Headless Chart
59
63
 
@@ -91,9 +95,12 @@ chart.connect({ adapter, symbol: 'BTCUSDT', timeframe: '5m', historyLimit: 300 }
91
95
  | `settings` | `boolean` | `true` | Show settings button |
92
96
  | `trading` | `boolean` | `true` | Enable trading overlay |
93
97
  | `statusBar` | `boolean` | `true` | Show bottom status bar |
98
+ | `rangeBar` | `boolean` | `true` | Range presets (1D … All) and go to date (Alt+G) on the status bar |
99
+ | `indicatorLegend` | `boolean` | `true` | Indicators listed on the chart (under the OHLCV legend and atop their panes) with show / settings / remove |
100
+ | `fullscreen` | `boolean` | `true` | Fullscreen button in the toolbar |
94
101
  | `symbols` | `string[]` | BTC/ETH/SOL/BNB | Searchable symbol catalog |
95
- | `timeframes` | `TimeFrame[]` | 1m to 1d | Available timeframes |
96
- | `chartTypes` | `ChartType[]` | 11 types | Available chart types |
102
+ | `timeframes` | `TimeFrame[]` | 1m to 1M | Timeframes on offer; pin favourites from the ▾ menu |
103
+ | `chartTypes` | `ChartType[]` | 18 types | Available chart types |
97
104
  | `watchlist` | `boolean` | `false` | Right-side watchlist sidebar |
98
105
  | `dragDropImport` | `boolean` | `true` | Drop CSV / JSON files onto the chart to load data |
99
106
  | `persistLayouts` | `boolean \| { keyPrefix, debounceMs }` | `false` | Save per-symbol indicators / drawings / chart type to localStorage |
@@ -103,6 +110,17 @@ chart.connect({ adapter, symbol: 'BTCUSDT', timeframe: '5m', historyLimit: 300 }
103
110
  | `locale` | `string` | `'en'` | UI chrome language — built-in `'en'` / `'vi'`, see **Widget i18n** below |
104
111
  | `messages` | `Partial<Record<MessageKey, string>>` | — | Override or add individual UI strings on top of `locale` |
105
112
 
113
+ ### Icons
114
+
115
+ The widget's icon set is exported for your own UI: `createIcon(name)`,
116
+ `createToolIcon(drawingTool)`, `createChartTypeIcon(chartType)` return inline
117
+ SVG strings drawn in `currentColor` (24 px grid, 1.75 px strokes).
118
+
119
+ ```ts
120
+ import { createToolIcon } from '@tradecanvas/chart/widget'
121
+ button.innerHTML = createToolIcon('fibRetracement', 16)
122
+ ```
123
+
106
124
  ### Widget i18n
107
125
 
108
126
  `locale` and `messages` translate `ChartWidget`'s own chrome — toolbar, watchlist, indicator-picker section headers (Popular/All, overlay/panel tags), status bar, settings panel (titles/tabs/section headers), and hotkey sheet (title/group headers). Set at construction; not currently hot-swappable at runtime.
@@ -136,6 +154,17 @@ See `packages/library/src/widget/i18n.ts` for the full key list (`MessageKey`) a
136
154
  | Customization | Full control | Toggle sections on/off |
137
155
  | Advanced access | Direct API | `widget.getChart()` for direct API |
138
156
 
157
+ ### Widget Look
158
+
159
+ The widget's shapes and sizes — corners, control heights, type, borders, shadows, how a chosen button shows, bars docked or floating — are a look of their own, apart from the colours. Three presets: **Studio** (the default), **Terminal** (dense and square) and **Capsule** (pills, floating bars). Start from one and change what you like:
160
+
161
+ ```ts
162
+ const widget = new ChartWidget(host, { ui: 'terminal' });
163
+ widget.setUI({ preset: 'studio', radius: { md: 10 }, density: 'compact', toolbar: 'floating', active: 'solid' });
164
+ ```
165
+
166
+ The chart's price tags take the same corners (`tagRadius`; on a bare `Chart`, `chart.setShapes({ tagRadius })`). The widget loads no fonts: load the ones a look names. See [Styling](https://bonguynvan.github.io/tradecanvas/docs/styling).
167
+
139
168
  ### Widget Theming
140
169
 
141
170
  `ChartWidget`'s own chrome (toolbar, sidebars, settings panel, watchlist — everything *outside* the canvas) is styled entirely through CSS custom properties on `.tcw-root`, the widget's own root element. These are a **stable, documented contract**: additive-only across minor/patch releases — a property is never renamed or removed without a major version bump. Override them from the host page; no build step or theme object needed.
@@ -175,12 +204,19 @@ See `packages/library/src/widget/i18n.ts` for the full key list (`MessageKey`) a
175
204
  | `--tcw-divider` | `rgba(255,255,255,.06)` | Hairline dividers |
176
205
  | `--tcw-ease` / `--tcw-ease-out` | cubic-bezier | Transition easing |
177
206
  | `--tcw-dur-fast` / `-normal` / `-slow` | `120ms` / `180ms` / `260ms` | Transition durations |
178
- | `--tcw-radius-sm` / `-base` / `-lg` / `-xl` | `4px` / `6px` / `10px` / `14px` | Corner radii — set to `0` for a square look |
207
+ | `--tcw-radius-xs` / `-sm` / `--tcw-radius` / `-lg` / `-xl` | `3px` / `5px` / `7px` / `11px` / `16px` | The corner scale — set to `0` for a square look |
208
+ | `--tcw-control-radius` / `--tcw-input-radius` / `--tcw-menu-radius` / `--tcw-dialog-radius` / `--tcw-panel-radius` / `--tcw-tooltip-radius` / `--tcw-tag-radius` / `--tcw-toast-radius` | from the scale | Each kind of part's corners |
209
+ | `--tcw-toolbar-h` / `--tcw-control-h` / `--tcw-control-h-sm` / `--tcw-icon` / `--tcw-sidebar-w` / `--tcw-menu-item-h` | `46px` / `30px` / `24px` / `18px` / `48px` / `30px` | Sizes |
210
+ | `--tcw-font` / `--tcw-font-size` / `--tcw-weight` / `--tcw-weight-strong` | `'Manrope', 'Inter', …` / `13px` / `500` / `600` | Type |
211
+ | `--tcw-label-case` / `--tcw-label-tracking` | `none` / `0em` | Small labels (section titles) |
212
+ | `--tcw-border-w` / `--tcw-sep-w` | `1px` / `0px` | Border width; rules between toolbar groups |
213
+ | `--tcw-menu-shadow` / `--tcw-dialog-shadow` / `--tcw-tooltip-shadow` | the elevation shadows | Shadows of menus, dialogs, tooltips |
214
+ | `--tcw-blur` / `--tcw-surface-opacity` | `0px` / `100%` | Frosted menus |
179
215
  | `--tcw-shadow-sm` / `-md` / `-lg` / `-xl` | box-shadow values | Elevation |
180
216
  | `--tcw-ring` | `0 0 0 2px rgba(242,169,59,.45)` | Focus ring |
181
217
  | `--tcw-font-mono` | `'JetBrains Mono', …` | Monospace font stack (price ladder, code) |
182
218
 
183
- Light theme (`[data-tcw-theme="light"]`) redefines the color group (`--tcw-bg*`, `--tcw-border*`, `--tcw-text*`, `--tcw-accent*`, `--tcw-hover-bg`, `--tcw-active-bg`, `--tcw-divider`, `--tcw-shadow*`) with its own defaults — override both selectors if you support both themes.
219
+ Light theme (`[data-tcw-theme="light"]`) redefines the color group (`--tcw-bg*`, `--tcw-border*`, `--tcw-text*`, `--tcw-accent*`, `--tcw-hover-bg`, `--tcw-active-bg`, `--tcw-divider`, `--tcw-shadow*`) with its own defaults — override both selectors if you support both themes. With the `ui` option set, the widget writes its look's variables on the element, so they win over your CSS; without it they stay yours to set.
184
220
 
185
221
  ## Features
186
222
 
@@ -219,8 +255,22 @@ const grid = new ChartGrid(document.getElementById('grid')!, {
219
255
  syncTimeAxis: true,
220
256
  })
221
257
 
222
- const adapter = new BinanceAdapter()
223
- grid.connectAll(adapter, ['BTCUSDT', 'ETHUSDT', 'SOLUSDT', 'BNBUSDT'], '5m')
258
+ // An adapter keeps one stream: give each chart its own
259
+ grid.connectAll(() => new BinanceAdapter(), ['BTCUSDT', 'ETHUSDT', 'SOLUSDT', 'BNBUSDT'], '5m')
260
+ ```
261
+
262
+ With the full widget on each chart, a bar to pick the arrangement and sync, and the whole grid saved as a named layout:
263
+
264
+ ```typescript
265
+ import { ChartWidgetGrid } from '@tradecanvas/chart/widget'
266
+
267
+ const workspace = new ChartWidgetGrid(document.getElementById('grid')!, {
268
+ layout: '1x2',
269
+ adapter: () => new BinanceAdapter(),
270
+ cells: [{ symbol: 'BTCUSDT' }, { symbol: 'ETHUSDT', timeframe: '1h' }],
271
+ sync: { crosshair: true, interval: false, symbol: false, time: false, drawings: false },
272
+ })
273
+ workspace.setSync({ time: true })
224
274
  ```
225
275
 
226
276
  Supported layouts: `'1x1'`, `'1x2'`, `'2x1'`, `'2x2'`, `'1x3'`, `'3x1'`, `'2x3'`, `'3x2'`.
@@ -286,13 +336,34 @@ gauge.setValue(85) // animates smoothly
286
336
 
287
337
  ### Indicators (built-in)
288
338
 
289
- **Overlay** (drawn on the price chart):
290
- SMA, EMA, Hull MA, Bollinger Bands, Keltner Channel, Donchian Channel, Ichimoku Cloud, Parabolic SAR, Supertrend, VWAP, Anchored VWAP, Pivot Points (Classic), ZigZag, Linear Regression Channel
339
+ 95 indicators — moving averages (SMA, EMA, WMA, Hull, DEMA, TEMA, ALMA, KAMA,
340
+ LSMA, McGinley, SMMA, MA Cross, MTF MA), bands and channels (Bollinger,
341
+ Keltner, Donchian, Envelope, Linear Regression), trend and stops (Ichimoku,
342
+ Supertrend, Parabolic SAR, Chandelier, Chande Kroll Stop, Alligator, ZigZag,
343
+ Fractals, Pivot Points), VWAPs and Volume Profile on the price pane; RSI, MACD,
344
+ Stochastic, ATR, ADX, CCI, OBV, MFI, Bollinger %B and BandWidth, Historical
345
+ Volatility, Ulcer Index and 40 more oscillators, volume and volatility
346
+ indicators in panes. The [indicator catalog](https://bonguynvan.github.io/tradecanvas/docs/indicators)
347
+ lists every id with its inputs, lines and levels.
348
+
349
+ ```typescript
350
+ import { indicatorSource } from '@tradecanvas/chart'
351
+
352
+ const rsi = chart.addIndicator('rsi', { period: 14 })!
353
+ chart.addIndicator('ema', { period: 21, source: 'hlc3' }) // another price
354
+ chart.addIndicator('sma', { period: 9, source: indicatorSource(rsi, 'value') }) // RSI's own average, in RSI's pane
355
+ chart.setIndicatorLevels(rsi, [20, 50, 80])
356
+ ```
291
357
 
292
- **Panel** (separate sub-chart):
293
- RSI, MACD, Stochastic, ATR, ADX, CCI, CMF, MFI, OBV, ROC, TSI, Williams %R, Awesome Oscillator, Chaikin Oscillator, Volume Profile, VROC, Standard Deviation, Accumulation/Distribution, Aroon
358
+ - **Sources**: close, open, high, low, hl2, hlc3, ohlc4, hlcc4, or another indicator's line.
359
+ - **Panes**: one value scale per pane for lines, levels, axis and crosshair; move an indicator into another pane, a new one or back to the price pane; fold, maximise and reorder panes (`moveIndicatorToPane`, `setPaneCollapsed`, `setMaximizedPane`, `movePane`).
360
+ - **Undo and templates**: Ctrl/Cmd+Z undoes indicator changes, in the same history as drawings; ChartWidget saves the indicators as named templates (`getIndicatorSetup` / `applyIndicatorSetup`).
361
+ - **Levels**: editable per instance (RSI 30/70, CCI ±100 …), kept in saved layouts.
362
+ - **Value tags**: each line's latest value on its axis, in its colour.
363
+ - **Custom indicators** declare their lines (`plots`), scale, levels and inputs; the chart draws and labels them.
294
364
 
295
- All indicator parameters are validated at runtime — invalid values (NaN, Infinity, non-numeric strings, missing keys) fall back to documented defaults instead of silently propagating to calculations.
365
+ Invalid parameters (NaN, Infinity, non-numeric strings, missing keys) fall back
366
+ to the defaults instead of reaching the calculations.
296
367
 
297
368
  ### Drawing Tools
298
369
 
@@ -346,6 +417,11 @@ chart.setTradingConfig({
346
417
  // Listen for user drag-to-modify
347
418
  chart.on('positionModify', (e) => console.log('SL/TP moved:', e.payload))
348
419
  chart.on('orderModify', (e) => console.log('Order moved:', e.payload))
420
+
421
+ // The × and ⇅ buttons on the lines raise these; so can your own UI
422
+ chart.cancelOrderIntent('order-1')
423
+ chart.reversePositionIntent('pos-1')
424
+ chart.on('executionFill', (e) => console.log(e.payload.reason, e.payload.pnl))
349
425
  ```
350
426
 
351
427
  ### Signal Markers
@@ -413,43 +489,21 @@ chart.updateLastBar(updatedBar)
413
489
  chart.setCurrentPrice(3500.42)
414
490
  ```
415
491
 
416
- ### Web Worker indicator pipeline
417
-
418
- Heavy charts (1,000+ bars × 10+ indicators) can stutter when `calculate()` runs on the main thread. `IndicatorWorkerHost` offloads calculation to a worker so the render loop stays smooth.
492
+ ### Indicators outside the chart
419
493
 
420
- ```typescript
421
- import { IndicatorWorkerHost } from '@tradecanvas/core'
422
-
423
- // Bundler-supported worker URL (Vite, webpack 5, esbuild, etc.)
424
- const worker = new Worker(
425
- new URL('@tradecanvas/core/dist/indicator.worker.js', import.meta.url),
426
- { type: 'module' },
427
- )
428
- const host = new IndicatorWorkerHost(worker, { timeoutMs: 30_000 })
429
-
430
- const output = await host.calculate(
431
- 'rsi',
432
- { id: 'rsi', instanceId: 'rsi-1', params: { period: 14 } },
433
- bars,
434
- )
435
-
436
- // Health check / cleanup
437
- await host.ping()
438
- host.terminate()
439
- ```
440
-
441
- No worker available (SSR, tests, or as a safety net)? Pass `null` and register fallback plugins for synchronous calculation:
494
+ `IndicatorWorkerHost` computes an indicator from bars with the same messages a
495
+ Web Worker would use. The worker script is not part of the published packages
496
+ yet; pass `null` and register the plugins to compute in place (SSR, tests,
497
+ scripts):
442
498
 
443
499
  ```typescript
444
500
  import { IndicatorWorkerHost, RSIIndicator } from '@tradecanvas/core'
445
501
 
446
502
  const host = new IndicatorWorkerHost(null)
447
503
  host.registerFallbackPlugin(new RSIIndicator())
448
- const output = await host.calculate('rsi', config, bars) // runs synchronously
504
+ const output = await host.calculate('rsi', { id: 'rsi', instanceId: 'rsi-1', params: { period: 14 } }, bars)
449
505
  ```
450
506
 
451
- Render still happens on the main thread (it needs `CanvasRenderingContext2D`). Only the heavy compute moves off-thread.
452
-
453
507
  ### Save / Load
454
508
 
455
509
  ```typescript
@@ -461,8 +515,14 @@ chart.loadState(localStorage.getItem('my-chart')!)
461
515
  // Download / upload files
462
516
  chart.downloadState('my-chart.json')
463
517
  await chart.loadStateFromFile()
518
+
519
+ // Or keep a layout saved as it changes (debounced)
520
+ chart.setAutoSave('my-chart', 1500)
464
521
  ```
465
522
 
523
+ A saved layout holds the chart type, theme, drawings, indicators (inputs, pane,
524
+ colours, visibility) and alerts, including alerts on indicator lines.
525
+
466
526
  ### Themes
467
527
 
468
528
  ```typescript
@@ -483,7 +543,12 @@ chart.setTheme({
483
543
  ### Events
484
544
 
485
545
  ```typescript
486
- chart.on('crosshairMove', (e) => { /* { point, bar, barIndex, indicatorValues } */ })
546
+ chart.on('crosshairMove', (e) => { /* { point, bar, barIndex, indicatorValues } — also over indicator panes */ })
547
+ chart.on('crosshairLeave', () => { /* the pointer left the plot */ })
548
+ chart.on('drawingToolChange', (e) => { /* { tool } — null once a drawing is finished or cancelled */ })
549
+ chart.on('indicatorUpdate', (e) => { /* { from } — indicator values recomputed from this bar on */ })
550
+ chart.on('paneResize', (e) => { /* { instanceId, size } — an indicator pane was resized */ })
551
+ chart.on('indicatorChange', (e) => { /* { instanceId, change } — shown/hidden, restyled, levels, inputs or pane changed */ })
487
552
  chart.on('barClick', (e) => { /* { bar, barIndex, point } */ })
488
553
  chart.on('visibleRangeChange', (e) => { /* { from, to } — bar indices, not timestamps */ })
489
554
  chart.on('priceRangeChange', (e) => { /* { min, max } — visible price bounds */ })
@@ -626,7 +691,7 @@ mc.worstMaxDrawdownPct
626
691
 
627
692
  | Feature | @tradecanvas/chart | lightweight-charts | chart.js | Highcharts Stock |
628
693
  |---|---|---|---|---|
629
- | Chart types | 17 + 6 finance | 4 | 8 (non-financial) | 10+ |
694
+ | Chart types | 18 + 6 finance | 4 | 8 (non-financial) | 10+ |
630
695
  | Finance charts | Sparkline, Depth, Equity, Heatmap, Waterfall, Gauge | None | None | Some |
631
696
  | Built-in indicators | 33 | 0 | 0 | ~30 |
632
697
  | Drawing tools | 24 | 0 | 0 | Some |
@@ -683,7 +748,13 @@ chart.setNumberLocale('de-DE') // 65.234,00
683
748
  | `setVolumeProfileVisible(v)` | Toggle the horizontal volume-profile overlay |
684
749
  | `setVolumeProfileConfig({ buckets, widthRatio, opacity, highlightPoC })` | Tune the volume profile |
685
750
  | `setAutoScale(v)` / `setLogScale(v)` | Lock or change price-scale mode |
751
+ | `setInvertScale(v)` | Turn the price scale upside down |
686
752
  | `fitContent()` / `scrollToEnd()` | Fit all data / jump to live edge |
753
+ | `setVisibleRangePreset(p)` | Show `1D`, `5D`, `1M`, `3M`, `6M`, `YTD`, `1Y`, `5Y` or `All` |
754
+ | `goToTime(time)` | Centre the bar at a time |
755
+ | `setCrosshairTime(time)` | Mirror another chart's crosshair (vertical line only) |
756
+ | `copyDrawings()` / `pasteDrawings()` | Copy the selection, paste into this or another chart |
757
+ | `setStayInDrawingMode(v)` | Keep the drawing tool after each drawing |
687
758
  | `saveState(key?)` | Serialize chart state |
688
759
  | `loadState(json)` | Restore chart state |
689
760
  | `screenshot()` | Download chart as image |
@@ -694,7 +765,7 @@ chart.setNumberLocale('de-DE') // 65.234,00
694
765
 
695
766
  ```typescript
696
767
  interface OHLCBar {
697
- time: number // Unix timestamp (seconds)
768
+ time: number // Unix time in ms or seconds (up to 1e12 is read as seconds); ascending
698
769
  open: number
699
770
  high: number
700
771
  low: number
@@ -711,6 +782,17 @@ interface OHLCBar {
711
782
  | [StackBlitz sandboxes](https://bonguynvan.github.io/tradecanvas/examples/) | One-click, forkable: vanilla `Chart`, `ChartWidget`, React / Vue / Svelte wrappers, finance charts |
712
783
  | [`@tradecanvas/react`](https://www.npmjs.com/package/@tradecanvas/react) · [`/vue`](https://www.npmjs.com/package/@tradecanvas/vue) · [`/svelte`](https://www.npmjs.com/package/@tradecanvas/svelte) | Framework components — reactive props, typed, zero boilerplate |
713
784
 
785
+ ## AI coding tools
786
+
787
+ - [`llms.txt`](https://bonguynvan.github.io/tradecanvas/llms.txt) and
788
+ [`llms-full.txt`](https://bonguynvan.github.io/tradecanvas/llms-full.txt) give
789
+ assistants the docs in one place.
790
+ - An agent skill, [`skills/tradecanvas`](https://github.com/bonguynvan/tradecanvas/blob/main/skills/tradecanvas/SKILL.md), teaches
791
+ coding agents to build with TradeCanvas: the entry points, the rules that
792
+ avoid most bugs, and worked examples that CI type-checks against the library.
793
+ Copy the folder into your project's `.claude/skills/` (or your agent's skills
794
+ folder) to use it.
795
+
714
796
  ## Browser Support
715
797
 
716
798
  Chrome 80+, Firefox 80+, Safari 14+, Edge 80+