velo-plot 2.20.0 → 3.0.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 (236) hide show
  1. package/README.md +15 -8
  2. package/dist/{ChartCore-ivzLqxVb.js → ChartCore-BpzRvN4Y.js} +978 -861
  3. package/dist/ChartCore-BpzRvN4Y.js.map +1 -0
  4. package/dist/a11y-Bw6urYpr.js +105 -0
  5. package/dist/a11y-Bw6urYpr.js.map +1 -0
  6. package/dist/angular/hooks-entry.d.ts +1 -0
  7. package/dist/angular/hooks.d.ts +26 -0
  8. package/dist/angular/index.d.ts +8 -0
  9. package/dist/angular/velo-plot.component.d.ts +46 -0
  10. package/dist/angular-hooks.d.ts +1 -0
  11. package/dist/angular-hooks.js +9 -0
  12. package/dist/angular-hooks.js.map +1 -0
  13. package/dist/angular.d.ts +1 -0
  14. package/dist/angular.js +166 -0
  15. package/dist/angular.js.map +1 -0
  16. package/dist/assets/indicator.worker-bv0zC4EX.js.map +1 -1
  17. package/dist/astro/StackedPlot.astro +19 -0
  18. package/dist/astro/VeloPlot.astro +23 -0
  19. package/dist/bindings/shared/a11y.d.ts +26 -0
  20. package/dist/bindings/shared/chartLifecycle.d.ts +16 -0
  21. package/dist/bindings/shared/chartSyncBridge.d.ts +8 -0
  22. package/dist/bindings/shared/dimensions.d.ts +1 -0
  23. package/dist/bindings/shared/index.d.ts +9 -0
  24. package/dist/bindings/shared/indicatorBridge.d.ts +11 -0
  25. package/dist/bindings/shared/optionsSync.d.ts +7 -0
  26. package/dist/bindings/shared/seriesDiff.d.ts +8 -0
  27. package/dist/bindings/shared/stackedSync.d.ts +9 -0
  28. package/dist/bindings/shared/types.d.ts +46 -0
  29. package/dist/bindings/test-utils/index.d.ts +35 -0
  30. package/dist/bindings/test-utils/mockLifecycle.d.ts +120 -0
  31. package/dist/bindings/test-utils/vitestSveltePlugin.d.ts +3 -0
  32. package/dist/chartSyncBridge-DbWrwtyP.js +57 -0
  33. package/dist/chartSyncBridge-DbWrwtyP.js.map +1 -0
  34. package/dist/core/Chart.d.ts +1 -1
  35. package/dist/core/InteractionManager.d.ts +7 -1
  36. package/dist/core/OverlayRenderer.d.ts +5 -0
  37. package/dist/core/annotations/types.d.ts +1 -1
  38. package/dist/core/chart/ChartCore.d.ts +2 -2
  39. package/dist/core/chart/types.d.ts +1 -1
  40. package/dist/core/clipboard/index.d.ts +1 -1
  41. package/dist/core/debug/index.d.ts +1 -1
  42. package/dist/core/keybindings/index.d.ts +1 -1
  43. package/dist/core/loading/index.d.ts +1 -1
  44. package/dist/core/locale/index.d.ts +1 -1
  45. package/dist/core/stacked/paneResize.d.ts +3 -0
  46. package/dist/core/stacked/types.d.ts +10 -0
  47. package/dist/core/theme-editor/index.d.ts +1 -1
  48. package/dist/createStackedChart-Dm-YqUT7.js +756 -0
  49. package/dist/createStackedChart-Dm-YqUT7.js.map +1 -0
  50. package/dist/examples/PluginDemonstration.d.ts +1 -1
  51. package/dist/gpuRenderer-BpaMYz-k.js.map +1 -1
  52. package/dist/hooks-CYPCxoZx.js +69 -0
  53. package/dist/hooks-CYPCxoZx.js.map +1 -0
  54. package/dist/{index-BBpJwOct.js → index-0InEyj0q.js} +119 -121
  55. package/dist/index-0InEyj0q.js.map +1 -0
  56. package/dist/index-BMiZoKmm.js.map +1 -1
  57. package/dist/{index-DoYxf1cV.js → index-CWxIHdwX.js} +38 -98
  58. package/dist/index-CWxIHdwX.js.map +1 -0
  59. package/dist/index-CaXWSOTk.js.map +1 -1
  60. package/dist/index-Dag88bW4.js.map +1 -1
  61. package/dist/index-qhscKTDy.js.map +1 -1
  62. package/dist/index-qunX30Xu.js.map +1 -1
  63. package/dist/index-x4stH3jD.js.map +1 -1
  64. package/dist/{index.core-COREBDNq.js → index.core-BmZe2jRQ.js} +9 -9
  65. package/dist/index.core-BmZe2jRQ.js.map +1 -0
  66. package/dist/index.core.d.ts +1 -1
  67. package/dist/index.d.ts +2 -2
  68. package/dist/indicators--eJGmVox.js.map +1 -1
  69. package/dist/{mockDatafeed-927foCM4.js → mockDatafeed-DHIDPcpX.js} +150 -146
  70. package/dist/mockDatafeed-DHIDPcpX.js.map +1 -0
  71. package/dist/optionsSync-QUiN4Inw.js +119 -0
  72. package/dist/optionsSync-QUiN4Inw.js.map +1 -0
  73. package/dist/plugins/3d/index.d.ts +2 -2
  74. package/dist/plugins/3d.d.ts +2 -2
  75. package/dist/plugins/3d.js.map +1 -1
  76. package/dist/plugins/analysis/index.d.ts +1 -1
  77. package/dist/plugins/analysis/indicators.d.ts +1 -1
  78. package/dist/plugins/analysis.d.ts +2 -2
  79. package/dist/plugins/analysis.js +2 -2
  80. package/dist/plugins/analysis.js.map +1 -1
  81. package/dist/plugins/annotations/index.d.ts +1 -1
  82. package/dist/plugins/annotations.d.ts +2 -2
  83. package/dist/plugins/annotations.js.map +1 -1
  84. package/dist/plugins/anomaly-detection.js +1 -1
  85. package/dist/plugins/anomaly-detection.js.map +1 -1
  86. package/dist/plugins/broken-axis.d.ts +2 -2
  87. package/dist/plugins/builtins/crosshair/CrosshairPlugin.d.ts +1 -1
  88. package/dist/plugins/builtins/index.d.ts +1 -1
  89. package/dist/plugins/caching.d.ts +2 -2
  90. package/dist/plugins/clipboard/index.d.ts +2 -2
  91. package/dist/plugins/clipboard.d.ts +2 -2
  92. package/dist/plugins/clipboard.js.map +1 -1
  93. package/dist/plugins/context-menu/index.d.ts +1 -1
  94. package/dist/plugins/context-menu.d.ts +2 -2
  95. package/dist/plugins/context-menu.js +1 -1
  96. package/dist/plugins/context-menu.js.map +1 -1
  97. package/dist/plugins/data-export/index.d.ts +1 -1
  98. package/dist/plugins/data-export.d.ts +2 -2
  99. package/dist/plugins/data-export.js +2 -2
  100. package/dist/plugins/data-export.js.map +1 -1
  101. package/dist/plugins/data-transform.d.ts +2 -2
  102. package/dist/plugins/data-transform.js +19 -19
  103. package/dist/plugins/data-transform.js.map +1 -1
  104. package/dist/plugins/debug/index.d.ts +2 -2
  105. package/dist/plugins/debug.d.ts +2 -2
  106. package/dist/plugins/debug.js +2 -2
  107. package/dist/plugins/debug.js.map +1 -1
  108. package/dist/plugins/forecasting/index.d.ts +1 -1
  109. package/dist/plugins/forecasting.js.map +1 -1
  110. package/dist/plugins/gpu/index.d.ts +2 -2
  111. package/dist/plugins/gpu.d.ts +2 -2
  112. package/dist/plugins/gpu.js.map +1 -1
  113. package/dist/plugins/i18n/index.d.ts +2 -2
  114. package/dist/plugins/i18n.d.ts +2 -2
  115. package/dist/plugins/i18n.js.map +1 -1
  116. package/dist/plugins/index.d.ts +1 -1
  117. package/dist/plugins/keyboard.d.ts +2 -2
  118. package/dist/plugins/keyboard.js +65 -5
  119. package/dist/plugins/keyboard.js.map +1 -1
  120. package/dist/plugins/latex.js.map +1 -1
  121. package/dist/plugins/lazy-load.d.ts +2 -2
  122. package/dist/plugins/loading/index.d.ts +1 -1
  123. package/dist/plugins/loading.d.ts +2 -2
  124. package/dist/plugins/ml-integration.d.ts +2 -2
  125. package/dist/plugins/ml-integration.js +5 -5
  126. package/dist/plugins/ml-integration.js.map +1 -1
  127. package/dist/plugins/offscreen.d.ts +2 -2
  128. package/dist/plugins/pattern-recognition.d.ts +2 -2
  129. package/dist/plugins/pattern-recognition.js +1 -1
  130. package/dist/plugins/pattern-recognition.js.map +1 -1
  131. package/dist/plugins/radar.d.ts +2 -2
  132. package/dist/plugins/regression.d.ts +2 -2
  133. package/dist/plugins/regression.js +1 -1
  134. package/dist/plugins/regression.js.map +1 -1
  135. package/dist/plugins/roi.js +9 -9
  136. package/dist/plugins/roi.js.map +1 -1
  137. package/dist/plugins/snapshot/index.d.ts +1 -1
  138. package/dist/plugins/snapshot/types.d.ts +1 -1
  139. package/dist/plugins/snapshot.d.ts +2 -2
  140. package/dist/plugins/snapshot.js.map +1 -1
  141. package/dist/plugins/streaming/index.d.ts +2 -2
  142. package/dist/plugins/streaming.d.ts +2 -2
  143. package/dist/plugins/sync/index.d.ts +3 -2
  144. package/dist/plugins/sync.d.ts +2 -2
  145. package/dist/plugins/sync.js.map +1 -1
  146. package/dist/plugins/theme-editor/index.d.ts +1 -1
  147. package/dist/plugins/theme-editor.d.ts +2 -2
  148. package/dist/plugins/tools/index.d.ts +1 -1
  149. package/dist/plugins/tools/tooltip/index.d.ts +1 -1
  150. package/dist/plugins/tools.d.ts +2 -2
  151. package/dist/plugins/types.d.ts +1 -1
  152. package/dist/plugins/video-recorder.d.ts +2 -2
  153. package/dist/plugins/virtualization.d.ts +2 -2
  154. package/dist/plugins/virtualization.js +1 -1
  155. package/dist/pool-DZ8shSqv.js +109 -0
  156. package/dist/pool-DZ8shSqv.js.map +1 -0
  157. package/dist/react/StackedPlot.d.ts +31 -0
  158. package/dist/react/VeloPlot.d.ts +29 -0
  159. package/dist/react/index.d.ts +25 -3
  160. package/dist/react/useChartSync.d.ts +8 -0
  161. package/dist/react/useIndicator.d.ts +12 -0
  162. package/dist/react/useVeloPlot.d.ts +19 -0
  163. package/dist/react.js +328 -24
  164. package/dist/react.js.map +1 -1
  165. package/dist/scientific/index.d.ts +48 -0
  166. package/dist/scientific.d.ts +1 -0
  167. package/dist/scientific.js +91 -0
  168. package/dist/scientific.js.map +1 -0
  169. package/dist/solid/VeloPlot.d.ts +16 -0
  170. package/dist/solid/index.d.ts +13 -0
  171. package/dist/solid/useChartSync.d.ts +6 -0
  172. package/dist/solid/useIndicator.d.ts +11 -0
  173. package/dist/solid/useStackedPlot.d.ts +14 -0
  174. package/dist/solid/useVeloPlot.d.ts +18 -0
  175. package/dist/solid.d.ts +1 -0
  176. package/dist/solid.js +172 -0
  177. package/dist/solid.js.map +1 -0
  178. package/dist/stackedSync-tnrunZMt.js +100 -0
  179. package/dist/stackedSync-tnrunZMt.js.map +1 -0
  180. package/dist/svelte/StackedPlot.svelte +29 -0
  181. package/dist/svelte/StackedPlot.test.ts +114 -0
  182. package/dist/svelte/VeloPlot.svelte +44 -0
  183. package/dist/svelte/VeloPlot.test.ts +105 -0
  184. package/dist/svelte/index.d.ts +11 -0
  185. package/dist/svelte/index.test.ts +20 -0
  186. package/dist/svelte/index.ts +15 -0
  187. package/dist/svelte/useChartSync.d.ts +8 -0
  188. package/dist/svelte/useChartSync.test.ts +49 -0
  189. package/dist/svelte/useChartSync.ts +29 -0
  190. package/dist/svelte/useIndicator.d.ts +13 -0
  191. package/dist/svelte/useIndicator.test.ts +67 -0
  192. package/dist/svelte/useIndicator.ts +43 -0
  193. package/dist/svelte/useStackedPlot.d.ts +16 -0
  194. package/dist/svelte/useStackedPlot.test.ts +76 -0
  195. package/dist/svelte/useStackedPlot.ts +54 -0
  196. package/dist/svelte/useVeloPlot.d.ts +21 -0
  197. package/dist/svelte/useVeloPlot.test.ts +100 -0
  198. package/dist/svelte/useVeloPlot.ts +81 -0
  199. package/dist/svelte.d.ts +1 -0
  200. package/dist/svelte.js +143 -0
  201. package/dist/svelte.js.map +1 -0
  202. package/dist/testing/index.d.ts +1 -1
  203. package/dist/theme/index.d.ts +2 -1
  204. package/dist/trading.js +6 -6
  205. package/dist/types.d.ts +1 -1
  206. package/dist/{utils-BK5UUXxj.js → utils-Dx0h0bgQ.js} +9 -9
  207. package/dist/{utils-BK5UUXxj.js.map → utils-Dx0h0bgQ.js.map} +1 -1
  208. package/dist/velo-plot.full.js +452 -443
  209. package/dist/velo-plot.full.js.map +1 -1
  210. package/dist/velo-plot.js +15 -15
  211. package/dist/vue/StackedPlot.vue.d.ts +48 -0
  212. package/dist/vue/VeloPlot.vue.d.ts +64 -0
  213. package/dist/vue/index.d.ts +250 -0
  214. package/dist/vue/useChartSync.d.ts +52 -0
  215. package/dist/vue/useIndicator.d.ts +23 -0
  216. package/dist/vue/useStackedPlot.d.ts +15 -0
  217. package/dist/vue/useVeloPlot.d.ts +20 -0
  218. package/dist/vue.d.ts +1 -0
  219. package/dist/vue.js +312 -0
  220. package/dist/vue.js.map +1 -0
  221. package/dist/workers/indicatorsAsync.d.ts +2 -0
  222. package/dist/workers/pool.d.ts +9 -0
  223. package/package.json +88 -10
  224. package/dist/ChartCore-ivzLqxVb.js.map +0 -1
  225. package/dist/SciPlot-CEU4ApgD.js +0 -463
  226. package/dist/SciPlot-CEU4ApgD.js.map +0 -1
  227. package/dist/createStackedChart-DxNW0VkF.js +0 -705
  228. package/dist/createStackedChart-DxNW0VkF.js.map +0 -1
  229. package/dist/index-BBpJwOct.js.map +0 -1
  230. package/dist/index-DoYxf1cV.js.map +0 -1
  231. package/dist/index.core-COREBDNq.js.map +0 -1
  232. package/dist/mockDatafeed-927foCM4.js.map +0 -1
  233. package/dist/pool-15HMCNv8.js +0 -88
  234. package/dist/pool-15HMCNv8.js.map +0 -1
  235. package/dist/react/SciPlot.d.ts +0 -60
  236. package/dist/react/useSciPlot.d.ts +0 -56
@@ -1,705 +0,0 @@
1
- import { m as Mt, M as W, c as St, g as Ot, a as Yt, r as Bt, h as _t, b as jt, i as Nt } from "./ChartCore-ivzLqxVb.js";
2
- import { c as qt } from "./index-CaXWSOTk.js";
3
- const ot = 5, rt = 1 / 6, Gt = { top: 4, bottom: 8, left: 4 }, Lt = { bottom: 55 };
4
- function Wt(t) {
5
- if (typeof t == "number") return t;
6
- switch (t) {
7
- case "8k":
8
- return 8;
9
- case "4k":
10
- return 4;
11
- case "2k":
12
- return 2;
13
- default:
14
- return 1;
15
- }
16
- }
17
- function Ut(t) {
18
- return new Promise((n, o) => {
19
- const r = new Image();
20
- r.onload = () => n(r), r.onerror = o, r.src = t;
21
- });
22
- }
23
- function Pt(t, n) {
24
- const o = t.getBoundingClientRect();
25
- return {
26
- x: o.left - n.left,
27
- y: o.top - n.top,
28
- width: o.width,
29
- height: o.height
30
- };
31
- }
32
- async function Kt(t, n, o, r, a, d = {}) {
33
- var f;
34
- const {
35
- format: b = "png",
36
- quality: k = 0.92,
37
- resolution: y = "standard",
38
- includeBackground: R = !0,
39
- includeDividers: X = !0,
40
- transparent: H = !1
41
- } = d, E = Wt(y), C = (((f = o[0]) == null ? void 0 : f.getDPR()) ?? (typeof window < "u" ? window.devicePixelRatio : 1)) * E, B = o.map((l) => l.getDPR());
42
- try {
43
- if (E > 1) {
44
- for (const u of o)
45
- typeof u.setDevicePixelRatioOverride == "function" ? u.setDevicePixelRatioOverride(C) : u.setDPR(C), u.render();
46
- await new Promise((u) => requestAnimationFrame(u)), await new Promise((u) => requestAnimationFrame(u)), await new Promise((u) => setTimeout(u, 50));
47
- }
48
- const l = t.getBoundingClientRect(), T = Math.max(1, Math.round(l.width * C)), S = Math.max(1, Math.round(l.height * C)), h = document.createElement("canvas");
49
- h.width = T, h.height = S;
50
- const m = h.getContext("2d");
51
- if (!m) throw new Error("Failed to create export canvas");
52
- !H && R && (m.fillStyle = a || "#ffffff", m.fillRect(0, 0, T, S));
53
- const g = b === "jpeg" ? "jpeg" : "png";
54
- for (let u = 0; u < n.length; u++) {
55
- const w = Pt(n[u], l), D = o[u].exportImage(g), A = await Ut(D);
56
- m.drawImage(
57
- A,
58
- Math.round(w.x * C),
59
- Math.round(w.y * C),
60
- Math.round(w.width * C),
61
- Math.round(w.height * C)
62
- );
63
- }
64
- if (X && r.length) {
65
- m.fillStyle = "rgba(128, 128, 128, 0.35)";
66
- for (const u of r) {
67
- const w = Pt(u, l);
68
- m.fillRect(
69
- Math.round(w.x * C),
70
- Math.round(w.y * C),
71
- Math.max(1, Math.round(w.width * C)),
72
- Math.max(1, Math.round(w.height * C))
73
- );
74
- }
75
- }
76
- const v = b === "jpeg" ? "image/jpeg" : b === "webp" ? "image/webp" : "image/png";
77
- return h.toDataURL(v, k);
78
- } finally {
79
- if (E > 1)
80
- for (let l = 0; l < o.length; l++)
81
- typeof o[l].setDevicePixelRatioOverride == "function" ? o[l].setDevicePixelRatioOverride(null) : o[l].setDPR(B[l]), o[l].render();
82
- }
83
- }
84
- const L = "velo-pane-divider", F = "velo-pane-resizing";
85
- function Qt(t) {
86
- if (typeof document > "u") return;
87
- let n = document.getElementById("velo-pane-divider-styles");
88
- n || (n = document.createElement("style"), n.id = "velo-pane-divider-styles", document.head.appendChild(n));
89
- const r = t === "horizontal" ? "ew-resize" : "ns-resize";
90
- n.textContent = `
91
- .${L} {
92
- flex: 0 0 var(--velo-divider-size, 6px);
93
- position: relative;
94
- cursor: ${r};
95
- touch-action: none;
96
- z-index: 20;
97
- background: transparent;
98
- user-select: none;
99
- }
100
- .${L}::after {
101
- content: "";
102
- position: absolute;
103
- background: rgba(128, 128, 128, 0.35);
104
- transition: background 0.15s;
105
- }
106
- .${L}[data-direction="vertical"]::after {
107
- left: 0;
108
- right: 0;
109
- top: 50%;
110
- transform: translateY(-50%);
111
- height: 1px;
112
- }
113
- .${L}[data-direction="horizontal"]::after {
114
- top: 0;
115
- bottom: 0;
116
- left: 50%;
117
- transform: translateX(-50%);
118
- width: 1px;
119
- }
120
- .${L}:hover::after,
121
- .${F} .${L}::after {
122
- background: rgba(0, 242, 255, 0.65);
123
- }
124
- .${L}[data-direction="vertical"]:hover::after,
125
- .${F} .${L}[data-direction="vertical"]::after {
126
- height: 2px;
127
- }
128
- .${L}[data-direction="horizontal"]:hover::after,
129
- .${F} .${L}[data-direction="horizontal"]::after {
130
- width: 2px;
131
- }
132
- .${L}-handle {
133
- position: absolute;
134
- left: 50%;
135
- top: 50%;
136
- transform: translate(-50%, -50%);
137
- width: 32px;
138
- height: 12px;
139
- display: flex;
140
- align-items: center;
141
- justify-content: center;
142
- opacity: 0;
143
- transition: opacity 0.15s;
144
- pointer-events: none;
145
- color: rgba(0, 242, 255, 0.9);
146
- font-size: 10px;
147
- line-height: 1;
148
- }
149
- .${L}:hover .${L}-handle,
150
- .${F} .${L}-handle {
151
- opacity: 1;
152
- }
153
- .${F} {
154
- cursor: ${r} !important;
155
- }
156
- .${F} * {
157
- cursor: ${r} !important;
158
- }
159
- .${F} [data-pane-id] {
160
- position: relative !important;
161
- overflow: hidden !important;
162
- }
163
- `;
164
- }
165
- function Zt(t, n, o) {
166
- const r = document.createElement("div");
167
- r.className = L, r.dataset.dividerIndex = String(t), r.dataset.direction = o, r.style.setProperty("--velo-divider-size", `${n}px`);
168
- const a = document.createElement("div");
169
- return a.className = `${L}-handle`, a.textContent = o === "horizontal" ? "⇔" : "⇕", r.appendChild(a), r;
170
- }
171
- function Vt(t, n) {
172
- const o = n === "horizontal" ? "min-width:0;" : "min-height:0;";
173
- return typeof t == "number" ? `flex:${t} 1 0;${o}` : `flex:1 1 ${t};${o}`;
174
- }
175
- function kt(t, n, o = rt, r = 0) {
176
- if (n < 1 || t <= 0) return 1;
177
- const a = t * o, d = Math.max(r, a);
178
- return Math.min(d, t / n);
179
- }
180
- function Jt(t, n, o = rt, r = 0) {
181
- return kt(t, n, o, r);
182
- }
183
- function te(t, n) {
184
- const o = t.length;
185
- if (o === 0) return t;
186
- const r = Math.max(1, Math.round(n)), a = t.reduce((y, R) => y + R, 0);
187
- if (a <= 0) {
188
- const y = Math.floor(r / o), R = t.map(() => y);
189
- return R[o - 1] = r - y * (o - 1), R;
190
- }
191
- const d = t.map((y) => y / a * r), b = [];
192
- let k = 0;
193
- for (let y = 0; y < o - 1; y++)
194
- b.push(Math.max(1, Math.round(d[y]))), k += b[y];
195
- return b.push(Math.max(1, r - k)), b;
196
- }
197
- function ee(t, n, o, r, a = {}) {
198
- const d = a.direction ?? "vertical", b = d === "horizontal";
199
- Qt(d);
200
- const k = a.minPaneRatio ?? rt, y = a.minPanePx ?? 0, R = a.dividerSize ?? 6, X = n.length, H = (f) => b ? Jt(f, X, k, y) : kt(f, X, k, y), E = [], q = [];
201
- if (n.length < 2)
202
- return { dividers: E, destroy: () => {
203
- } };
204
- const C = () => {
205
- const f = E.length * R, l = b ? t.clientWidth : t.clientHeight;
206
- return Math.max(1, l - f);
207
- }, B = (f, l, T, S) => {
208
- var A;
209
- const h = C(), m = H(h), g = S.reduce(
210
- (x, z, I) => I === f || I === l ? x : x + z,
211
- 0
212
- ), v = h - g;
213
- let u = S[f] + T;
214
- u = Math.max(m, Math.min(v - m, u));
215
- const w = v - u;
216
- S[f] = u, S[l] = w;
217
- const D = r.reduce((x, z) => x + z, 0);
218
- if (r[f] = u / h * D, r[l] = w / h * D, (A = a.onDragMove) == null || A.call(a, S, f, l), a.onResize) {
219
- const x = {};
220
- for (let z = 0; z < o.length; z++)
221
- x[o[z]] = r[z];
222
- a.onResize(x);
223
- }
224
- };
225
- for (let f = 0; f < n.length - 1; f++) {
226
- const l = Zt(f, R, d);
227
- n[f].after(l), E.push(l);
228
- const S = (h) => {
229
- var w, D;
230
- h.preventDefault(), l.setPointerCapture(h.pointerId), t.classList.add(F);
231
- const m = ((w = a.onDragStart) == null ? void 0 : w.call(a, f, f + 1)) ?? n.map(
232
- (A) => b ? A.getBoundingClientRect().width : A.getBoundingClientRect().height
233
- );
234
- (D = a.onDragMove) == null || D.call(a, m, f, f + 1);
235
- let g = b ? h.clientX : h.clientY;
236
- const v = (A) => {
237
- const x = b ? A.clientX : A.clientY, z = x - g;
238
- g = x, z !== 0 && B(f, f + 1, z, m);
239
- }, u = (A) => {
240
- var x;
241
- l.releasePointerCapture(A.pointerId), t.classList.remove(F), l.removeEventListener("pointermove", v), l.removeEventListener("pointerup", u), l.removeEventListener("pointercancel", u), (x = a.onDragEnd) == null || x.call(a, m);
242
- };
243
- l.addEventListener("pointermove", v), l.addEventListener("pointerup", u), l.addEventListener("pointercancel", u);
244
- };
245
- l.addEventListener("pointerdown", S), q.push(() => l.removeEventListener("pointerdown", S));
246
- }
247
- return {
248
- dividers: E,
249
- destroy: () => {
250
- for (const f of q) f();
251
- for (const f of E) f.remove();
252
- t.classList.remove(F);
253
- }
254
- };
255
- }
256
- function ne(t, n, o = "vertical") {
257
- for (let r = 0; r < t.length; r++)
258
- t[r].style.cssText = `${Vt(n[r], o)}position:relative;overflow:hidden;`;
259
- }
260
- function Rt(t) {
261
- return typeof t == "number" ? t : 1;
262
- }
263
- function oe(t, n = 6) {
264
- if (!Number.isFinite(t) || t <= 0) return n;
265
- const o = Math.floor(t / 36);
266
- return Math.max(2, Math.min(n, o));
267
- }
268
- function ie(t, n = 8) {
269
- if (!Number.isFinite(t) || t <= 0) return n;
270
- const o = Math.floor(t / 72);
271
- return Math.max(2, Math.min(n, o));
272
- }
273
- function zt(t) {
274
- var o;
275
- return t ? ((o = (Array.isArray(t) ? t : [t])[0]) == null ? void 0 : o.tickCount) ?? 6 : 6;
276
- }
277
- function re(t) {
278
- const n = t.wrapper.clientHeight, o = t.wrapper.clientWidth, r = oe(n, t.baseYTickCount);
279
- if (t.chart.updateYAxis("default", { tickCount: r }), t.showXAxis) {
280
- const a = ie(o, t.baseXTickCount);
281
- t.chart.updateXAxis({ tickCount: a });
282
- }
283
- }
284
- function Ct(t) {
285
- for (const n of t) re(n);
286
- }
287
- function Et(t) {
288
- const n = t ? Array.isArray(t) ? t : [t] : [{}];
289
- let o = 0, r = 0;
290
- for (const a of n)
291
- a.position === "right" ? r++ : o++;
292
- return { left: Math.max(1, o), right: r };
293
- }
294
- function ae(t, n) {
295
- var r;
296
- let o = 0;
297
- for (const a of t) {
298
- const { left: d } = Et((r = a.chart) == null ? void 0 : r.yAxis);
299
- o = Math.max(o, (d - 1) * 65);
300
- }
301
- return n + o;
302
- }
303
- function se(t, n) {
304
- var r;
305
- let o = 0;
306
- for (const a of t) {
307
- const { right: d } = Et((r = a.chart) == null ? void 0 : r.yAxis);
308
- o = Math.max(o, d * 65);
309
- }
310
- return n + o;
311
- }
312
- function ce(t, n) {
313
- return `flex:${t} 1 0;${n === "horizontal" ? "min-width:0;" : "min-height:0;"}`;
314
- }
315
- function $t(t) {
316
- if (!(t != null && t.length)) return [];
317
- const n = [];
318
- for (const o of t)
319
- o.type === "indicator" ? n.push(...Ot(o)) : n.push(o);
320
- return n;
321
- }
322
- function Dt(t, n, o, r, a, d, b, k, y) {
323
- var D, A, x, z, I, V, U, K, Q, J, tt, et, nt;
324
- const R = r === 0, X = r === a - 1, H = y === "horizontal", q = !H && o.sharedXAxis !== "none" && !b, B = H && (o.sharedYAxis ?? "left") !== "none" && !k, l = (o.gap ?? 0) > 0 ? Gt : { top: 0, bottom: 0, left: 0 }, T = H ? {
325
- top: d.top,
326
- right: X ? d.right : l.left,
327
- left: B ? l.left : d.left,
328
- bottom: d.bottom
329
- } : {
330
- top: R ? d.top : l.top,
331
- right: d.right,
332
- left: d.left,
333
- bottom: q ? l.bottom : X ? ((A = (D = o.layout) == null ? void 0 : D.margins) == null ? void 0 : A.bottom) ?? Lt.bottom : d.bottom
334
- }, S = ((x = t.chart) == null ? void 0 : x.xAxis) ?? {}, h = {
335
- ...S,
336
- showLine: b ? S.showLine ?? !0 : !1,
337
- showTicks: b ? S.showTicks ?? !0 : !1,
338
- showLabels: b ? S.showLabels ?? !0 : !1
339
- }, m = ((z = t.chart) == null ? void 0 : z.yAxis) ?? {}, v = (Array.isArray(m) ? m : [m]).map((G) => ({
340
- ...G,
341
- showLine: k ? G.showLine ?? !0 : !1,
342
- showTicks: k ? G.showTicks ?? !0 : !1,
343
- showLabels: k ? G.showLabels ?? !0 : !1
344
- })), u = Array.isArray((I = t.chart) == null ? void 0 : I.yAxis) ? v : v[0];
345
- return (t.interactive ?? !0) || (n.style.pointerEvents = "none"), {
346
- ...t.chart,
347
- id: t.id,
348
- container: n,
349
- showLegend: ((V = t.chart) == null ? void 0 : V.showLegend) ?? o.showLegend ?? !1,
350
- theme: ((U = t.chart) == null ? void 0 : U.theme) ?? o.theme,
351
- devicePixelRatio: o.devicePixelRatio ?? ((K = t.chart) == null ? void 0 : K.devicePixelRatio),
352
- loading: ((Q = t.chart) == null ? void 0 : Q.loading) ?? !1,
353
- xAxis: h,
354
- yAxis: u,
355
- layout: Mt({
356
- ...o.layout,
357
- ...(J = t.chart) == null ? void 0 : J.layout,
358
- margins: { ...T, ...(tt = o.layout) == null ? void 0 : tt.margins, ...(nt = (et = t.chart) == null ? void 0 : et.layout) == null ? void 0 : nt.margins }
359
- })
360
- };
361
- }
362
- function it(t, n, o, r) {
363
- const a = n > 0 && o > 0 ? r === "horizontal" ? `margin-left:${n}px;` : `margin-top:${n}px;` : "";
364
- return `${ce(t, r)}position:relative;overflow:hidden;${a}`;
365
- }
366
- function le(t, n, o) {
367
- return t === !1 ? {
368
- axis: "none",
369
- syncCursor: !1,
370
- syncZoom: !1,
371
- syncPan: !1,
372
- bidirectional: !0,
373
- masterId: void 0
374
- } : {
375
- axis: o === "horizontal" ? "y" : "x",
376
- bidirectional: !0,
377
- masterId: n,
378
- syncCursor: !0,
379
- syncZoom: !0,
380
- syncPan: !0,
381
- ...typeof t == "object" ? t : {}
382
- };
383
- }
384
- function fe(t) {
385
- var ut, ht, ft, mt, gt, pt, yt, xt;
386
- const { container: n, panes: o } = t;
387
- if (!n) throw new Error("[StackedChart] container is required");
388
- if (o.length < 1 || o.length > ot)
389
- throw new Error(`[StackedChart] panes must be 1–${ot}`);
390
- const r = t.masterPaneId ?? o[0].id, a = t.direction ?? "vertical", d = a === "horizontal", b = t.sharedXAxis ?? "bottom", k = t.sharedYAxis ?? "left", y = t.gap ?? 0, R = t.resizable, X = !!R, H = typeof R == "object" ? R.dividerSize ?? 6 : 6, E = Mt(t.layout), q = ((ut = E.margins) == null ? void 0 : ut.left) ?? W.left, C = ((ht = E.margins) == null ? void 0 : ht.right) ?? W.right, B = ((ft = E.margins) == null ? void 0 : ft.top) ?? W.top, f = ae(o, q), l = se(o, C);
391
- n.replaceChildren(), n.style.display = "flex", n.style.flexDirection = d ? "row" : "column", n.style.width = "100%";
392
- const T = n.offsetHeight || parseInt(getComputedStyle(n).height, 10), S = n.offsetWidth || parseInt(getComputedStyle(n).width, 10);
393
- d ? (S > 0 && (n.style.width = `${S}px`, n.style.minWidth = `${S}px`), n.style.height = T > 0 ? `${T}px` : "320px", n.style.minHeight = n.style.height) : T > 0 ? (n.style.height = `${T}px`, n.style.minHeight = `${T}px`) : n.style.height || (n.style.minHeight = "320px"), n.style.overflow = "hidden", n.style.position = "relative";
394
- const h = o.map((e) => e.id), m = o.map((e) => Rt(e.height)), g = /* @__PURE__ */ new Map(), v = [], u = [];
395
- let w = null, D = !1, A = 0, x = 0, z = null;
396
- const I = (e) => {
397
- const i = Array.from({ length: v.length }, (s, c) => c);
398
- for (const s of i) {
399
- const c = g.get(h[s]);
400
- c && c.resize();
401
- }
402
- Ct(
403
- i.map((s) => u[s]).filter(Boolean)
404
- );
405
- }, V = () => {
406
- A || (A = requestAnimationFrame(() => {
407
- A = 0, !D && I();
408
- }));
409
- }, U = new ResizeObserver(() => {
410
- D || V();
411
- });
412
- U.observe(n);
413
- const K = () => {
414
- for (let e = 0; e < v.length; e++)
415
- v[e].style.cssText = it(m[e], y, e, a);
416
- }, Q = () => {
417
- const e = (v.length - 1) * H;
418
- return d ? Math.max(1, n.clientWidth - e) : Math.max(1, n.clientHeight - e);
419
- }, J = () => {
420
- for (const e of v) {
421
- const i = e.firstElementChild;
422
- i && (i.style.cssText = "position:absolute;inset:0;width:100%;height:100%;");
423
- }
424
- }, tt = () => {
425
- const e = Q(), i = v.map(
426
- (c) => d ? c.getBoundingClientRect().width : c.getBoundingClientRect().height
427
- ), s = i.reduce((c, p) => c + p, 0);
428
- return s > 0 ? i.map((c) => c * (e / s)) : i;
429
- }, et = (e) => {
430
- for (let i = 0; i < v.length; i++) {
431
- const s = Math.max(1, Math.round(e[i])), c = y > 0 && i > 0 ? d ? `margin-left:${y}px;` : `margin-top:${y}px;` : "", p = d ? "width" : "height";
432
- v[i].style.cssText = `${p}:${s}px;flex:0 0 auto;min-height:0;min-width:0;position:relative;overflow:hidden;${c}`;
433
- }
434
- }, nt = () => {
435
- if (x = 0, !D || !z) return;
436
- const { sizes: e, leadingIdx: i, trailingIdx: s } = z;
437
- et(e);
438
- for (const c of [i, s]) {
439
- const p = g.get(h[c]);
440
- p && (p.resize(), Ct([u[c]]));
441
- }
442
- }, G = (e, i, s) => {
443
- z = { sizes: e, leadingIdx: i, trailingIdx: s }, !x && (x = requestAnimationFrame(nt));
444
- }, Tt = (e) => {
445
- const i = e.reduce((c, p) => c + p, 0);
446
- if (i <= 0) return;
447
- const s = m.reduce((c, p) => c + p, 0);
448
- for (let c = 0; c < m.length; c++)
449
- m[c] = e[c] / i * s;
450
- }, at = (e) => {
451
- var i;
452
- for (const s of g.values())
453
- (i = s.setResizeSuspended) == null || i.call(s, e);
454
- }, It = (e, i) => {
455
- var s, c, p, $, P, O;
456
- for (let M = 0; M < h.length; M++)
457
- M === e || M === i || (c = (s = g.get(h[M])) == null ? void 0 : s.setResizeSuspended) == null || c.call(s, !0);
458
- ($ = (p = g.get(h[e])) == null ? void 0 : p.setResizeSuspended) == null || $.call(p, !1), (O = (P = g.get(h[i])) == null ? void 0 : P.setResizeSuspended) == null || O.call(P, !1);
459
- }, st = d ? ((gt = (mt = t.layout) == null ? void 0 : mt.margins) == null ? void 0 : gt.bottom) ?? Lt.bottom : W.bottom;
460
- for (let e = 0; e < o.length; e++) {
461
- const i = o[e], s = e === 0, c = e === o.length - 1, p = d ? i.showXAxis ?? !0 : i.showXAxis ?? (b === "bottom" ? c : !0), $ = d ? i.showYAxis ?? (k === "left" ? s : !0) : i.showYAxis ?? !0, P = document.createElement("div");
462
- P.dataset.paneId = i.id, P.style.cssText = it(m[e], y, e, a);
463
- const O = document.createElement("div");
464
- O.style.cssText = "position:absolute;inset:0;width:100%;height:100%;", P.appendChild(O), n.appendChild(P), v.push(P);
465
- const M = St(
466
- Dt(
467
- i,
468
- O,
469
- t,
470
- e,
471
- o.length,
472
- {
473
- left: d && !$ ? W.left : f,
474
- right: l,
475
- top: B,
476
- bottom: st
477
- },
478
- p,
479
- $,
480
- a
481
- )
482
- ), j = $t(i.series);
483
- if (j.length)
484
- for (const N of j) M.addSeries(N);
485
- i.yRange && i.yRange !== "auto" && M.zoom({ y: i.yRange, animate: !1 }), g.set(i.id, M), u.push({
486
- chart: M,
487
- wrapper: P,
488
- baseYTickCount: zt((pt = i.chart) == null ? void 0 : pt.yAxis),
489
- baseXTickCount: ((xt = (yt = i.chart) == null ? void 0 : yt.xAxis) == null ? void 0 : xt.tickCount) ?? 8,
490
- showXAxis: p
491
- });
492
- }
493
- if (X && o.length > 1) {
494
- const e = typeof R == "object" ? {
495
- minPaneRatio: R.minPaneRatio,
496
- minPanePx: R.minPanePx,
497
- dividerSize: R.dividerSize
498
- } : {};
499
- w = ee(
500
- n,
501
- v,
502
- h,
503
- m,
504
- {
505
- direction: a,
506
- ...e,
507
- onDragStart: (i, s) => (D = !0, at(!0), It(i, s), tt()),
508
- onDragMove: (i, s, c) => {
509
- G(i, s, c);
510
- },
511
- onDragEnd: (i) => {
512
- x && (cancelAnimationFrame(x), x = 0), z = null, D = !1;
513
- const s = te(i, Q());
514
- Tt(s), J(), K(), at(!1), I();
515
- }
516
- }
517
- );
518
- }
519
- const Z = g.get(r);
520
- if (!Z)
521
- throw new Error(`[StackedChart] masterPaneId "${r}" not found in panes`);
522
- const _ = qt(
523
- Array.from(g.values()),
524
- le(t.sync, r, a)
525
- ), Ft = () => {
526
- const e = Z.theme ?? Z.baseTheme;
527
- return (e == null ? void 0 : e.backgroundColor) ?? "#ffffff";
528
- }, ct = () => {
529
- const i = Date.now();
530
- return new Promise((c) => {
531
- const p = () => {
532
- const $ = Nt();
533
- if ($.pending === 0 && !$.isProcessing || Date.now() - i > 8e3) {
534
- c();
535
- return;
536
- }
537
- setTimeout(p, 50);
538
- };
539
- p();
540
- }).then(() => new Promise((c) => {
541
- requestAnimationFrame(() => {
542
- I(), c();
543
- });
544
- }));
545
- }, lt = async (e = {}) => {
546
- await ct();
547
- for (const s of g.values()) s.render();
548
- await new Promise((s) => requestAnimationFrame(s));
549
- const i = await Kt(
550
- n,
551
- v,
552
- Array.from(g.values()),
553
- (w == null ? void 0 : w.dividers) ?? [],
554
- Ft(),
555
- e
556
- );
557
- if (e.download) {
558
- const s = e.format === "jpeg" ? "jpg" : e.format ?? "png", c = document.createElement("a");
559
- c.download = `${e.fileName ?? "velo-plot-stack"}.${s}`, c.href = i, document.body.appendChild(c), c.click(), document.body.removeChild(c);
560
- }
561
- return i;
562
- }, dt = (e) => {
563
- var vt, wt, bt, At;
564
- if (g.size >= ot)
565
- throw new Error(`[StackedChart] Cannot exceed ${ot} panes`);
566
- if (g.has(e.id))
567
- throw new Error(`[StackedChart] Pane "${e.id}" already exists`);
568
- if (!d && b === "bottom" && h.length > 0) {
569
- const Y = h[h.length - 1];
570
- (vt = g.get(Y)) == null || vt.updateXAxis({
571
- showLabels: !1,
572
- showTicks: !1,
573
- showLine: !1
574
- });
575
- }
576
- const i = Rt(e.height ?? 0.25), s = m.reduce((Y, Ht) => Y + Ht, 0), c = s > 0 ? (1 - i) / s : 1;
577
- for (let Y = 0; Y < m.length; Y++) m[Y] *= c;
578
- const p = h.length;
579
- h.push(e.id), m.push(i);
580
- const $ = document.createElement("div");
581
- $.dataset.paneId = e.id, $.style.cssText = it(m[p], y, p, a);
582
- const P = document.createElement("div");
583
- P.style.cssText = "position:absolute;inset:0;width:100%;height:100%;", $.appendChild(P), n.appendChild($), v.push($);
584
- const M = d ? e.showXAxis ?? !0 : e.showXAxis ?? (b === "bottom" ? !0 : !0), j = d ? e.showYAxis ?? (k === "left" ? p === 0 : !0) : e.showYAxis ?? !0, N = St(
585
- Dt(
586
- e,
587
- P,
588
- t,
589
- p,
590
- h.length,
591
- {
592
- left: d && !j ? W.left : f,
593
- right: l,
594
- top: B,
595
- bottom: st
596
- },
597
- M,
598
- j,
599
- a
600
- )
601
- ), Xt = $t(e.series);
602
- for (const Y of Xt) N.addSeries(Y);
603
- return e.yRange && e.yRange !== "auto" && N.zoom({ y: e.yRange, animate: !1 }), g.set(e.id, N), u.push({
604
- chart: N,
605
- wrapper: $,
606
- baseYTickCount: zt((wt = e.chart) == null ? void 0 : wt.yAxis),
607
- baseXTickCount: ((At = (bt = e.chart) == null ? void 0 : bt.xAxis) == null ? void 0 : At.tickCount) ?? 8,
608
- showXAxis: M
609
- }), _.add(N), K(), I(), N;
610
- };
611
- return {
612
- container: n,
613
- getPane(e) {
614
- return g.get(e);
615
- },
616
- getPanes() {
617
- return Array.from(g.values());
618
- },
619
- getMaster() {
620
- return Z;
621
- },
622
- getGroup() {
623
- return _;
624
- },
625
- fitAll(e) {
626
- _.fitAll(e);
627
- },
628
- resetAll() {
629
- _.resetAll();
630
- },
631
- resize() {
632
- I();
633
- },
634
- getPaneRatios() {
635
- const e = {};
636
- for (let i = 0; i < h.length; i++)
637
- e[h[i]] = m[i];
638
- return e;
639
- },
640
- setPaneRatios(e) {
641
- for (let i = 0; i < h.length; i++) {
642
- const s = h[i];
643
- e[s] !== void 0 && (m[i] = e[s]);
644
- }
645
- ne(v, m, a), I();
646
- },
647
- setSyncAxis(e) {
648
- _.syncAxis(e);
649
- },
650
- getSyncAxis() {
651
- return _.getOptions().axis ?? "x";
652
- },
653
- setSyncOptions(e) {
654
- _.updateOptions(e);
655
- },
656
- whenReady() {
657
- return ct();
658
- },
659
- exportImage(e) {
660
- return lt(e);
661
- },
662
- snapshot(e) {
663
- return lt(e);
664
- },
665
- addPane(e) {
666
- return dt(e);
667
- },
668
- async addIndicator(e, i = {}) {
669
- var M;
670
- const s = g.get(r) ?? Z;
671
- if (i.pane !== "new")
672
- return { ...await Yt(s, e, i), chart: s };
673
- const c = Bt(s, i.sourceSeriesId), { x: p, prices: $ } = _t(c), P = await jt(e, p, $, {
674
- id: i.id ?? e,
675
- label: i.label ?? e.toUpperCase(),
676
- height: i.paneHeight ?? 0.25,
677
- showXAxis: i.showXAxis,
678
- period: i.period,
679
- fastPeriod: i.fastPeriod,
680
- slowPeriod: i.slowPeriod,
681
- signalPeriod: i.signalPeriod,
682
- stdDev: i.stdDev
683
- }, c), O = dt(P);
684
- return {
685
- id: P.id,
686
- preset: e,
687
- placement: "oscillator",
688
- seriesIds: ((M = P.series) == null ? void 0 : M.map((j) => j.id)) ?? [],
689
- paneId: P.id,
690
- chart: O
691
- };
692
- },
693
- destroy() {
694
- A && cancelAnimationFrame(A), x && cancelAnimationFrame(x), U.disconnect(), w == null || w.destroy(), _.destroy();
695
- for (const e of g.values()) e.destroy();
696
- g.clear(), n.replaceChildren();
697
- }
698
- };
699
- }
700
- export {
701
- ot as S,
702
- rt as a,
703
- fe as c
704
- };
705
- //# sourceMappingURL=createStackedChart-DxNW0VkF.js.map