acttrader-charts 1.1.2 → 1.2.0-beta.1
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.
- package/README.md +156 -1
- package/dist/{MACD-Dqi682ei.d.cts → MACD-B42iJOWq.d.cts} +233 -2
- package/dist/{MACD-Dqi682ei.d.ts → MACD-B42iJOWq.d.ts} +233 -2
- package/dist/index.cjs +4035 -741
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +441 -3
- package/dist/index.d.ts +441 -3
- package/dist/index.js +4021 -742
- package/dist/index.js.map +1 -1
- package/dist/indicators/index.d.cts +2 -2
- package/dist/indicators/index.d.ts +2 -2
- package/dist/webview/chart.html +84 -67
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ActCharts
|
|
2
2
|
|
|
3
3
|
A performant, zero-dependency stock charting library built on Canvas 2D.
|
|
4
4
|
Dual ESM/CJS output, TypeScript-first.
|
|
@@ -115,6 +115,50 @@ To push ticks directly without an adapter (e.g. from your own WebSocket handler)
|
|
|
115
115
|
chart.pushTick({ time: Date.now(), bid: 1.2055, ask: 1.2057, volume: 120 });
|
|
116
116
|
```
|
|
117
117
|
|
|
118
|
+
### Compare symbols
|
|
119
|
+
|
|
120
|
+
Overlay one or more comparison instruments on the main chart, normalized to
|
|
121
|
+
percent change from the leftmost visible bar — TradingView-style. Compares are
|
|
122
|
+
historical-only (no live streaming) and persist across primary symbol /
|
|
123
|
+
timeframe switches; the library refetches them automatically against the new
|
|
124
|
+
primary range whenever the chart's range changes.
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
const chart = new ChartEngine({
|
|
128
|
+
container: document.getElementById('chart')!,
|
|
129
|
+
symbol: 'AAPL',
|
|
130
|
+
isins: ['AAPL', 'MSFT', 'GOOG', 'SPY', 'NVDA'],
|
|
131
|
+
headerLayout: 'advanced', // Compare button lives in this toolbar
|
|
132
|
+
initialCompares: ['SPY'], // optional — added on first dataLoaded
|
|
133
|
+
maxCompares: 8, // optional — default 8
|
|
134
|
+
compareDataLoader: async ({ symbol, start, end, interval }) => {
|
|
135
|
+
const res = await fetch(
|
|
136
|
+
`/api/bars?symbol=${symbol}&interval=${interval}` +
|
|
137
|
+
`&start=${start.toISOString()}&end=${end.toISOString()}`
|
|
138
|
+
);
|
|
139
|
+
return res.json(); // OHLCVBar[]
|
|
140
|
+
},
|
|
141
|
+
dataLoader: async (params) => fetchBars('AAPL', params),
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// Programmatic API
|
|
145
|
+
await chart.addCompare('MSFT');
|
|
146
|
+
chart.removeCompare('MSFT');
|
|
147
|
+
chart.clearCompares();
|
|
148
|
+
chart.getCompares(); // [{ symbol, color, status }]
|
|
149
|
+
|
|
150
|
+
// Events
|
|
151
|
+
chart.on('compareAdded', ({ symbol, color }) => console.log('+', symbol));
|
|
152
|
+
chart.on('compareRemoved', ({ symbol }) => console.log('-', symbol));
|
|
153
|
+
chart.on('compareError', ({ symbol, message }) => console.warn(symbol, message));
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
When any compare is active the Y-axis switches to percent (`+12.34%` /
|
|
157
|
+
`-5.67%`); removing every compare returns it to absolute-price labels.
|
|
158
|
+
The Compare button in the advanced toolbar opens an in-chart picker filtered
|
|
159
|
+
by `isins` (with the primary symbol and active compares hidden). To keep the
|
|
160
|
+
old consumer-owned flow, omit `compareDataLoader` and wire `onCompareClick`.
|
|
161
|
+
|
|
118
162
|
### Trade From Chart (TFC) — `setLevels`
|
|
119
163
|
|
|
120
164
|
TFC renders draggable price levels for open positions and pending orders.
|
|
@@ -252,6 +296,7 @@ When `enableTrading` is on and live BID/ASK data is streaming, hovering / activa
|
|
|
252
296
|
| `series` | | `"candlestick"` | Initial chart type |
|
|
253
297
|
| `showVolume` | | `true` | Show volume overlay |
|
|
254
298
|
| `showUI` | | `true` | Render top / bottom / left bars. When `false`, the loading overlay is also suppressed (mobile wrappers provide their own) |
|
|
299
|
+
| `hideHeader` | | `false` | Hide only the chart header (TopBar / AdvancedToolbar / CompactToolbar, per `headerLayout`). Bottom bar, left drawing tools, and on-canvas overlays remain on their own flags. Drive the chart from your own UI via `setTimeframe(tf)`, `setSeries(type)`, `addIndicatorByName(name)`, `removeIndicator(name)` |
|
|
255
300
|
| `showDrawingTools` | | `true` | Show drawing toolbar and pencil button |
|
|
256
301
|
| `showFullscreenButton` | | `true` | Show the fullscreen toggle button in the top bar. Set to `false` to hide it entirely. Mobile wrappers (Android / iOS) default this to `false` |
|
|
257
302
|
| `timeframe` | | `"1D"` | Initial timeframe |
|
|
@@ -274,6 +319,9 @@ When `enableTrading` is on and live BID/ASK data is streaming, hovering / activa
|
|
|
274
319
|
| `targetCandleWidth` | | `10` | Target px width per candle for auto-calculating initial bar count |
|
|
275
320
|
| `durationTimeframeMap` | | *(see below)* | Override duration → timeframe pairings |
|
|
276
321
|
| `dataLoader` | | — | `(params) => Promise<OHLCVBar[]>` auto-called on load / change |
|
|
322
|
+
| `compareDataLoader` | | — | `({ symbol, start, end, interval }) => Promise<OHLCVBar[]>` — fetches bars for a compare symbol. Set this to enable the library-owned Compare flow. |
|
|
323
|
+
| `initialCompares` | | — | Symbols to auto-add as compares once the initial primary range is loaded |
|
|
324
|
+
| `maxCompares` | | `8` | Maximum concurrent compare symbols. Adding beyond emits `compareError` |
|
|
277
325
|
| `themeOverrides` | | — | Deep-partial color overrides applied on top of the built-in dark/light themes |
|
|
278
326
|
| `uiConfig` | | `DEFAULT_UI_CONFIG` | Deep-partial size / font overrides per component |
|
|
279
327
|
| `labels` | | `DEFAULT_LABELS` | Deep-partial string overrides for i18n/translation |
|
|
@@ -817,6 +865,113 @@ chart.on('tradeLevelBracketActivated', ({ label, bracketType, price, isFullscree
|
|
|
817
865
|
|
|
818
866
|
---
|
|
819
867
|
|
|
868
|
+
## Multi-Pane Layouts
|
|
869
|
+
|
|
870
|
+
The library ships everything you need to put multiple synchronised `ChartEngine`s on one screen — preset definitions, a layout-picker popover, cross-pane sync, and a composite snapshot helper. The library *emits intent*; the host renders the grid.
|
|
871
|
+
|
|
872
|
+
### Enabling the layout & snapshot UI
|
|
873
|
+
|
|
874
|
+
Pass two flags to `ChartConfig` (and optionally pick a header variant):
|
|
875
|
+
|
|
876
|
+
```ts
|
|
877
|
+
const chart = new ChartEngine({
|
|
878
|
+
container,
|
|
879
|
+
headerLayout: 'advanced', // 'simple' (default) | 'advanced' | 'compact'
|
|
880
|
+
enableMultipleLayouts: true, // shows Layout button + 26 preset picker
|
|
881
|
+
enableSnapshot: true, // shows Snapshot button + Download/Copy popover
|
|
882
|
+
});
|
|
883
|
+
|
|
884
|
+
chart.on('layoutChange', ({ presetId, preset, sync }) => {
|
|
885
|
+
// Mount / teardown panes to match preset.count
|
|
886
|
+
// Apply sync flags to your ChartGroup
|
|
887
|
+
});
|
|
888
|
+
|
|
889
|
+
chart.on('snapshot', ({ dataUrl, action }) => {
|
|
890
|
+
// Native wrappers can intercept here to save via platform APIs
|
|
891
|
+
});
|
|
892
|
+
```
|
|
893
|
+
|
|
894
|
+
### `ChartGroup` — cross-pane sync
|
|
895
|
+
|
|
896
|
+
`ChartGroup` listens to events on the *active* engine and mirrors them to the others:
|
|
897
|
+
|
|
898
|
+
| Sync flag | Source event | Action on other panes
|
|
899
|
+
| ------------ | ------------------ | ----------------------------------------
|
|
900
|
+
| `interval` | `timeframeChange` | `setTimeframe` (skip if equal)
|
|
901
|
+
| `crosshair` | `crosshair` | `timeToBarIndex` → `setCrosshair`
|
|
902
|
+
| `time` | `pan` | `setViewport({ startIndex, endIndex })`
|
|
903
|
+
| `dateRange` | `zoom` | `setViewport({ startIndex, endIndex })`
|
|
904
|
+
| `symbol` | push (`broadcastSymbol`) | `setSymbol` (host still fetches data)
|
|
905
|
+
|
|
906
|
+
```ts
|
|
907
|
+
import { ChartGroup, DEFAULT_LAYOUT_SYNC } from 'acttrader-charts';
|
|
908
|
+
|
|
909
|
+
const group = new ChartGroup({ sync: DEFAULT_LAYOUT_SYNC });
|
|
910
|
+
group.add('p1', engineA);
|
|
911
|
+
group.add('p2', engineB);
|
|
912
|
+
group.setActive('p1');
|
|
913
|
+
|
|
914
|
+
// react to user picking a preset
|
|
915
|
+
chart.on('layoutChange', ({ sync }) => group.setSync(sync));
|
|
916
|
+
|
|
917
|
+
// user picked a new symbol on the active pane
|
|
918
|
+
group.broadcastSymbol('AAPL', 'p1');
|
|
919
|
+
```
|
|
920
|
+
|
|
921
|
+
`ChartEngine.setViewport` / `setCrosshair` deliberately do **not** re-emit `pan` / `zoom` / `crosshair`, so the mirror is safe from feedback loops.
|
|
922
|
+
|
|
923
|
+
### Custom layout presets
|
|
924
|
+
|
|
925
|
+
Register an extra preset alongside the 26 built-ins; it appears in the picker automatically:
|
|
926
|
+
|
|
927
|
+
```ts
|
|
928
|
+
import { registerCustomPreset } from 'acttrader-charts';
|
|
929
|
+
|
|
930
|
+
registerCustomPreset({
|
|
931
|
+
id: 'my-3-wide-left',
|
|
932
|
+
count: 3,
|
|
933
|
+
cols: '2fr 1fr',
|
|
934
|
+
rows: '1fr 1fr',
|
|
935
|
+
areas: '"a b" "a c"',
|
|
936
|
+
areaOrder: ['a', 'b', 'c'],
|
|
937
|
+
icon: '<svg>…</svg>',
|
|
938
|
+
});
|
|
939
|
+
```
|
|
940
|
+
|
|
941
|
+
Persistence is the host's job — serialise the preset to your store, call `registerCustomPreset` again on app boot.
|
|
942
|
+
|
|
943
|
+
### Composite snapshot of a multi-pane grid
|
|
944
|
+
|
|
945
|
+
`SnapshotPopover` captures the single active chart. For a whole-grid PNG, hand the cell rectangles to the group:
|
|
946
|
+
|
|
947
|
+
```ts
|
|
948
|
+
const containerRect = gridEl.getBoundingClientRect();
|
|
949
|
+
const rects = paneIds.map(id => {
|
|
950
|
+
const cell = cellEls.get(id)!.getBoundingClientRect();
|
|
951
|
+
return {
|
|
952
|
+
paneId: id,
|
|
953
|
+
x: cell.left - containerRect.left,
|
|
954
|
+
y: cell.top - containerRect.top,
|
|
955
|
+
w: cell.width,
|
|
956
|
+
h: cell.height,
|
|
957
|
+
};
|
|
958
|
+
});
|
|
959
|
+
|
|
960
|
+
const dataUrl = group.toCompositeDataUrl({
|
|
961
|
+
width: containerRect.width,
|
|
962
|
+
height: containerRect.height,
|
|
963
|
+
rects,
|
|
964
|
+
});
|
|
965
|
+
```
|
|
966
|
+
|
|
967
|
+
The composite excludes trade levels (positions, SL/TP) — same rule as `chart.toDataUrl()`.
|
|
968
|
+
|
|
969
|
+
### Native wrapper parity
|
|
970
|
+
|
|
971
|
+
`enableMultipleLayouts`, `enableSnapshot`, `headerLayout`, the `layoutChange` event, and the `snapshot` event are all exposed by [charts-android](../charts-android) and [charts-ios](../charts-ios) — see their READMEs for native usage.
|
|
972
|
+
|
|
973
|
+
---
|
|
974
|
+
|
|
820
975
|
## Custom Indicator
|
|
821
976
|
|
|
822
977
|
Implement `IIndicator` and pass it to `addIndicator()`:
|
|
@@ -1,3 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Definition of a multi-chart layout preset (grid template).
|
|
3
|
+
* Used by the chart-owned LayoutPopover and emitted via the `layoutChange` event.
|
|
4
|
+
* The host project is responsible for actually mounting N panes per `count`.
|
|
5
|
+
*/
|
|
6
|
+
interface LayoutPreset {
|
|
7
|
+
id: string;
|
|
8
|
+
count: number;
|
|
9
|
+
cols: string;
|
|
10
|
+
rows: string;
|
|
11
|
+
areas?: string;
|
|
12
|
+
areaOrder?: string[];
|
|
13
|
+
icon: string;
|
|
14
|
+
}
|
|
15
|
+
/** Cross-pane sync toggles emitted alongside layoutChange. */
|
|
16
|
+
interface LayoutSyncState {
|
|
17
|
+
symbol: boolean;
|
|
18
|
+
interval: boolean;
|
|
19
|
+
crosshair: boolean;
|
|
20
|
+
time: boolean;
|
|
21
|
+
dateRange: boolean;
|
|
22
|
+
}
|
|
23
|
+
declare const LAYOUT_PRESETS: LayoutPreset[];
|
|
24
|
+
declare const PRESETS_BY_COUNT: Record<number, LayoutPreset[]>;
|
|
25
|
+
declare const PRESET_COUNTS: number[];
|
|
26
|
+
/**
|
|
27
|
+
* Register a preset that appears alongside the built-ins in `getAllPresets()`
|
|
28
|
+
* and the chart-owned `LayoutPopover`. Re-registering the same id overwrites.
|
|
29
|
+
* Throws when the id collides with a built-in preset.
|
|
30
|
+
*/
|
|
31
|
+
declare function registerCustomPreset(preset: LayoutPreset): void;
|
|
32
|
+
/** Remove a previously registered custom preset. No-op for unknown ids. */
|
|
33
|
+
declare function unregisterCustomPreset(id: string): void;
|
|
34
|
+
/** All registered custom presets, in insertion order. */
|
|
35
|
+
declare function getCustomPresets(): LayoutPreset[];
|
|
36
|
+
/** Built-ins followed by registered custom presets. */
|
|
37
|
+
declare function getAllPresets(): LayoutPreset[];
|
|
38
|
+
/**
|
|
39
|
+
* Resolve a preset by id, checking custom presets first, then built-ins. Falls
|
|
40
|
+
* back to the single-pane preset when nothing matches.
|
|
41
|
+
*/
|
|
42
|
+
declare function getPreset(id: string): LayoutPreset;
|
|
43
|
+
/** Human-readable label for each preset, useful in status bars / tooltips. */
|
|
44
|
+
declare const PRESET_LABEL: Record<string, string>;
|
|
45
|
+
/** Default sync state — matches the host's current defaults in useChartLayout.ts. */
|
|
46
|
+
declare const DEFAULT_LAYOUT_SYNC: LayoutSyncState;
|
|
47
|
+
|
|
1
48
|
declare class ScaleManager {
|
|
2
49
|
private static readonly VERTICAL_PADDING_PX;
|
|
3
50
|
xToPixel(index: number, viewport: Viewport, chartWidth: number): number;
|
|
@@ -37,6 +84,11 @@ interface DrawingToolbarUiConfig {
|
|
|
37
84
|
btnGap: number;
|
|
38
85
|
/** Container width (px) below which LeftBar switches to mobile layout */
|
|
39
86
|
mobileBreakpoint: number;
|
|
87
|
+
/**
|
|
88
|
+
* Use Lucide-style modern SVG icons for the drawing toolbar categories.
|
|
89
|
+
* Default: `false` (original icons, unchanged for all existing consumers).
|
|
90
|
+
*/
|
|
91
|
+
modernIcons?: boolean;
|
|
40
92
|
}
|
|
41
93
|
interface TopBarUiConfig {
|
|
42
94
|
/** Height of the top bar strip */
|
|
@@ -354,6 +406,11 @@ interface ChartThemeUi {
|
|
|
354
406
|
reconnecting: string;
|
|
355
407
|
disconnected: string;
|
|
356
408
|
};
|
|
409
|
+
/**
|
|
410
|
+
* Background color of the scroll-to-latest (➕) button.
|
|
411
|
+
* When omitted the button uses the chart background + axisBorder border (neutral style).
|
|
412
|
+
*/
|
|
413
|
+
scrollToEndBtnBg?: string;
|
|
357
414
|
}
|
|
358
415
|
/** Colors specific to the drawing toolbar (LeftBar). */
|
|
359
416
|
interface DrawingToolbarColors {
|
|
@@ -546,6 +603,13 @@ interface DataLoaderParams {
|
|
|
546
603
|
end: Date;
|
|
547
604
|
interval: string;
|
|
548
605
|
}
|
|
606
|
+
/**
|
|
607
|
+
* Params passed to `compareDataLoader`. Mirrors `DataLoaderParams` but also
|
|
608
|
+
* carries the compare symbol so a single loader can serve multiple compares.
|
|
609
|
+
*/
|
|
610
|
+
interface CompareDataLoaderParams extends DataLoaderParams {
|
|
611
|
+
symbol: string;
|
|
612
|
+
}
|
|
549
613
|
/**
|
|
550
614
|
* Per-theme deep-partial color overrides applied on top of the built-in
|
|
551
615
|
* dark / light themes. Only the keys you supply are replaced.
|
|
@@ -935,6 +999,125 @@ interface ChartConfig {
|
|
|
935
999
|
* Default: `false` (bar is hidden).
|
|
936
1000
|
*/
|
|
937
1001
|
showBottomBar?: boolean;
|
|
1002
|
+
/**
|
|
1003
|
+
* Text-decoration for the clickable symbol name in the top-left OHLCV strip.
|
|
1004
|
+
* Default: `'underline'` (existing behaviour).
|
|
1005
|
+
* - `'underline'` → persistent underline whenever the symbol is clickable
|
|
1006
|
+
* - `'none'` → never underline; click handler still attached
|
|
1007
|
+
* - `'hover'` → no resting underline, but `:hover` / `:focus-visible` reveal one
|
|
1008
|
+
* (preferred for branded designs that still want a link affordance)
|
|
1009
|
+
*/
|
|
1010
|
+
symbolNameDecoration?: 'underline' | 'none' | 'hover';
|
|
1011
|
+
/** Called when the user clicks "Add alert" in the trade popover. Omit to hide the alert row. */
|
|
1012
|
+
onAddAlert?: (price: number) => void;
|
|
1013
|
+
/**
|
|
1014
|
+
* Header layout variant. Default `'simple'`.
|
|
1015
|
+
* - `'simple'` — original top-bar with dropdowns + duration buttons
|
|
1016
|
+
* - `'advanced'` — compact toolbar with timeframe pills + Compare/1-Click
|
|
1017
|
+
* - `'compact'` — slim per-pane toolbar (timeframe + series + indicators only),
|
|
1018
|
+
* sized for multi-pane grid cells. Symbol is changed via the
|
|
1019
|
+
* on-canvas OHLC strip label (no symbol button in this variant).
|
|
1020
|
+
*
|
|
1021
|
+
* If both `headerLayout` and the deprecated `features.advancedToolbar` are set,
|
|
1022
|
+
* `headerLayout` wins.
|
|
1023
|
+
*/
|
|
1024
|
+
headerLayout?: 'simple' | 'advanced' | 'compact';
|
|
1025
|
+
/**
|
|
1026
|
+
* Hide the chart header entirely (simple TopBar / AdvancedToolbar /
|
|
1027
|
+
* CompactToolbar — whichever `headerLayout` would have rendered).
|
|
1028
|
+
*
|
|
1029
|
+
* Use when the host UI provides its own controls and drives the chart via
|
|
1030
|
+
* `setTimeframe`, `setSeries`, `addIndicatorByName`, `removeIndicator`.
|
|
1031
|
+
*
|
|
1032
|
+
* Independent of `showUI` (which hides ALL UI) and `showBottomBar` /
|
|
1033
|
+
* drawing-tools / OHLC strip flags. Default: `false` (header visible).
|
|
1034
|
+
*/
|
|
1035
|
+
hideHeader?: boolean;
|
|
1036
|
+
/**
|
|
1037
|
+
* Show the Layout button and built-in multi-chart layout preset popover.
|
|
1038
|
+
* Default `false`. Works in both `'simple'` and `'advanced'` header layouts.
|
|
1039
|
+
*
|
|
1040
|
+
* The chart owns ONLY the picker UI. Selecting a preset emits a `layoutChange`
|
|
1041
|
+
* event with `{ presetId, preset, sync }`; the host project is responsible for
|
|
1042
|
+
* mounting the actual N-pane grid of ChartEngine instances and applying sync.
|
|
1043
|
+
*
|
|
1044
|
+
* Suppresses the deprecated `onLayoutClick` callback if also provided
|
|
1045
|
+
* (a one-time `console.warn` is logged at init).
|
|
1046
|
+
*/
|
|
1047
|
+
enableMultipleLayouts?: boolean;
|
|
1048
|
+
/**
|
|
1049
|
+
* Show the Snapshot button and built-in Download/Copy popover.
|
|
1050
|
+
* Default `false`. Works in both `'simple'` and `'advanced'` header layouts.
|
|
1051
|
+
*
|
|
1052
|
+
* The chart emits a `snapshot` event with `{ dataUrl, action }` BEFORE
|
|
1053
|
+
* attempting the native browser action — mobile wrappers (Android/iOS)
|
|
1054
|
+
* can intercept via the JS bridge to use native APIs (Photos library,
|
|
1055
|
+
* UIPasteboard, ClipboardManager) where browser permissions are restricted.
|
|
1056
|
+
*
|
|
1057
|
+
* Suppresses the deprecated `onScreenshotClick` callback if also provided
|
|
1058
|
+
* (a one-time `console.warn` is logged at init).
|
|
1059
|
+
*/
|
|
1060
|
+
enableSnapshot?: boolean;
|
|
1061
|
+
/**
|
|
1062
|
+
* Opt-in feature flags. All flags default to `false` / disabled so existing
|
|
1063
|
+
* consumers are completely unaffected when this field is omitted.
|
|
1064
|
+
*/
|
|
1065
|
+
features?: {
|
|
1066
|
+
/**
|
|
1067
|
+
* @deprecated Use top-level `headerLayout: 'advanced'` instead. Will be
|
|
1068
|
+
* removed in a future major version. Currently treated as an alias.
|
|
1069
|
+
*/
|
|
1070
|
+
advancedToolbar?: boolean;
|
|
1071
|
+
};
|
|
1072
|
+
/**
|
|
1073
|
+
* Fetches historical OHLC bars for a compare symbol. When provided, the
|
|
1074
|
+
* library owns the Compare flow end-to-end: clicking the Compare button
|
|
1075
|
+
* opens an in-chart picker (reusing `isins`), and this loader is invoked
|
|
1076
|
+
* to populate each chosen compare. It is also re-invoked whenever the
|
|
1077
|
+
* primary symbol's range changes (timeframe switch, primary-symbol switch,
|
|
1078
|
+
* history pan-back, `resetData`) so compares stay aligned.
|
|
1079
|
+
*
|
|
1080
|
+
* No streaming — compares are historical-only in v1.
|
|
1081
|
+
*/
|
|
1082
|
+
compareDataLoader?: (params: CompareDataLoaderParams) => Promise<OHLCVBar[]>;
|
|
1083
|
+
/**
|
|
1084
|
+
* Compare symbols to add automatically on chart init. Each one triggers a
|
|
1085
|
+
* `compareDataLoader` call against the initial primary range.
|
|
1086
|
+
*/
|
|
1087
|
+
initialCompares?: string[];
|
|
1088
|
+
/**
|
|
1089
|
+
* Maximum number of concurrent compare symbols. Attempting to add beyond
|
|
1090
|
+
* this emits a `compareError` event instead of fetching. Default: `8`.
|
|
1091
|
+
*/
|
|
1092
|
+
maxCompares?: number;
|
|
1093
|
+
/**
|
|
1094
|
+
* @deprecated With `enableMultipleLayouts: true`, the chart owns the popover
|
|
1095
|
+
* and emits a `layoutChange` event. Listen to that event instead.
|
|
1096
|
+
* Still honored when `enableMultipleLayouts` is omitted/false.
|
|
1097
|
+
*/
|
|
1098
|
+
onLayoutClick?: () => void;
|
|
1099
|
+
/**
|
|
1100
|
+
* Called when the user toggles the 1-Click Trade button. Receives the new
|
|
1101
|
+
* active state as a boolean. The button is rendered in whichever toolbar is
|
|
1102
|
+
* active (default `TopBar` or `AdvancedToolbar`).
|
|
1103
|
+
*
|
|
1104
|
+
* **When omitted, the 1-Click Trade button is hidden** — callback presence
|
|
1105
|
+
* gates the button's visibility, matching the pattern used by
|
|
1106
|
+
* `onLayoutClick` / `onScreenshotClick`.
|
|
1107
|
+
*/
|
|
1108
|
+
onOneClickTradeToggle?: (active: boolean) => void;
|
|
1109
|
+
/**
|
|
1110
|
+
* @deprecated Renamed to `onOneClickTradeToggle` for clarity. Will be
|
|
1111
|
+
* removed in a future major version. If both are provided,
|
|
1112
|
+
* `onOneClickTradeToggle` wins and a console warning is emitted.
|
|
1113
|
+
*/
|
|
1114
|
+
onOneClickToggle?: (active: boolean) => void;
|
|
1115
|
+
/**
|
|
1116
|
+
* @deprecated With `enableSnapshot: true`, the chart owns the popover and
|
|
1117
|
+
* emits a `snapshot` event. Listen to that event instead.
|
|
1118
|
+
* Still honored when `enableSnapshot` is omitted/false.
|
|
1119
|
+
*/
|
|
1120
|
+
onScreenshotClick?: () => void;
|
|
938
1121
|
/**
|
|
939
1122
|
* @deprecated DraftOrderQtyInput has been removed. This option is a no-op.
|
|
940
1123
|
* Accepted for backward compatibility only.
|
|
@@ -1126,6 +1309,11 @@ interface ChartState {
|
|
|
1126
1309
|
factor: number;
|
|
1127
1310
|
panOffset: number;
|
|
1128
1311
|
};
|
|
1312
|
+
/**
|
|
1313
|
+
* Active compare symbols at snapshot time. The library will re-add each
|
|
1314
|
+
* one (in order) via `compareDataLoader` when this state is restored.
|
|
1315
|
+
*/
|
|
1316
|
+
compares?: string[];
|
|
1129
1317
|
}
|
|
1130
1318
|
interface CrosshairPosition {
|
|
1131
1319
|
x: number;
|
|
@@ -1135,7 +1323,12 @@ interface CrosshairPosition {
|
|
|
1135
1323
|
bar: OHLCVBar | null;
|
|
1136
1324
|
}
|
|
1137
1325
|
type ChartEventMap = {
|
|
1138
|
-
|
|
1326
|
+
/**
|
|
1327
|
+
* Crosshair position changed. Payload is `null` when the crosshair leaves
|
|
1328
|
+
* the chart area or is otherwise cleared — listeners that mirror crosshair
|
|
1329
|
+
* across multiple panes use `null` to clear the mirrored crosshair.
|
|
1330
|
+
*/
|
|
1331
|
+
crosshair: CrosshairPosition | null;
|
|
1139
1332
|
click: CrosshairPosition;
|
|
1140
1333
|
zoom: {
|
|
1141
1334
|
viewport: Viewport;
|
|
@@ -1327,6 +1520,44 @@ type ChartEventMap = {
|
|
|
1327
1520
|
bracketOrderLabel?: string;
|
|
1328
1521
|
}>;
|
|
1329
1522
|
};
|
|
1523
|
+
/**
|
|
1524
|
+
* Emitted when the user picks a preset in the multi-layout popover or toggles
|
|
1525
|
+
* a sync option. Fires only when `enableMultipleLayouts: true`. The host
|
|
1526
|
+
* project listens to this event to mount/teardown N panes accordingly.
|
|
1527
|
+
*/
|
|
1528
|
+
layoutChange: {
|
|
1529
|
+
presetId: string;
|
|
1530
|
+
preset: LayoutPreset;
|
|
1531
|
+
sync: LayoutSyncState;
|
|
1532
|
+
};
|
|
1533
|
+
/**
|
|
1534
|
+
* Emitted when the user picks Download or Copy from the snapshot popover.
|
|
1535
|
+
* Fires only when `enableSnapshot: true`. The chart attempts the native
|
|
1536
|
+
* browser action immediately after emitting; mobile wrappers can intercept
|
|
1537
|
+
* via the JS bridge to short-circuit and use platform APIs.
|
|
1538
|
+
*/
|
|
1539
|
+
snapshot: {
|
|
1540
|
+
/** Full PNG data URL of the composited chart canvas. */
|
|
1541
|
+
dataUrl: string;
|
|
1542
|
+
action: 'download' | 'copy';
|
|
1543
|
+
};
|
|
1544
|
+
/** Emitted after a compare symbol has been added and its bars resolved. */
|
|
1545
|
+
compareAdded: {
|
|
1546
|
+
symbol: string;
|
|
1547
|
+
color: string;
|
|
1548
|
+
};
|
|
1549
|
+
/** Emitted when a compare symbol is removed (×, `removeCompare`, or `clearCompares`). */
|
|
1550
|
+
compareRemoved: {
|
|
1551
|
+
symbol: string;
|
|
1552
|
+
};
|
|
1553
|
+
/**
|
|
1554
|
+
* Emitted when adding a compare or fetching its bars fails — e.g. no
|
|
1555
|
+
* `compareDataLoader` configured, loader rejected, or `maxCompares` reached.
|
|
1556
|
+
*/
|
|
1557
|
+
compareError: {
|
|
1558
|
+
symbol: string;
|
|
1559
|
+
message: string;
|
|
1560
|
+
};
|
|
1330
1561
|
};
|
|
1331
1562
|
/** Distinguishes level types: historical trade, open position, or pending order. */
|
|
1332
1563
|
type TradeLevelType = 'trade' | 'position' | 'pending';
|
|
@@ -1518,4 +1749,4 @@ declare class MACD implements IIndicator {
|
|
|
1518
1749
|
render(ctx: CanvasRenderingContext2D, results: IndicatorResult[], scale: ScaleManager, viewport: Viewport, paneHeight: number, rangeOverride?: PriceRange): void;
|
|
1519
1750
|
}
|
|
1520
1751
|
|
|
1521
|
-
export { type
|
|
1752
|
+
export { type Duration as $, type AnyDrawingStyle as A, BollingerBands as B, type ChartConfig as C, type DrawingToolType as D, DEFAULT_DRAWING_TOOLBAR_CONFIG as E, DEFAULT_INDICATOR_OVERLAY_CONFIG as F, DEFAULT_LABELS as G, DEFAULT_LAYOUT_SYNC as H, type IIndicator as I, DEFAULT_PRICE_AXIS_CONFIG as J, DEFAULT_TIME_AXIS_CONFIG as K, type LayoutSyncState as L, DEFAULT_TOP_BAR_CONFIG as M, DEFAULT_TRADE_BUTTON_CONFIG as N, type OHLCVBar as O, type PriceRange as P, DEFAULT_UI_CONFIG as Q, type DataLoaderParams as R, type SeriesType as S, type Timeframe as T, type DeepPartial$1 as U, type Viewport as V, type DeepPartialChartTheme as W, type DialogLabels as X, type DrawingToolbarColors as Y, type DrawingToolbarLabels as Z, type DrawingToolbarUiConfig as _, type ChartEventMap as a, EMA as a0, type IndicatorOverlayColors as a1, type IndicatorOverlayUiConfig as a2, type IndicatorParams as a3, type IndicatorResult as a4, type IndicatorStateEntry as a5, LAYOUT_PRESETS as a6, LIGHT_THEME as a7, type LayoutPreset as a8, MACD as a9, getAllPresets as aA, getCustomPresets as aB, getPreset as aC, registerCustomPreset as aD, resolveCssVarsInTheme as aE, resolveLabels as aF, resolveUiConfig as aG, unregisterCustomPreset as aH, type PriceSource as aI, type OhlcLabels as aa, type OrderSubmit as ab, PRESETS_BY_COUNT as ac, PRESET_COUNTS as ad, PRESET_LABEL as ae, type Padding as af, type PendingOrderLevel as ag, type PositionLevel as ah, type PositionRenderStyle as ai, type PriceAxisUiConfig as aj, RSI as ak, SMA as al, type Theme as am, type ThemeOverrides as an, type TimeAxisUiConfig as ao, type TopBarColors as ap, type TopBarLabels as aq, type TopBarUiConfig as ar, type TradeButtonUiConfig as as, type TradeDisplayFilter as at, type TradeLabels as au, type TradeLevel as av, type TradeLevelColors as aw, type TradePanelColors as ax, type UiConfig as ay, deepMergeTheme as az, type ChartState as b, type IDrawing as c, type IWebSocketAdapter as d, type TradeLevelType as e, type ChartTheme as f, type AnyLevel as g, type DrawingPoint as h, ScaleManager as i, type DrawingHandle as j, type SerializedDrawing as k, type Tick as l, type StreamStatus as m, type ActiveIndicatorState as n, type BottomBarColors as o, type BottomBarLabels as p, type BottomBarUiConfig as q, type CanvasColorSettings as r, type ChartLabels as s, type ChartMiscLabels as t, type ChartThemeUi as u, type CrosshairPosition as v, type CrosshairUiConfig as w, DARK_THEME as x, DEFAULT_BOTTOM_BAR_CONFIG as y, DEFAULT_CROSSHAIR_CONFIG as z };
|