acttrader-charts 1.2.0-beta.2 → 1.2.0-beta.4
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 +22 -0
- package/dist/{MACD-BBW1QO3M.d.cts → MACD-dGgN6dtc.d.cts} +11 -1
- package/dist/{MACD-BBW1QO3M.d.ts → MACD-dGgN6dtc.d.ts} +11 -1
- package/dist/index.cjs +21 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -2
- package/dist/index.d.ts +13 -2
- package/dist/index.js +21 -1
- 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 +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -916,6 +916,7 @@ const chart = new ChartEngine({
|
|
|
916
916
|
headerLayout: 'advanced', // 'simple' (default) | 'advanced' | 'compact'
|
|
917
917
|
enableMultipleLayouts: true, // shows Layout button + 26 preset picker
|
|
918
918
|
enableSnapshot: true, // shows Snapshot button + Download/Copy popover
|
|
919
|
+
layoutSync: { symbol: false, interval: true }, // optional — seed the popover's sync toggles
|
|
919
920
|
});
|
|
920
921
|
|
|
921
922
|
chart.on('layoutChange', ({ presetId, preset, sync }) => {
|
|
@@ -928,6 +929,27 @@ chart.on('snapshot', ({ dataUrl, action }) => {
|
|
|
928
929
|
});
|
|
929
930
|
```
|
|
930
931
|
|
|
932
|
+
### Seeding & restoring the popover's sync toggles
|
|
933
|
+
|
|
934
|
+
The layout popover's five sync toggles (`symbol` / `interval` / `crosshair` / `time` / `dateRange`) default to `DEFAULT_LAYOUT_SYNC`. To open the popover in a different state — e.g. restoring a user's saved preference — pass a **partial** `layoutSync` at construction (omitted keys keep their `DEFAULT_LAYOUT_SYNC` value):
|
|
935
|
+
|
|
936
|
+
```ts
|
|
937
|
+
const chart = new ChartEngine({
|
|
938
|
+
container,
|
|
939
|
+
enableMultipleLayouts: true,
|
|
940
|
+
layoutSync: savedSync ?? { symbol: false, interval: false, crosshair: false, time: false, dateRange: false },
|
|
941
|
+
});
|
|
942
|
+
```
|
|
943
|
+
|
|
944
|
+
To change the toggles on an **already-mounted** chart (e.g. mirroring a host-owned settings UI), call `setLayoutSync()`:
|
|
945
|
+
|
|
946
|
+
```ts
|
|
947
|
+
chart.setLayoutSync({ crosshair: true }); // partial — other toggles unchanged
|
|
948
|
+
const current = chart.getLayoutSync(); // read the current state
|
|
949
|
+
```
|
|
950
|
+
|
|
951
|
+
`setLayoutSync()` updates the popover's toggles in place and — unlike a user click inside the popover — does **not** emit a `layoutChange` event, so a host can call it in response to its own state without re-entrancy. It no-ops when the resolved state is unchanged.
|
|
952
|
+
|
|
931
953
|
### `ChartGroup` — cross-pane sync
|
|
932
954
|
|
|
933
955
|
`ChartGroup` listens to events on the *active* engine and mirrors them to the others:
|
|
@@ -958,7 +958,7 @@ interface ChartConfig {
|
|
|
958
958
|
* Always render SL/TP bracket lines + price pills, even when the parent
|
|
959
959
|
* trade level is not hovered or selected. Close (×) buttons remain
|
|
960
960
|
* hover-only to keep the chart uncluttered.
|
|
961
|
-
* Default: `false
|
|
961
|
+
* Default: `true`. Set `false` to only show them on hover/selection.
|
|
962
962
|
*/
|
|
963
963
|
showTradeLevelsAlways?: boolean;
|
|
964
964
|
/**
|
|
@@ -1045,6 +1045,16 @@ interface ChartConfig {
|
|
|
1045
1045
|
* (a one-time `console.warn` is logged at init).
|
|
1046
1046
|
*/
|
|
1047
1047
|
enableMultipleLayouts?: boolean;
|
|
1048
|
+
/**
|
|
1049
|
+
* Initial state of the cross-pane sync toggles (Symbol / Interval / Crosshair
|
|
1050
|
+
* / Time / Date range) shown in the chart-owned layout popover when
|
|
1051
|
+
* `enableMultipleLayouts: true`. Partial — any omitted key falls back to
|
|
1052
|
+
* {@link DEFAULT_LAYOUT_SYNC}, so existing consumers are unaffected.
|
|
1053
|
+
*
|
|
1054
|
+
* Use this to restore a user's persisted sync preferences on init. To change
|
|
1055
|
+
* the toggles on an already-mounted chart, call {@link ChartEngine.setLayoutSync}.
|
|
1056
|
+
*/
|
|
1057
|
+
layoutSync?: Partial<LayoutSyncState>;
|
|
1048
1058
|
/**
|
|
1049
1059
|
* Show the Snapshot button and built-in Download/Copy popover.
|
|
1050
1060
|
* Default `false`. Works in both `'simple'` and `'advanced'` header layouts.
|
|
@@ -958,7 +958,7 @@ interface ChartConfig {
|
|
|
958
958
|
* Always render SL/TP bracket lines + price pills, even when the parent
|
|
959
959
|
* trade level is not hovered or selected. Close (×) buttons remain
|
|
960
960
|
* hover-only to keep the chart uncluttered.
|
|
961
|
-
* Default: `false
|
|
961
|
+
* Default: `true`. Set `false` to only show them on hover/selection.
|
|
962
962
|
*/
|
|
963
963
|
showTradeLevelsAlways?: boolean;
|
|
964
964
|
/**
|
|
@@ -1045,6 +1045,16 @@ interface ChartConfig {
|
|
|
1045
1045
|
* (a one-time `console.warn` is logged at init).
|
|
1046
1046
|
*/
|
|
1047
1047
|
enableMultipleLayouts?: boolean;
|
|
1048
|
+
/**
|
|
1049
|
+
* Initial state of the cross-pane sync toggles (Symbol / Interval / Crosshair
|
|
1050
|
+
* / Time / Date range) shown in the chart-owned layout popover when
|
|
1051
|
+
* `enableMultipleLayouts: true`. Partial — any omitted key falls back to
|
|
1052
|
+
* {@link DEFAULT_LAYOUT_SYNC}, so existing consumers are unaffected.
|
|
1053
|
+
*
|
|
1054
|
+
* Use this to restore a user's persisted sync preferences on init. To change
|
|
1055
|
+
* the toggles on an already-mounted chart, call {@link ChartEngine.setLayoutSync}.
|
|
1056
|
+
*/
|
|
1057
|
+
layoutSync?: Partial<LayoutSyncState>;
|
|
1048
1058
|
/**
|
|
1049
1059
|
* Show the Snapshot button and built-in Download/Copy popover.
|
|
1050
1060
|
* Default `false`. Works in both `'simple'` and `'advanced'` header layouts.
|
package/dist/index.cjs
CHANGED
|
@@ -22493,7 +22493,7 @@ var _ChartEngine = class _ChartEngine {
|
|
|
22493
22493
|
this.tfcActive = this.tfcEnabled;
|
|
22494
22494
|
this.showCandleCountdown = config.showCandleCountdown ?? true;
|
|
22495
22495
|
this.candleCountdownTimeframes = config.candleCountdownTimeframes;
|
|
22496
|
-
this.showTradeLevelsAlways = config.showTradeLevelsAlways ??
|
|
22496
|
+
this.showTradeLevelsAlways = config.showTradeLevelsAlways ?? true;
|
|
22497
22497
|
this.showPriceAxisCountdown = config.showPriceAxisCountdown ?? false;
|
|
22498
22498
|
try {
|
|
22499
22499
|
const persistedSlTp = localStorage.getItem(this.SHOW_SLTP_ALWAYS_LS_KEY);
|
|
@@ -22543,6 +22543,9 @@ var _ChartEngine = class _ChartEngine {
|
|
|
22543
22543
|
const hideHeader = config.hideHeader === true;
|
|
22544
22544
|
const enableMultipleLayouts = config.enableMultipleLayouts === true;
|
|
22545
22545
|
const enableSnapshot = config.enableSnapshot === true;
|
|
22546
|
+
if (config.layoutSync) {
|
|
22547
|
+
this.currentSync = { ...DEFAULT_LAYOUT_SYNC, ...config.layoutSync };
|
|
22548
|
+
}
|
|
22546
22549
|
if (enableMultipleLayouts && typeof config.onLayoutClick === "function") {
|
|
22547
22550
|
console.warn(
|
|
22548
22551
|
"[ActCharts] `enableMultipleLayouts: true` owns the Layout button \u2014 the deprecated `onLayoutClick` callback is ignored. Listen to the `layoutChange` event instead."
|
|
@@ -25169,6 +25172,23 @@ var _ChartEngine = class _ChartEngine {
|
|
|
25169
25172
|
getLayoutSync() {
|
|
25170
25173
|
return { ...this.currentSync };
|
|
25171
25174
|
}
|
|
25175
|
+
/**
|
|
25176
|
+
* Programmatically set the cross-pane sync toggles (e.g. restoring saved
|
|
25177
|
+
* state or mirroring a host-owned settings UI). Accepts a partial patch —
|
|
25178
|
+
* omitted keys keep their current value.
|
|
25179
|
+
*
|
|
25180
|
+
* Updates the chart-owned layout popover's toggles in place. Unlike a user
|
|
25181
|
+
* click inside the popover, this does NOT emit a `layoutChange` event, so a
|
|
25182
|
+
* host can safely call it in response to its own state without re-entrancy.
|
|
25183
|
+
* No-ops when the resolved state is unchanged.
|
|
25184
|
+
*/
|
|
25185
|
+
setLayoutSync(sync) {
|
|
25186
|
+
const next = { ...this.currentSync, ...sync };
|
|
25187
|
+
const changed = Object.keys(next).some((k) => next[k] !== this.currentSync[k]);
|
|
25188
|
+
if (!changed) return;
|
|
25189
|
+
this.currentSync = next;
|
|
25190
|
+
this.layoutPopover?.setSync(this.currentSync);
|
|
25191
|
+
}
|
|
25172
25192
|
destroy() {
|
|
25173
25193
|
this._isDestroyed = true;
|
|
25174
25194
|
this.panHandler.destroy();
|