velo-plot 3.1.0 → 4.0.0-alpha.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/dist/{ChartCore-AnR_3Xkb.js → ChartCore-KYG2HTcK.js} +1349 -1213
- package/dist/ChartCore-KYG2HTcK.js.map +1 -0
- package/dist/{PluginRegistry-CzMHebYP.js → PluginRegistry-CDf_jcnp.js} +2 -2
- package/dist/{PluginRegistry-CzMHebYP.js.map → PluginRegistry-CDf_jcnp.js.map} +1 -1
- package/dist/SVGDocumentBuilder-C-uLkcFW.js +83 -0
- package/dist/SVGDocumentBuilder-C-uLkcFW.js.map +1 -0
- package/dist/angular-hooks.js +1 -1
- package/dist/angular.js +4 -4
- package/dist/{chartSyncBridge-D_rCtbFq.js → chartSyncBridge-C1uRy0ZS.js} +3 -3
- package/dist/{chartSyncBridge-D_rCtbFq.js.map → chartSyncBridge-C1uRy0ZS.js.map} +1 -1
- package/dist/core/chart/ChartCore.d.ts +7 -3
- package/dist/core/chart/ChartRenderLoop.d.ts +5 -0
- package/dist/core/chart/ChartRenderer.d.ts +9 -0
- package/dist/core/chart/ChartSetup.d.ts +1 -0
- package/dist/core/chart/exporter/SVGExporter.d.ts +9 -7
- package/dist/core/chart/exporter/svg/SVGDocumentBuilder.d.ts +27 -0
- package/dist/core/chart/exporter/svg/SVGExportContext.d.ts +147 -0
- package/dist/core/chart/exporter/svg/SVGOrchestrator.d.ts +3 -0
- package/dist/core/chart/exporter/svg/SVGThemeAdapter.d.ts +22 -0
- package/dist/core/chart/exporter/svg/__tests__/testFixtures.d.ts +46 -0
- package/dist/core/chart/exporter/svg/__tests__/visualTestUtils.d.ts +12 -0
- package/dist/core/chart/exporter/svg/overlay/axes.d.ts +4 -0
- package/dist/core/chart/exporter/svg/overlay/border.d.ts +4 -0
- package/dist/core/chart/exporter/svg/overlay/errorBars.d.ts +7 -0
- package/dist/core/chart/exporter/svg/overlay/grid.d.ts +4 -0
- package/dist/core/chart/exporter/svg/overlay/index.d.ts +12 -0
- package/dist/core/chart/exporter/svg/overlay/legend.d.ts +4 -0
- package/dist/core/chart/exporter/svg/overlay/pluginCharts.d.ts +6 -0
- package/dist/core/chart/exporter/svg/overlay/polarGrid.d.ts +4 -0
- package/dist/core/chart/exporter/svg/overlay/specialChart.d.ts +15 -0
- package/dist/core/chart/exporter/svg/overlay/title.d.ts +4 -0
- package/dist/core/chart/exporter/svg/plugins/annotations.d.ts +5 -0
- package/dist/core/chart/exporter/svg/plugins/brokenAxis.d.ts +20 -0
- package/dist/core/chart/exporter/svg/plugins/latex.d.ts +9 -0
- package/dist/core/chart/exporter/svg/plugins/register.d.ts +8 -0
- package/dist/core/chart/exporter/svg/plugins/regression.d.ts +33 -0
- package/dist/core/chart/exporter/svg/plugins/roi.d.ts +12 -0
- package/dist/core/chart/exporter/svg/plugins/tradeMarkers.d.ts +3 -0
- package/dist/core/chart/exporter/svg/plugins/types.d.ts +28 -0
- package/dist/core/chart/exporter/svg/plugins/watermark.d.ts +13 -0
- package/dist/core/chart/exporter/svg/series/band.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/bar.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/boxplot.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/candlestick.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/finitePoints.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/gauge.d.ts +5 -0
- package/dist/core/chart/exporter/svg/series/heatmap.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/indicator.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/line.d.ts +12 -0
- package/dist/core/chart/exporter/svg/series/polar.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/radar.d.ts +5 -0
- package/dist/core/chart/exporter/svg/series/registry.d.ts +10 -0
- package/dist/core/chart/exporter/svg/series/sankey.d.ts +5 -0
- package/dist/core/chart/exporter/svg/series/scatter.d.ts +1 -0
- package/dist/core/chart/exporter/svg/series/ternary.d.ts +7 -0
- package/dist/core/chart/exporter/svg/series/waterfall.d.ts +6 -0
- package/dist/core/chart/exporter/svg/seriesAtTimestamp.d.ts +4 -0
- package/dist/core/chart/exporter/svg/seriesUtils.d.ts +3 -0
- package/dist/core/chart/exporter/svg/symbols.d.ts +5 -0
- package/dist/core/chart/exporter/svg/tickUtils.d.ts +9 -0
- package/dist/core/chart/mountSVGString.d.ts +5 -0
- package/dist/core/chart/types.d.ts +2 -2
- package/dist/core/stacked/StackSVGComposer.d.ts +14 -0
- package/dist/core/stacked/index.d.ts +3 -2
- package/dist/core/stacked/types.d.ts +12 -4
- package/dist/createStackedChart-DjA3aJAu.js +2761 -0
- package/dist/createStackedChart-DjA3aJAu.js.map +1 -0
- package/dist/{hooks-DH-3bewj.js → hooks-4wQH27r9.js} +3 -3
- package/dist/{hooks-DH-3bewj.js.map → hooks-4wQH27r9.js.map} +1 -1
- package/dist/index-Bj-xyXY6.js +582 -0
- package/dist/index-Bj-xyXY6.js.map +1 -0
- package/dist/plugins/PluginManager.d.ts +5 -0
- package/dist/plugins/annotations.js +8 -7
- package/dist/plugins/annotations.js.map +1 -1
- package/dist/plugins/broken-axis.js +198 -152
- package/dist/plugins/broken-axis.js.map +1 -1
- package/dist/plugins/forecasting.js +273 -258
- package/dist/plugins/forecasting.js.map +1 -1
- package/dist/plugins/ml-integration.js +107 -93
- package/dist/plugins/ml-integration.js.map +1 -1
- package/dist/plugins/radar/types.d.ts +11 -0
- package/dist/plugins/radar.js +64 -53
- package/dist/plugins/radar.js.map +1 -1
- package/dist/plugins/roi/index.d.ts +2 -0
- package/dist/plugins/roi.js +184 -145
- package/dist/plugins/roi.js.map +1 -1
- package/dist/plugins/snapshot.js +20 -15
- package/dist/plugins/snapshot.js.map +1 -1
- package/dist/plugins/types.d.ts +4 -0
- package/dist/react.js +2 -2
- package/dist/regression-HNdyk1Dm.js +28 -0
- package/dist/regression-HNdyk1Dm.js.map +1 -0
- package/dist/renderer/ChartSeriesRenderer.d.ts +3 -2
- package/dist/renderer/SVGChartRenderer.d.ts +15 -0
- package/dist/renderer/SankeyRenderer.d.ts +1 -0
- package/dist/renderer/registerSVG.d.ts +5 -0
- package/dist/renderer/sankeyLayout.d.ts +29 -0
- package/dist/scientific.js +2 -2
- package/dist/solid.js +2 -2
- package/dist/svelte.js +2 -2
- package/dist/tickUtils-B_X-ha13.js +41 -0
- package/dist/tickUtils-B_X-ha13.js.map +1 -0
- package/dist/trading.js +3 -3
- package/dist/types.d.ts +2 -1
- package/dist/velo-plot.full.js +1107 -1292
- package/dist/velo-plot.full.js.map +1 -1
- package/dist/velo-plot.js +2 -2
- package/dist/vue/VeloPlot.vue.d.ts +1 -1
- package/dist/vue/index.d.ts +33 -33
- package/dist/vue.js +2 -2
- package/package.json +6 -1
- package/dist/ChartCore-AnR_3Xkb.js.map +0 -1
- package/dist/createStackedChart-DqcLCFGS.js +0 -1338
- package/dist/createStackedChart-DqcLCFGS.js.map +0 -1
- package/dist/index-Cv6ZDLWf.js +0 -521
- package/dist/index-Cv6ZDLWf.js.map +0 -1
|
@@ -1,1338 +0,0 @@
|
|
|
1
|
-
import { m as _e, i as te, c as Ee, j as it } from "./ChartCore-AnR_3Xkb.js";
|
|
2
|
-
import { c as at } from "./index-CaXWSOTk.js";
|
|
3
|
-
import { f as st, m as ct, e as lt, s as dt, r as ut, a as ft } from "./indicators--eJGmVox.js";
|
|
4
|
-
import { n as ht, W as mt } from "./pool-DZ8shSqv.js";
|
|
5
|
-
function K(e) {
|
|
6
|
-
return e instanceof Float32Array || e instanceof Float64Array ? e : Float32Array.from(e);
|
|
7
|
-
}
|
|
8
|
-
function gt(e) {
|
|
9
|
-
const n = new Float32Array(e.length), t = new Float32Array(e.length);
|
|
10
|
-
for (let o = 0; o < e.length; o++) {
|
|
11
|
-
const r = e[o];
|
|
12
|
-
n[o] = r > 0 ? r : 0, t[o] = r < 0 ? r : 0;
|
|
13
|
-
}
|
|
14
|
-
return { positive: n, negative: t };
|
|
15
|
-
}
|
|
16
|
-
function yt(e, n, t) {
|
|
17
|
-
if (e === void 0 || e === "zero") return 0;
|
|
18
|
-
if (typeof e == "number") return e;
|
|
19
|
-
const o = t.find((a) => a.id === e);
|
|
20
|
-
return o ? K(o.y)[n] ?? 0 : 0;
|
|
21
|
-
}
|
|
22
|
-
function pt(e, n, t, o, r) {
|
|
23
|
-
const a = e.length;
|
|
24
|
-
if (a === 0) return [];
|
|
25
|
-
if (a === 1) {
|
|
26
|
-
const f = n[0] >= t(0) ? o : r;
|
|
27
|
-
return [{ points: [{ x: e[0], y: n[0] }], color: f }];
|
|
28
|
-
}
|
|
29
|
-
const l = [];
|
|
30
|
-
let d = null;
|
|
31
|
-
const c = (f) => n[f] >= t(f) ? o : r, h = (f, b, w) => {
|
|
32
|
-
!d || d.color !== w ? (d != null && d.points.length && l.push(d), d = { points: [{ x: f, y: b }], color: w }) : d.points.push({ x: f, y: b });
|
|
33
|
-
}, x = () => {
|
|
34
|
-
d != null && d.points.length && (l.push(d), d = null);
|
|
35
|
-
};
|
|
36
|
-
h(e[0], n[0], c(0));
|
|
37
|
-
for (let f = 1; f < a; f++) {
|
|
38
|
-
const b = n[f - 1], w = n[f], p = t(f - 1), R = t(f), v = b >= p, m = w >= R;
|
|
39
|
-
if (v === m) {
|
|
40
|
-
h(e[f], n[f], c(f));
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
const X = w - b - (R - p), D = Math.max(0, Math.min(1, (p - b) / X)), C = e[f - 1] + D * (e[f] - e[f - 1]), L = b + D * (w - b), H = v ? o : r, T = m ? o : r;
|
|
44
|
-
h(C, L, H), x(), h(C, L, T), h(e[f], n[f], c(f));
|
|
45
|
-
}
|
|
46
|
-
return x(), l;
|
|
47
|
-
}
|
|
48
|
-
function wt(e, n, t, o, r, a, l, d) {
|
|
49
|
-
const c = r.colorZones, x = pt(
|
|
50
|
-
t,
|
|
51
|
-
o,
|
|
52
|
-
(f) => yt(c.ref, f, a),
|
|
53
|
-
c.aboveColor,
|
|
54
|
-
c.belowColor
|
|
55
|
-
);
|
|
56
|
-
for (let f = 0; f < x.length; f++) {
|
|
57
|
-
const b = x[f];
|
|
58
|
-
b.points.length < 2 || e.push({
|
|
59
|
-
id: `${n}-${d}-${f}`,
|
|
60
|
-
type: "line",
|
|
61
|
-
visible: l,
|
|
62
|
-
data: {
|
|
63
|
-
x: Float32Array.from(b.points.map((w) => w.x)),
|
|
64
|
-
y: Float32Array.from(b.points.map((w) => w.y))
|
|
65
|
-
},
|
|
66
|
-
style: {
|
|
67
|
-
color: b.color,
|
|
68
|
-
width: r.width ?? 2,
|
|
69
|
-
opacity: r.opacity ?? 1
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
const vt = {
|
|
75
|
-
baselineColor: "rgba(255,255,255,0.35)",
|
|
76
|
-
baselineWidth: 1,
|
|
77
|
-
baselineDash: [4, 4],
|
|
78
|
-
peakColor: "#ff00ff",
|
|
79
|
-
troughColor: "#00ffff",
|
|
80
|
-
peakSize: 6,
|
|
81
|
-
troughSize: 6
|
|
82
|
-
};
|
|
83
|
-
function de(e) {
|
|
84
|
-
var h, x, f, b;
|
|
85
|
-
const { id: n, data: t, style: o = {}, visible: r = !0 } = e, a = { ...vt, ...o }, l = K(t.x), d = l.length, c = [];
|
|
86
|
-
if ((h = t.fills) != null && h.length)
|
|
87
|
-
for (let w = 0; w < t.fills.length; w++) {
|
|
88
|
-
const p = t.fills[w], R = p.id ?? `${n}-fill-${w}`;
|
|
89
|
-
c.push({
|
|
90
|
-
id: R,
|
|
91
|
-
type: "band",
|
|
92
|
-
visible: r,
|
|
93
|
-
data: {
|
|
94
|
-
x: l,
|
|
95
|
-
y: K(p.upper),
|
|
96
|
-
y2: K(p.lower)
|
|
97
|
-
},
|
|
98
|
-
style: {
|
|
99
|
-
color: p.color ?? "rgba(100, 80, 180, 0.25)",
|
|
100
|
-
opacity: p.opacity ?? 0.35
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
if (t.histogram) {
|
|
105
|
-
const w = K(t.histogram.y), { positive: p, negative: R } = gt(w), v = t.histogram.barWidth, m = v !== void 0 ? { barWidth: v } : {};
|
|
106
|
-
c.push({
|
|
107
|
-
id: `${n}-hist-pos`,
|
|
108
|
-
type: "bar",
|
|
109
|
-
visible: r,
|
|
110
|
-
data: { x: l, y: p },
|
|
111
|
-
style: {
|
|
112
|
-
color: t.histogram.positiveColor ?? "#26a69a",
|
|
113
|
-
opacity: t.histogram.opacity ?? 0.85,
|
|
114
|
-
...m
|
|
115
|
-
}
|
|
116
|
-
}), c.push({
|
|
117
|
-
id: `${n}-hist-neg`,
|
|
118
|
-
type: "bar",
|
|
119
|
-
visible: r,
|
|
120
|
-
data: { x: l, y: R },
|
|
121
|
-
style: {
|
|
122
|
-
color: t.histogram.negativeColor ?? "#ef5350",
|
|
123
|
-
opacity: t.histogram.opacity ?? 0.85,
|
|
124
|
-
...m
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
if ((x = t.lines) != null && x.length)
|
|
129
|
-
for (let w = 0; w < t.lines.length; w++) {
|
|
130
|
-
const p = t.lines[w], R = p.id ?? `${n}-line-${w}`, v = K(p.y);
|
|
131
|
-
if (p.colorZones) {
|
|
132
|
-
wt(c, R, l, v, p, t.lines, r, "zone");
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
c.push({
|
|
136
|
-
id: R,
|
|
137
|
-
type: "line",
|
|
138
|
-
visible: r,
|
|
139
|
-
data: { x: l, y: v },
|
|
140
|
-
style: {
|
|
141
|
-
color: p.color ?? (w === 0 ? "#00e5ff" : "#e040fb"),
|
|
142
|
-
width: p.width ?? 2,
|
|
143
|
-
opacity: p.opacity ?? 1
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
if (t.baseline !== void 0 && d >= 2) {
|
|
148
|
-
const w = t.baseline;
|
|
149
|
-
c.push({
|
|
150
|
-
id: `${n}-baseline`,
|
|
151
|
-
type: "line",
|
|
152
|
-
visible: r,
|
|
153
|
-
data: {
|
|
154
|
-
x: Float32Array.from([l[0], l[d - 1]]),
|
|
155
|
-
y: Float32Array.from([w, w])
|
|
156
|
-
},
|
|
157
|
-
style: {
|
|
158
|
-
color: a.baselineColor,
|
|
159
|
-
width: a.baselineWidth,
|
|
160
|
-
lineDash: a.baselineDash,
|
|
161
|
-
opacity: 1
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
if ((f = t.referenceLines) != null && f.length)
|
|
166
|
-
for (let w = 0; w < t.referenceLines.length; w++) {
|
|
167
|
-
const p = t.referenceLines[w];
|
|
168
|
-
c.push({
|
|
169
|
-
id: `${n}-ref-${w}`,
|
|
170
|
-
type: "line",
|
|
171
|
-
visible: r,
|
|
172
|
-
data: {
|
|
173
|
-
x: Float32Array.from([l[0], l[d - 1]]),
|
|
174
|
-
y: Float32Array.from([p.y, p.y])
|
|
175
|
-
},
|
|
176
|
-
style: {
|
|
177
|
-
color: p.color ?? "rgba(255,255,255,0.2)",
|
|
178
|
-
width: p.width ?? 1,
|
|
179
|
-
lineDash: p.dash ?? [2, 4],
|
|
180
|
-
opacity: 0.8
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
if ((b = t.markers) != null && b.length) {
|
|
185
|
-
const w = t.markers.filter((R) => R.kind === "peak"), p = t.markers.filter((R) => R.kind === "trough");
|
|
186
|
-
w.length && c.push({
|
|
187
|
-
id: `${n}-peaks`,
|
|
188
|
-
type: "scatter",
|
|
189
|
-
visible: r,
|
|
190
|
-
data: {
|
|
191
|
-
x: Float32Array.from(w.map((R) => R.x)),
|
|
192
|
-
y: Float32Array.from(w.map((R) => R.y))
|
|
193
|
-
},
|
|
194
|
-
style: {
|
|
195
|
-
color: a.peakColor,
|
|
196
|
-
pointSize: a.peakSize,
|
|
197
|
-
opacity: 1
|
|
198
|
-
}
|
|
199
|
-
}), p.length && c.push({
|
|
200
|
-
id: `${n}-troughs`,
|
|
201
|
-
type: "scatter",
|
|
202
|
-
visible: r,
|
|
203
|
-
data: {
|
|
204
|
-
x: Float32Array.from(p.map((R) => R.x)),
|
|
205
|
-
y: Float32Array.from(p.map((R) => R.y))
|
|
206
|
-
},
|
|
207
|
-
style: {
|
|
208
|
-
color: a.troughColor,
|
|
209
|
-
pointSize: a.troughSize,
|
|
210
|
-
opacity: 1
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
return c;
|
|
215
|
-
}
|
|
216
|
-
function on(e) {
|
|
217
|
-
return de(e);
|
|
218
|
-
}
|
|
219
|
-
function rn(e, n, t = 3) {
|
|
220
|
-
const o = K(e), r = K(n), a = [], l = Math.max(1, t);
|
|
221
|
-
for (let d = l; d < r.length - l; d++) {
|
|
222
|
-
let c = !0, h = !0;
|
|
223
|
-
for (let x = d - l; x <= d + l; x++)
|
|
224
|
-
x !== d && (r[x] >= r[d] && (c = !1), r[x] <= r[d] && (h = !1));
|
|
225
|
-
c ? a.push({ x: o[d], y: r[d], kind: "peak" }) : h && a.push({ x: o[d], y: r[d], kind: "trough" });
|
|
226
|
-
}
|
|
227
|
-
return a;
|
|
228
|
-
}
|
|
229
|
-
function xt(e) {
|
|
230
|
-
const t = {
|
|
231
|
-
id: e.seriesId ?? `${e.id}-indicator`,
|
|
232
|
-
data: e.data,
|
|
233
|
-
style: e.style,
|
|
234
|
-
name: e.label
|
|
235
|
-
}, o = de(t);
|
|
236
|
-
return {
|
|
237
|
-
id: e.id,
|
|
238
|
-
height: e.height ?? 0.25,
|
|
239
|
-
showXAxis: e.showXAxis,
|
|
240
|
-
yRange: e.yRange,
|
|
241
|
-
chart: {
|
|
242
|
-
yAxis: {
|
|
243
|
-
label: e.label ?? "Indicator",
|
|
244
|
-
auto: e.yRange === void 0 || e.yRange === "auto",
|
|
245
|
-
tickCount: e.tickCount ?? 5,
|
|
246
|
-
scientific: !1
|
|
247
|
-
},
|
|
248
|
-
// X-axis visibility is owned by createStackedChart (sharedXAxis / showXAxis).
|
|
249
|
-
// Do not force labels off here — the new bottom pane must show dates.
|
|
250
|
-
animations: !1,
|
|
251
|
-
loading: !1,
|
|
252
|
-
showLegend: !1
|
|
253
|
-
},
|
|
254
|
-
series: o
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
const bt = 5e3;
|
|
258
|
-
let V = null, he = !1;
|
|
259
|
-
function je(e) {
|
|
260
|
-
const n = performance.now();
|
|
261
|
-
switch (e.indicator) {
|
|
262
|
-
case "rsi":
|
|
263
|
-
return {
|
|
264
|
-
id: e.id,
|
|
265
|
-
type: "indicator-result",
|
|
266
|
-
indicator: "rsi",
|
|
267
|
-
values: ut(e.data, e.period ?? 14),
|
|
268
|
-
duration: performance.now() - n
|
|
269
|
-
};
|
|
270
|
-
case "sma":
|
|
271
|
-
return {
|
|
272
|
-
id: e.id,
|
|
273
|
-
type: "indicator-result",
|
|
274
|
-
indicator: "sma",
|
|
275
|
-
values: dt(e.data, e.period ?? 14),
|
|
276
|
-
duration: performance.now() - n
|
|
277
|
-
};
|
|
278
|
-
case "ema":
|
|
279
|
-
return {
|
|
280
|
-
id: e.id,
|
|
281
|
-
type: "indicator-result",
|
|
282
|
-
indicator: "ema",
|
|
283
|
-
values: lt(e.data, e.period ?? 14),
|
|
284
|
-
duration: performance.now() - n
|
|
285
|
-
};
|
|
286
|
-
case "macd": {
|
|
287
|
-
const t = ct(
|
|
288
|
-
e.data,
|
|
289
|
-
e.fastPeriod ?? 12,
|
|
290
|
-
e.slowPeriod ?? 26,
|
|
291
|
-
e.signalPeriod ?? 9
|
|
292
|
-
);
|
|
293
|
-
return {
|
|
294
|
-
id: e.id,
|
|
295
|
-
type: "indicator-result",
|
|
296
|
-
indicator: "macd",
|
|
297
|
-
...t,
|
|
298
|
-
duration: performance.now() - n
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
case "bollingerBands": {
|
|
302
|
-
const t = st(e.data, e.period ?? 20, e.stdDev ?? 2);
|
|
303
|
-
return {
|
|
304
|
-
id: e.id,
|
|
305
|
-
type: "indicator-result",
|
|
306
|
-
indicator: "bollingerBands",
|
|
307
|
-
...t,
|
|
308
|
-
duration: performance.now() - n
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
default:
|
|
312
|
-
throw new Error(`Unknown indicator: ${e.indicator}`);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
function At() {
|
|
316
|
-
return V || (V = new mt(
|
|
317
|
-
() => new Worker(new URL(
|
|
318
|
-
/* @vite-ignore */
|
|
319
|
-
"/assets/indicator.worker-bv0zC4EX.js",
|
|
320
|
-
import.meta.url
|
|
321
|
-
), { type: "module" }),
|
|
322
|
-
{
|
|
323
|
-
poolSize: 2,
|
|
324
|
-
syncFallback: !0,
|
|
325
|
-
// Short timeout — if the worker is silent (broken Vite URL), don't stall UI.
|
|
326
|
-
timeoutMs: 250,
|
|
327
|
-
syncHandler: je
|
|
328
|
-
}
|
|
329
|
-
)), V;
|
|
330
|
-
}
|
|
331
|
-
function ae(e) {
|
|
332
|
-
return e instanceof Float32Array || e instanceof Float64Array ? e : Float32Array.from(e);
|
|
333
|
-
}
|
|
334
|
-
function Fe(e) {
|
|
335
|
-
return {
|
|
336
|
-
values: e.values,
|
|
337
|
-
signal: e.signal,
|
|
338
|
-
upper: e.upper,
|
|
339
|
-
lower: e.lower,
|
|
340
|
-
histogram: e.histogram,
|
|
341
|
-
duration: e.duration
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
async function se(e) {
|
|
345
|
-
const t = { id: ht(e.indicator), type: "indicator", ...e };
|
|
346
|
-
if (he || e.data.length < bt)
|
|
347
|
-
return Fe(je(t));
|
|
348
|
-
const o = performance.now(), r = await At().run(t);
|
|
349
|
-
return performance.now() - o >= 200 && (he = !0), Fe(r);
|
|
350
|
-
}
|
|
351
|
-
async function St(e, n = 14) {
|
|
352
|
-
return se({ indicator: "rsi", data: ae(e), period: n });
|
|
353
|
-
}
|
|
354
|
-
async function Pt(e, n = 14) {
|
|
355
|
-
return se({ indicator: "sma", data: ae(e), period: n });
|
|
356
|
-
}
|
|
357
|
-
async function Rt(e, n = 14) {
|
|
358
|
-
return se({ indicator: "ema", data: ae(e), period: n });
|
|
359
|
-
}
|
|
360
|
-
async function It(e, n = 12, t = 26, o = 9) {
|
|
361
|
-
return se({
|
|
362
|
-
indicator: "macd",
|
|
363
|
-
data: ae(e),
|
|
364
|
-
fastPeriod: n,
|
|
365
|
-
slowPeriod: t,
|
|
366
|
-
signalPeriod: o
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
async function zt(e, n = 20, t = 2) {
|
|
370
|
-
return se({ indicator: "bollingerBands", data: ae(e), period: n, stdDev: t });
|
|
371
|
-
}
|
|
372
|
-
function an() {
|
|
373
|
-
V == null || V.destroy(), V = null, he = !1;
|
|
374
|
-
}
|
|
375
|
-
function Ct(e) {
|
|
376
|
-
return e === "bollingerBands" ? "bollinger" : e;
|
|
377
|
-
}
|
|
378
|
-
function Ne(e) {
|
|
379
|
-
const n = e.getData(), t = n.x;
|
|
380
|
-
if (!(t != null && t.length))
|
|
381
|
-
throw new Error("[addIndicator] Source series has no X data");
|
|
382
|
-
const o = e.getType();
|
|
383
|
-
let r;
|
|
384
|
-
if (o === "candlestick" ? r = n.close ?? n.y : r = n.y, !(r != null && r.length))
|
|
385
|
-
throw new Error("[addIndicator] Source series has no price/Y data");
|
|
386
|
-
return { x: t, prices: r };
|
|
387
|
-
}
|
|
388
|
-
function $t(e) {
|
|
389
|
-
const n = e.getData(), t = n.x;
|
|
390
|
-
if (!(t != null && t.length))
|
|
391
|
-
throw new Error("[addIndicator] Source series has no X data");
|
|
392
|
-
const o = n.open ?? n.y, r = n.high ?? n.y, a = n.low ?? n.y, l = n.close ?? n.y;
|
|
393
|
-
if (!(o != null && o.length) || !(r != null && r.length) || !(a != null && a.length) || !(l != null && l.length))
|
|
394
|
-
throw new Error("[addIndicator] Source series has no OHLC data — use candlestick");
|
|
395
|
-
return { x: t, open: o, high: r, low: a, close: l };
|
|
396
|
-
}
|
|
397
|
-
function me(e, n) {
|
|
398
|
-
if (n) {
|
|
399
|
-
const r = e.getSeries(n);
|
|
400
|
-
if (!r) throw new Error(`[addIndicator] Source series "${n}" not found`);
|
|
401
|
-
return r;
|
|
402
|
-
}
|
|
403
|
-
const o = e.getAllSeries().find((r) => {
|
|
404
|
-
const a = r.getType();
|
|
405
|
-
return a === "candlestick" || a === "line" || a === "bar";
|
|
406
|
-
});
|
|
407
|
-
if (!o)
|
|
408
|
-
throw new Error("[addIndicator] No line/candlestick/bar series found — pass sourceSeriesId");
|
|
409
|
-
return o;
|
|
410
|
-
}
|
|
411
|
-
async function Ue(e, n, t, o = {}, r) {
|
|
412
|
-
const a = Ct(e), l = o.id ?? a, d = n instanceof Float32Array || n instanceof Float64Array ? n : Float32Array.from(n);
|
|
413
|
-
switch (a) {
|
|
414
|
-
case "rsi": {
|
|
415
|
-
const c = o.period ?? 14, { values: h } = await St(t, c);
|
|
416
|
-
return {
|
|
417
|
-
id: l,
|
|
418
|
-
preset: "rsi",
|
|
419
|
-
placement: "oscillator",
|
|
420
|
-
yRange: [0, 100],
|
|
421
|
-
data: {
|
|
422
|
-
x: d,
|
|
423
|
-
lines: [{ id: "rsi", y: h, color: "#ab47bc", width: 1.5 }],
|
|
424
|
-
referenceLines: [
|
|
425
|
-
{ y: 70, color: "rgba(239, 83, 80, 0.5)", dash: [4, 4] },
|
|
426
|
-
{ y: 30, color: "rgba(38, 166, 154, 0.5)", dash: [4, 4] }
|
|
427
|
-
]
|
|
428
|
-
}
|
|
429
|
-
};
|
|
430
|
-
}
|
|
431
|
-
case "macd": {
|
|
432
|
-
const c = o.fastPeriod ?? 12, h = o.slowPeriod ?? 26, x = o.signalPeriod ?? 9, f = await It(t, c, h, x);
|
|
433
|
-
return {
|
|
434
|
-
id: l,
|
|
435
|
-
preset: "macd",
|
|
436
|
-
placement: "oscillator",
|
|
437
|
-
data: {
|
|
438
|
-
x: d,
|
|
439
|
-
histogram: {
|
|
440
|
-
y: f.histogram ?? new Float32Array(t.length),
|
|
441
|
-
positiveColor: "#26a69a",
|
|
442
|
-
negativeColor: "#ef5350"
|
|
443
|
-
},
|
|
444
|
-
lines: [
|
|
445
|
-
{ id: "macd", y: f.values, color: "#42a5f5", width: 1.5 },
|
|
446
|
-
{ id: "signal", y: f.signal ?? f.values, color: "#ff9800", width: 1 }
|
|
447
|
-
],
|
|
448
|
-
baseline: 0
|
|
449
|
-
}
|
|
450
|
-
};
|
|
451
|
-
}
|
|
452
|
-
case "bollinger": {
|
|
453
|
-
const c = o.period ?? 20, h = o.stdDev ?? 2, x = await zt(t, c, h), f = x.upper ?? x.values, b = x.lower ?? x.values;
|
|
454
|
-
return {
|
|
455
|
-
id: l,
|
|
456
|
-
preset: "bollinger",
|
|
457
|
-
placement: "overlay",
|
|
458
|
-
data: {
|
|
459
|
-
x: d,
|
|
460
|
-
lines: [{ id: "mid", y: x.values, color: "rgba(99, 102, 241, 0.9)", width: 1 }],
|
|
461
|
-
fills: [
|
|
462
|
-
{
|
|
463
|
-
id: "band",
|
|
464
|
-
upper: f,
|
|
465
|
-
lower: b,
|
|
466
|
-
color: "rgba(99, 102, 241, 0.15)"
|
|
467
|
-
}
|
|
468
|
-
]
|
|
469
|
-
}
|
|
470
|
-
};
|
|
471
|
-
}
|
|
472
|
-
case "ema": {
|
|
473
|
-
const c = o.period ?? 14, { values: h } = await Rt(t, c);
|
|
474
|
-
return {
|
|
475
|
-
id: l,
|
|
476
|
-
preset: "ema",
|
|
477
|
-
placement: "overlay",
|
|
478
|
-
data: {
|
|
479
|
-
x: d,
|
|
480
|
-
lines: [{ id: "ema", y: h, color: "#ffd54f", width: 1.5 }]
|
|
481
|
-
}
|
|
482
|
-
};
|
|
483
|
-
}
|
|
484
|
-
case "sma": {
|
|
485
|
-
const c = o.period ?? 14, { values: h } = await Pt(t, c);
|
|
486
|
-
return {
|
|
487
|
-
id: l,
|
|
488
|
-
preset: "sma",
|
|
489
|
-
placement: "overlay",
|
|
490
|
-
data: {
|
|
491
|
-
x: d,
|
|
492
|
-
lines: [{ id: "sma", y: h, color: "#4fc3f7", width: 1.5 }]
|
|
493
|
-
}
|
|
494
|
-
};
|
|
495
|
-
}
|
|
496
|
-
case "stochastic": {
|
|
497
|
-
if (!r)
|
|
498
|
-
throw new Error("[addIndicator] stochastic requires a candlestick source series");
|
|
499
|
-
const c = $t(r), h = o.period ?? 14, x = o.signalPeriod ?? 3, f = ft(c, h, x);
|
|
500
|
-
return {
|
|
501
|
-
id: l,
|
|
502
|
-
preset: "stochastic",
|
|
503
|
-
placement: "oscillator",
|
|
504
|
-
yRange: [0, 100],
|
|
505
|
-
data: {
|
|
506
|
-
x: d,
|
|
507
|
-
lines: [
|
|
508
|
-
{ id: "k", y: f.values, color: "#42a5f5", width: 1.5 },
|
|
509
|
-
{ id: "d", y: f.signal ?? f.values, color: "#ff9800", width: 1 }
|
|
510
|
-
],
|
|
511
|
-
referenceLines: [
|
|
512
|
-
{ y: 80, color: "rgba(239, 83, 80, 0.5)", dash: [4, 4] },
|
|
513
|
-
{ y: 20, color: "rgba(38, 166, 154, 0.5)", dash: [4, 4] }
|
|
514
|
-
]
|
|
515
|
-
}
|
|
516
|
-
};
|
|
517
|
-
}
|
|
518
|
-
default:
|
|
519
|
-
throw new Error(`[addIndicator] Unknown preset: ${e}`);
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
function Lt(e, n) {
|
|
523
|
-
for (const t of [...e.getAllSeries()]) {
|
|
524
|
-
const o = t.getId();
|
|
525
|
-
(o === n || o.startsWith(`${n}-`)) && e.removeSeries(o);
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
async function Dt(e, n, t = {}) {
|
|
529
|
-
const o = me(e, t.sourceSeriesId), { x: r, prices: a } = Ne(o);
|
|
530
|
-
return Ue(n, r, a, t, o);
|
|
531
|
-
}
|
|
532
|
-
async function kt(e, n, t = {}) {
|
|
533
|
-
var c;
|
|
534
|
-
if (t.pane === "new")
|
|
535
|
-
throw new Error(
|
|
536
|
-
"[addIndicator] pane: 'new' requires createStackedChart — use buildIndicatorPaneFromPreset() instead"
|
|
537
|
-
);
|
|
538
|
-
const o = me(e, t.sourceSeriesId), r = t.yAxisId ?? ((c = o.getYAxisId) == null ? void 0 : c.call(o)), a = await Dt(e, n, t);
|
|
539
|
-
Lt(e, a.id);
|
|
540
|
-
const l = de({
|
|
541
|
-
id: a.id,
|
|
542
|
-
data: a.data,
|
|
543
|
-
name: t.label ?? a.id.toUpperCase()
|
|
544
|
-
}), d = [];
|
|
545
|
-
for (const h of l)
|
|
546
|
-
e.addSeries({
|
|
547
|
-
...h,
|
|
548
|
-
yAxisId: r ?? h.yAxisId
|
|
549
|
-
}), d.push(h.id);
|
|
550
|
-
return {
|
|
551
|
-
id: a.id,
|
|
552
|
-
preset: n,
|
|
553
|
-
placement: a.placement,
|
|
554
|
-
seriesIds: d
|
|
555
|
-
};
|
|
556
|
-
}
|
|
557
|
-
async function Mt(e, n, t, o, r) {
|
|
558
|
-
const a = await Ue(e, n, t, o, r);
|
|
559
|
-
return xt({
|
|
560
|
-
id: o.id ?? a.id,
|
|
561
|
-
height: o.height ?? 0.25,
|
|
562
|
-
label: o.label ?? a.id.toUpperCase(),
|
|
563
|
-
yRange: o.yRange ?? a.yRange ?? "auto",
|
|
564
|
-
tickCount: o.tickCount,
|
|
565
|
-
showXAxis: o.showXAxis,
|
|
566
|
-
seriesId: o.seriesId,
|
|
567
|
-
style: o.style,
|
|
568
|
-
data: a.data
|
|
569
|
-
});
|
|
570
|
-
}
|
|
571
|
-
const le = 5, ge = 1 / 6, qe = { top: 4, bottom: 8, left: 4 }, Ge = { bottom: 55 };
|
|
572
|
-
function Et(e) {
|
|
573
|
-
if (typeof e == "number") return e;
|
|
574
|
-
switch (e) {
|
|
575
|
-
case "8k":
|
|
576
|
-
return 8;
|
|
577
|
-
case "4k":
|
|
578
|
-
return 4;
|
|
579
|
-
case "2k":
|
|
580
|
-
return 2;
|
|
581
|
-
default:
|
|
582
|
-
return 1;
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
function Ft(e) {
|
|
586
|
-
return new Promise((n, t) => {
|
|
587
|
-
const o = new Image();
|
|
588
|
-
o.onload = () => n(o), o.onerror = t, o.src = e;
|
|
589
|
-
});
|
|
590
|
-
}
|
|
591
|
-
function Te(e, n) {
|
|
592
|
-
const t = e.getBoundingClientRect();
|
|
593
|
-
return {
|
|
594
|
-
x: t.left - n.left,
|
|
595
|
-
y: t.top - n.top,
|
|
596
|
-
width: t.width,
|
|
597
|
-
height: t.height
|
|
598
|
-
};
|
|
599
|
-
}
|
|
600
|
-
async function Tt(e, n, t, o, r, a = {}) {
|
|
601
|
-
var v;
|
|
602
|
-
const {
|
|
603
|
-
format: l = "png",
|
|
604
|
-
quality: d = 0.92,
|
|
605
|
-
resolution: c = "standard",
|
|
606
|
-
includeBackground: h = !0,
|
|
607
|
-
includeDividers: x = !0,
|
|
608
|
-
transparent: f = !1
|
|
609
|
-
} = a, b = Et(c), p = (((v = t[0]) == null ? void 0 : v.getDPR()) ?? (typeof window < "u" ? window.devicePixelRatio : 1)) * b, R = t.map((m) => m.getDPR());
|
|
610
|
-
try {
|
|
611
|
-
if (b > 1) {
|
|
612
|
-
for (const g of t)
|
|
613
|
-
typeof g.setDevicePixelRatioOverride == "function" ? g.setDevicePixelRatioOverride(p) : g.setDPR(p), g.render();
|
|
614
|
-
await new Promise((g) => requestAnimationFrame(g)), await new Promise((g) => requestAnimationFrame(g)), await new Promise((g) => setTimeout(g, 50));
|
|
615
|
-
}
|
|
616
|
-
const m = e.getBoundingClientRect(), X = Math.max(1, Math.round(m.width * p)), D = Math.max(1, Math.round(m.height * p)), C = document.createElement("canvas");
|
|
617
|
-
C.width = X, C.height = D;
|
|
618
|
-
const L = C.getContext("2d");
|
|
619
|
-
if (!L) throw new Error("Failed to create export canvas");
|
|
620
|
-
!f && h && (L.fillStyle = r || "#ffffff", L.fillRect(0, 0, X, D));
|
|
621
|
-
const H = l === "jpeg" ? "jpeg" : "png";
|
|
622
|
-
for (let g = 0; g < n.length; g++) {
|
|
623
|
-
const A = Te(n[g], m), S = t[g].exportImage(H), P = await Ft(S);
|
|
624
|
-
L.drawImage(
|
|
625
|
-
P,
|
|
626
|
-
Math.round(A.x * p),
|
|
627
|
-
Math.round(A.y * p),
|
|
628
|
-
Math.round(A.width * p),
|
|
629
|
-
Math.round(A.height * p)
|
|
630
|
-
);
|
|
631
|
-
}
|
|
632
|
-
if (x && o.length) {
|
|
633
|
-
L.fillStyle = "rgba(128, 128, 128, 0.35)";
|
|
634
|
-
for (const g of o) {
|
|
635
|
-
const A = Te(g, m);
|
|
636
|
-
L.fillRect(
|
|
637
|
-
Math.round(A.x * p),
|
|
638
|
-
Math.round(A.y * p),
|
|
639
|
-
Math.max(1, Math.round(A.width * p)),
|
|
640
|
-
Math.max(1, Math.round(A.height * p))
|
|
641
|
-
);
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
const T = l === "jpeg" ? "image/jpeg" : l === "webp" ? "image/webp" : "image/png";
|
|
645
|
-
return C.toDataURL(T, d);
|
|
646
|
-
} finally {
|
|
647
|
-
if (b > 1)
|
|
648
|
-
for (let m = 0; m < t.length; m++)
|
|
649
|
-
typeof t[m].setDevicePixelRatioOverride == "function" ? t[m].setDevicePixelRatioOverride(null) : t[m].setDPR(R[m]), t[m].render();
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
const F = "velo-pane-divider", W = "velo-pane-resizing";
|
|
653
|
-
function Xt(e) {
|
|
654
|
-
if (typeof document > "u") return;
|
|
655
|
-
let n = document.getElementById("velo-pane-divider-styles");
|
|
656
|
-
n || (n = document.createElement("style"), n.id = "velo-pane-divider-styles", document.head.appendChild(n));
|
|
657
|
-
const o = e === "horizontal" ? "ew-resize" : "ns-resize";
|
|
658
|
-
n.textContent = `
|
|
659
|
-
.${F} {
|
|
660
|
-
flex: 0 0 var(--velo-divider-size, 6px);
|
|
661
|
-
position: relative;
|
|
662
|
-
cursor: ${o};
|
|
663
|
-
touch-action: none;
|
|
664
|
-
z-index: 20;
|
|
665
|
-
background: transparent;
|
|
666
|
-
user-select: none;
|
|
667
|
-
}
|
|
668
|
-
.${F}::after {
|
|
669
|
-
content: "";
|
|
670
|
-
position: absolute;
|
|
671
|
-
background: rgba(128, 128, 128, 0.35);
|
|
672
|
-
transition: background 0.15s;
|
|
673
|
-
}
|
|
674
|
-
.${F}[data-direction="vertical"]::after {
|
|
675
|
-
left: 0;
|
|
676
|
-
right: 0;
|
|
677
|
-
top: 50%;
|
|
678
|
-
transform: translateY(-50%);
|
|
679
|
-
height: 1px;
|
|
680
|
-
}
|
|
681
|
-
.${F}[data-direction="horizontal"]::after {
|
|
682
|
-
top: 0;
|
|
683
|
-
bottom: 0;
|
|
684
|
-
left: 50%;
|
|
685
|
-
transform: translateX(-50%);
|
|
686
|
-
width: 1px;
|
|
687
|
-
}
|
|
688
|
-
.${F}:hover::after,
|
|
689
|
-
.${W} .${F}::after {
|
|
690
|
-
background: rgba(0, 242, 255, 0.65);
|
|
691
|
-
}
|
|
692
|
-
.${F}[data-direction="vertical"]:hover::after,
|
|
693
|
-
.${W} .${F}[data-direction="vertical"]::after {
|
|
694
|
-
height: 2px;
|
|
695
|
-
}
|
|
696
|
-
.${F}[data-direction="horizontal"]:hover::after,
|
|
697
|
-
.${W} .${F}[data-direction="horizontal"]::after {
|
|
698
|
-
width: 2px;
|
|
699
|
-
}
|
|
700
|
-
.${F}-handle {
|
|
701
|
-
position: absolute;
|
|
702
|
-
left: 50%;
|
|
703
|
-
top: 50%;
|
|
704
|
-
transform: translate(-50%, -50%);
|
|
705
|
-
width: 32px;
|
|
706
|
-
height: 12px;
|
|
707
|
-
display: flex;
|
|
708
|
-
align-items: center;
|
|
709
|
-
justify-content: center;
|
|
710
|
-
opacity: 0;
|
|
711
|
-
transition: opacity 0.15s;
|
|
712
|
-
pointer-events: none;
|
|
713
|
-
color: rgba(0, 242, 255, 0.9);
|
|
714
|
-
font-size: 10px;
|
|
715
|
-
line-height: 1;
|
|
716
|
-
}
|
|
717
|
-
.${F}:hover .${F}-handle,
|
|
718
|
-
.${W} .${F}-handle {
|
|
719
|
-
opacity: 1;
|
|
720
|
-
}
|
|
721
|
-
.${W} {
|
|
722
|
-
cursor: ${o} !important;
|
|
723
|
-
}
|
|
724
|
-
.${W} * {
|
|
725
|
-
cursor: ${o} !important;
|
|
726
|
-
}
|
|
727
|
-
.${W} [data-pane-id] {
|
|
728
|
-
position: relative !important;
|
|
729
|
-
overflow: hidden !important;
|
|
730
|
-
}
|
|
731
|
-
`;
|
|
732
|
-
}
|
|
733
|
-
function Ht(e, n) {
|
|
734
|
-
return e.map(
|
|
735
|
-
(t) => n ? t.getBoundingClientRect().width : t.getBoundingClientRect().height
|
|
736
|
-
);
|
|
737
|
-
}
|
|
738
|
-
function Yt(e, n, t, o, r) {
|
|
739
|
-
return (e == null ? void 0 : e(n, t)) ?? Ht(o, r);
|
|
740
|
-
}
|
|
741
|
-
function Bt(e, n, t) {
|
|
742
|
-
const o = document.createElement("div");
|
|
743
|
-
o.className = F, o.dataset.dividerIndex = String(e), o.dataset.direction = t, o.style.setProperty("--velo-divider-size", `${n}px`);
|
|
744
|
-
const r = document.createElement("div");
|
|
745
|
-
return r.className = `${F}-handle`, r.textContent = t === "horizontal" ? "⇔" : "⇕", o.appendChild(r), o;
|
|
746
|
-
}
|
|
747
|
-
function Ot(e, n) {
|
|
748
|
-
const t = n === "horizontal" ? "min-width:0;" : "min-height:0;";
|
|
749
|
-
return typeof e == "number" ? `flex:${e} 1 0;${t}` : `flex:1 1 ${e};${t}`;
|
|
750
|
-
}
|
|
751
|
-
function Ze(e, n, t = ge, o = 0) {
|
|
752
|
-
if (n < 1 || e <= 0) return 1;
|
|
753
|
-
const r = e * t, a = Math.max(o, r);
|
|
754
|
-
return Math.min(a, e / n);
|
|
755
|
-
}
|
|
756
|
-
function Wt(e, n, t = ge, o = 0) {
|
|
757
|
-
return Ze(e, n, t, o);
|
|
758
|
-
}
|
|
759
|
-
function ue(e, n) {
|
|
760
|
-
const t = e.length;
|
|
761
|
-
if (t === 0) return e;
|
|
762
|
-
const o = Math.max(1, Math.round(n)), r = e.reduce((c, h) => c + h, 0);
|
|
763
|
-
if (r <= 0) {
|
|
764
|
-
const c = Math.floor(o / t), h = e.map(() => c);
|
|
765
|
-
return h[t - 1] = o - c * (t - 1), h;
|
|
766
|
-
}
|
|
767
|
-
const a = e.map((c) => c / r * o), l = [];
|
|
768
|
-
let d = 0;
|
|
769
|
-
for (let c = 0; c < t - 1; c++)
|
|
770
|
-
l.push(Math.max(1, Math.round(a[c]))), d += l[c];
|
|
771
|
-
return l.push(Math.max(1, o - d)), l;
|
|
772
|
-
}
|
|
773
|
-
function _t(e, n, t, o, r = {}) {
|
|
774
|
-
const a = r.direction ?? "vertical", l = a === "horizontal";
|
|
775
|
-
Xt(a);
|
|
776
|
-
const d = r.minPaneRatio ?? ge, c = r.minPanePx ?? 0, h = r.dividerSize ?? 6, x = n.length, f = (v) => l ? Wt(v, x, d, c) : Ze(v, x, d, c), b = [], w = [];
|
|
777
|
-
if (n.length < 2)
|
|
778
|
-
return { dividers: b, destroy: () => {
|
|
779
|
-
} };
|
|
780
|
-
const p = () => {
|
|
781
|
-
const v = b.length * h, m = l ? e.clientWidth : e.clientHeight;
|
|
782
|
-
return Math.max(1, m - v);
|
|
783
|
-
}, R = (v, m, X, D) => {
|
|
784
|
-
var P;
|
|
785
|
-
const C = p(), L = f(C), H = D.reduce(
|
|
786
|
-
(M, $, Y) => Y === v || Y === m ? M : M + $,
|
|
787
|
-
0
|
|
788
|
-
), T = C - H;
|
|
789
|
-
let g = D[v] + X;
|
|
790
|
-
g = Math.max(L, Math.min(T - L, g));
|
|
791
|
-
const A = T - g;
|
|
792
|
-
D[v] = g, D[m] = A;
|
|
793
|
-
const S = o.reduce((M, $) => M + $, 0);
|
|
794
|
-
if (o[v] = g / C * S, o[m] = A / C * S, (P = r.onDragMove) == null || P.call(r, D, v, m), r.onResize) {
|
|
795
|
-
const M = {};
|
|
796
|
-
for (let $ = 0; $ < t.length; $++)
|
|
797
|
-
M[t[$]] = o[$];
|
|
798
|
-
r.onResize(M);
|
|
799
|
-
}
|
|
800
|
-
};
|
|
801
|
-
for (let v = 0; v < n.length - 1; v++) {
|
|
802
|
-
const m = Bt(v, h, a);
|
|
803
|
-
n[v].after(m), b.push(m);
|
|
804
|
-
const D = (C) => {
|
|
805
|
-
var A;
|
|
806
|
-
C.preventDefault(), m.setPointerCapture(C.pointerId), e.classList.add(W);
|
|
807
|
-
const L = Yt(
|
|
808
|
-
r.onDragStart,
|
|
809
|
-
v,
|
|
810
|
-
v + 1,
|
|
811
|
-
n,
|
|
812
|
-
l
|
|
813
|
-
);
|
|
814
|
-
(A = r.onDragMove) == null || A.call(r, L, v, v + 1);
|
|
815
|
-
let H = l ? C.clientX : C.clientY;
|
|
816
|
-
const T = (S) => {
|
|
817
|
-
const P = l ? S.clientX : S.clientY, M = P - H;
|
|
818
|
-
H = P, M !== 0 && R(v, v + 1, M, L);
|
|
819
|
-
}, g = (S) => {
|
|
820
|
-
var P;
|
|
821
|
-
m.releasePointerCapture(S.pointerId), e.classList.remove(W), m.removeEventListener("pointermove", T), m.removeEventListener("pointerup", g), m.removeEventListener("pointercancel", g), (P = r.onDragEnd) == null || P.call(r, L);
|
|
822
|
-
};
|
|
823
|
-
m.addEventListener("pointermove", T), m.addEventListener("pointerup", g), m.addEventListener("pointercancel", g);
|
|
824
|
-
};
|
|
825
|
-
m.addEventListener("pointerdown", D), w.push(() => m.removeEventListener("pointerdown", D));
|
|
826
|
-
}
|
|
827
|
-
return {
|
|
828
|
-
dividers: b,
|
|
829
|
-
destroy: () => {
|
|
830
|
-
for (const v of w) v();
|
|
831
|
-
for (const v of b) v.remove();
|
|
832
|
-
e.classList.remove(W);
|
|
833
|
-
}
|
|
834
|
-
};
|
|
835
|
-
}
|
|
836
|
-
function jt(e, n, t = "vertical") {
|
|
837
|
-
for (let o = 0; o < e.length; o++)
|
|
838
|
-
e[o].style.cssText = `${Ot(n[o], t)}position:relative;overflow:hidden;`;
|
|
839
|
-
}
|
|
840
|
-
function Xe(e) {
|
|
841
|
-
return typeof e == "number" ? e : 1;
|
|
842
|
-
}
|
|
843
|
-
function Nt(e, n = 6) {
|
|
844
|
-
if (!Number.isFinite(e) || e <= 0) return n;
|
|
845
|
-
const t = Math.floor(e / 36);
|
|
846
|
-
return Math.max(2, Math.min(n, t));
|
|
847
|
-
}
|
|
848
|
-
function Ut(e, n = 8) {
|
|
849
|
-
if (!Number.isFinite(e) || e <= 0) return n;
|
|
850
|
-
const t = Math.floor(e / 72);
|
|
851
|
-
return Math.max(2, Math.min(n, t));
|
|
852
|
-
}
|
|
853
|
-
function He(e) {
|
|
854
|
-
var t;
|
|
855
|
-
return e ? ((t = (Array.isArray(e) ? e : [e])[0]) == null ? void 0 : t.tickCount) ?? 6 : 6;
|
|
856
|
-
}
|
|
857
|
-
function qt(e) {
|
|
858
|
-
const n = e.wrapper.clientHeight, t = e.wrapper.clientWidth, o = Nt(n, e.baseYTickCount);
|
|
859
|
-
if (e.chart.updateYAxis("default", { tickCount: o }), e.showXAxis) {
|
|
860
|
-
const r = Ut(t, e.baseXTickCount);
|
|
861
|
-
e.chart.updateXAxis({ tickCount: r });
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
function Ye(e) {
|
|
865
|
-
for (const n of e) qt(n);
|
|
866
|
-
}
|
|
867
|
-
function Ke(e) {
|
|
868
|
-
const n = e ? Array.isArray(e) ? e : [e] : [{}];
|
|
869
|
-
let t = 0, o = 0;
|
|
870
|
-
for (const r of n)
|
|
871
|
-
r.position === "right" ? o++ : t++;
|
|
872
|
-
return { left: Math.max(1, t), right: o };
|
|
873
|
-
}
|
|
874
|
-
function Gt(e, n) {
|
|
875
|
-
var o;
|
|
876
|
-
let t = 0;
|
|
877
|
-
for (const r of e) {
|
|
878
|
-
const { left: a } = Ke((o = r.chart) == null ? void 0 : o.yAxis);
|
|
879
|
-
t = Math.max(t, (a - 1) * 65);
|
|
880
|
-
}
|
|
881
|
-
return n + t;
|
|
882
|
-
}
|
|
883
|
-
function Zt(e, n) {
|
|
884
|
-
var o;
|
|
885
|
-
let t = 0;
|
|
886
|
-
for (const r of e) {
|
|
887
|
-
const { right: a } = Ke((o = r.chart) == null ? void 0 : o.yAxis);
|
|
888
|
-
t = Math.max(t, a * 65);
|
|
889
|
-
}
|
|
890
|
-
return n + t;
|
|
891
|
-
}
|
|
892
|
-
function Kt(e, n) {
|
|
893
|
-
return `flex:${e} 1 0;${n === "horizontal" ? "min-width:0;" : "min-height:0;"}`;
|
|
894
|
-
}
|
|
895
|
-
function Be(e) {
|
|
896
|
-
const n = e.reduce((t, o) => t + o, 0);
|
|
897
|
-
if (n <= 0) {
|
|
898
|
-
const t = 1 / Math.max(1, e.length);
|
|
899
|
-
for (let o = 0; o < e.length; o++) e[o] = t;
|
|
900
|
-
return;
|
|
901
|
-
}
|
|
902
|
-
for (let t = 0; t < e.length; t++) e[t] /= n;
|
|
903
|
-
}
|
|
904
|
-
function Oe(e) {
|
|
905
|
-
if (!(e != null && e.length)) return [];
|
|
906
|
-
const n = [];
|
|
907
|
-
for (const t of e)
|
|
908
|
-
t.type === "indicator" ? n.push(...de(t)) : n.push(t);
|
|
909
|
-
return n;
|
|
910
|
-
}
|
|
911
|
-
function We(e, n, t, o, r, a, l, d, c) {
|
|
912
|
-
var S, P, M, $, Y, N, B, Q, _, ce, oe, re, J;
|
|
913
|
-
const h = o === 0, x = o === r - 1, f = c === "horizontal", w = !f && t.sharedXAxis !== "none" && !l, R = f && (t.sharedYAxis ?? "left") !== "none" && !d, m = (t.gap ?? 0) > 0 ? qe : { top: 0, bottom: 0, left: 0 }, X = f ? {
|
|
914
|
-
top: a.top,
|
|
915
|
-
right: x ? a.right : m.left,
|
|
916
|
-
left: R ? m.left : a.left,
|
|
917
|
-
bottom: a.bottom
|
|
918
|
-
} : {
|
|
919
|
-
top: h ? a.top : m.top,
|
|
920
|
-
right: a.right,
|
|
921
|
-
left: a.left,
|
|
922
|
-
bottom: w ? m.bottom : x ? ((P = (S = t.layout) == null ? void 0 : S.margins) == null ? void 0 : P.bottom) ?? Ge.bottom : a.bottom
|
|
923
|
-
}, D = {
|
|
924
|
-
...t.xAxis ?? {},
|
|
925
|
-
...((M = e.chart) == null ? void 0 : M.xAxis) ?? {}
|
|
926
|
-
}, C = {
|
|
927
|
-
...D,
|
|
928
|
-
showLine: l ? D.showLine ?? !0 : !1,
|
|
929
|
-
showTicks: l ? D.showTicks ?? !0 : !1,
|
|
930
|
-
showLabels: l ? D.showLabels ?? !0 : !1
|
|
931
|
-
}, L = (($ = e.chart) == null ? void 0 : $.yAxis) ?? {}, T = (Array.isArray(L) ? L : [L]).map((ee) => ({
|
|
932
|
-
...ee,
|
|
933
|
-
showLine: d ? ee.showLine ?? !0 : !1,
|
|
934
|
-
showTicks: d ? ee.showTicks ?? !0 : !1,
|
|
935
|
-
showLabels: d ? ee.showLabels ?? !0 : !1
|
|
936
|
-
})), g = Array.isArray((Y = e.chart) == null ? void 0 : Y.yAxis) ? T : T[0];
|
|
937
|
-
return (e.interactive ?? !0) || (n.style.pointerEvents = "none"), {
|
|
938
|
-
...e.chart,
|
|
939
|
-
id: e.id,
|
|
940
|
-
container: n,
|
|
941
|
-
showLegend: ((N = e.chart) == null ? void 0 : N.showLegend) ?? t.showLegend ?? !1,
|
|
942
|
-
theme: ((B = e.chart) == null ? void 0 : B.theme) ?? t.theme,
|
|
943
|
-
devicePixelRatio: t.devicePixelRatio ?? ((Q = e.chart) == null ? void 0 : Q.devicePixelRatio),
|
|
944
|
-
loading: ((_ = e.chart) == null ? void 0 : _.loading) ?? !1,
|
|
945
|
-
xAxis: C,
|
|
946
|
-
yAxis: g,
|
|
947
|
-
layout: _e({
|
|
948
|
-
...t.layout,
|
|
949
|
-
...(ce = e.chart) == null ? void 0 : ce.layout,
|
|
950
|
-
margins: { ...X, ...(oe = t.layout) == null ? void 0 : oe.margins, ...(J = (re = e.chart) == null ? void 0 : re.layout) == null ? void 0 : J.margins }
|
|
951
|
-
})
|
|
952
|
-
};
|
|
953
|
-
}
|
|
954
|
-
function ne() {
|
|
955
|
-
return "position:absolute;inset:0;width:100%;height:100%;min-width:0;min-height:0;";
|
|
956
|
-
}
|
|
957
|
-
function fe(e, n, t, o) {
|
|
958
|
-
const r = n > 0 && t > 0 ? o === "horizontal" ? `margin-left:${n}px;` : `margin-top:${n}px;` : "";
|
|
959
|
-
return `${Kt(e, o)}position:relative;overflow:hidden;${r}`;
|
|
960
|
-
}
|
|
961
|
-
function Qt(e, n, t) {
|
|
962
|
-
return e === !1 ? {
|
|
963
|
-
axis: "none",
|
|
964
|
-
syncCursor: !1,
|
|
965
|
-
syncZoom: !1,
|
|
966
|
-
syncPan: !1,
|
|
967
|
-
bidirectional: !0,
|
|
968
|
-
masterId: void 0
|
|
969
|
-
} : {
|
|
970
|
-
axis: t === "horizontal" ? "y" : "x",
|
|
971
|
-
bidirectional: !0,
|
|
972
|
-
masterId: n,
|
|
973
|
-
syncCursor: !0,
|
|
974
|
-
syncZoom: !0,
|
|
975
|
-
syncPan: !0,
|
|
976
|
-
...typeof e == "object" ? e : {}
|
|
977
|
-
};
|
|
978
|
-
}
|
|
979
|
-
function sn(e) {
|
|
980
|
-
var Ae, Se, Pe, Re, Ie, ze, Ce, $e;
|
|
981
|
-
const { container: n, panes: t } = e;
|
|
982
|
-
if (!n) throw new Error("[StackedChart] container is required");
|
|
983
|
-
if (t.length < 1 || t.length > le)
|
|
984
|
-
throw new Error(`[StackedChart] panes must be 1–${le}`);
|
|
985
|
-
const o = e.masterPaneId ?? t[0].id, r = e.direction ?? "vertical", a = r === "horizontal", l = e.sharedXAxis ?? "bottom", d = e.sharedYAxis ?? "left", c = e.gap ?? 0, h = e.resizable, x = !!h, f = typeof h == "object" ? h.dividerSize ?? 6 : 6, b = _e(e.layout), w = ((Ae = b.margins) == null ? void 0 : Ae.left) ?? te.left, p = ((Se = b.margins) == null ? void 0 : Se.right) ?? te.right, R = ((Pe = b.margins) == null ? void 0 : Pe.top) ?? te.top, v = Gt(t, w), m = Zt(t, p), X = n.style.height, D = n.style.width, C = n.style.minHeight, L = n.style.minWidth, H = getComputedStyle(n), T = n.offsetHeight || parseInt(H.height, 10) || 0;
|
|
986
|
-
n.replaceChildren(), n.style.display = "flex", n.style.flexDirection = a ? "row" : "column", n.style.boxSizing = "border-box", n.style.overflow = "hidden", n.style.position = "relative", n.style.maxWidth = "none", n.style.maxHeight = "none", n.style.width = D || "100%", n.style.minWidth = L || "0", X ? n.style.height = X : T > 0 ? n.style.height = `${T}px` : (n.style.height = "100%", n.style.minHeight = C || "320px"), C ? n.style.minHeight = C : n.style.minHeight || (n.style.minHeight = "0");
|
|
987
|
-
const g = t.map((i) => i.id), A = t.map((i) => Xe(i.height));
|
|
988
|
-
Be(A);
|
|
989
|
-
const S = /* @__PURE__ */ new Map(), P = [], M = [];
|
|
990
|
-
let $ = null, Y = !1, N = 0, B = 0, Q = null;
|
|
991
|
-
const _ = (i) => {
|
|
992
|
-
const s = Array.from({ length: P.length }, (u, y) => y);
|
|
993
|
-
for (const u of s) {
|
|
994
|
-
const y = S.get(g[u]);
|
|
995
|
-
y && y.resize();
|
|
996
|
-
}
|
|
997
|
-
Ye(
|
|
998
|
-
s.map((u) => M[u]).filter(Boolean)
|
|
999
|
-
);
|
|
1000
|
-
}, ce = () => {
|
|
1001
|
-
N || (N = requestAnimationFrame(() => {
|
|
1002
|
-
N = 0, !Y && _();
|
|
1003
|
-
}));
|
|
1004
|
-
}, oe = new ResizeObserver(() => {
|
|
1005
|
-
Y || ce();
|
|
1006
|
-
});
|
|
1007
|
-
oe.observe(n);
|
|
1008
|
-
const re = () => {
|
|
1009
|
-
for (let i = 0; i < P.length; i++)
|
|
1010
|
-
P[i].style.cssText = fe(A[i], c, i, r);
|
|
1011
|
-
}, J = () => {
|
|
1012
|
-
const i = (P.length - 1) * f;
|
|
1013
|
-
return a ? Math.max(1, n.clientWidth - i) : Math.max(1, n.clientHeight - i);
|
|
1014
|
-
}, ee = () => {
|
|
1015
|
-
for (const i of P) {
|
|
1016
|
-
const s = i.firstElementChild;
|
|
1017
|
-
s && (s.style.cssText = ne());
|
|
1018
|
-
}
|
|
1019
|
-
}, Qe = () => {
|
|
1020
|
-
const i = J(), s = P.map(
|
|
1021
|
-
(y) => a ? y.getBoundingClientRect().width : y.getBoundingClientRect().height
|
|
1022
|
-
);
|
|
1023
|
-
if (s.reduce((y, I) => y + I, 0) <= 0) {
|
|
1024
|
-
const y = Math.floor(i / Math.max(1, P.length));
|
|
1025
|
-
return P.map(
|
|
1026
|
-
(I, k) => k === P.length - 1 ? i - y * (P.length - 1) : y
|
|
1027
|
-
);
|
|
1028
|
-
}
|
|
1029
|
-
return ue(s, i);
|
|
1030
|
-
}, Ve = (i) => {
|
|
1031
|
-
const s = ue(i, J());
|
|
1032
|
-
for (let u = 0; u < P.length; u++) {
|
|
1033
|
-
const y = Math.max(1, s[u]), I = c > 0 && u > 0 ? a ? `margin-left:${c}px;` : `margin-top:${c}px;` : "", k = a ? "width" : "height";
|
|
1034
|
-
P[u].style.cssText = `${k}:${y}px;flex:0 0 auto;min-height:0;min-width:0;position:relative;overflow:hidden;${I}`;
|
|
1035
|
-
const z = P[u].firstElementChild;
|
|
1036
|
-
z && (z.style.cssText = ne());
|
|
1037
|
-
}
|
|
1038
|
-
for (let u = 0; u < i.length; u++) i[u] = s[u];
|
|
1039
|
-
}, Je = () => {
|
|
1040
|
-
if (B = 0, !Y || !Q) return;
|
|
1041
|
-
const { sizes: i, leadingIdx: s, trailingIdx: u } = Q;
|
|
1042
|
-
Ve(i);
|
|
1043
|
-
for (const y of [s, u]) {
|
|
1044
|
-
const I = S.get(g[y]);
|
|
1045
|
-
I && (I.resize(), Ye([M[y]]));
|
|
1046
|
-
}
|
|
1047
|
-
}, et = (i, s, u) => {
|
|
1048
|
-
Q = { sizes: i, leadingIdx: s, trailingIdx: u }, !B && (B = requestAnimationFrame(Je));
|
|
1049
|
-
}, tt = (i) => {
|
|
1050
|
-
const s = i.reduce((y, I) => y + I, 0);
|
|
1051
|
-
if (s <= 0) return;
|
|
1052
|
-
const u = A.reduce((y, I) => y + I, 0);
|
|
1053
|
-
for (let y = 0; y < A.length; y++)
|
|
1054
|
-
A[y] = i[y] / s * u;
|
|
1055
|
-
}, ye = (i) => {
|
|
1056
|
-
var s;
|
|
1057
|
-
for (const u of S.values())
|
|
1058
|
-
(s = u.setResizeSuspended) == null || s.call(u, i);
|
|
1059
|
-
}, nt = (i, s) => {
|
|
1060
|
-
var u, y, I, k, z, O;
|
|
1061
|
-
for (let E = 0; E < g.length; E++)
|
|
1062
|
-
E === i || E === s || (y = (u = S.get(g[E])) == null ? void 0 : u.setResizeSuspended) == null || y.call(u, !0);
|
|
1063
|
-
(k = (I = S.get(g[i])) == null ? void 0 : I.setResizeSuspended) == null || k.call(I, !1), (O = (z = S.get(g[s])) == null ? void 0 : z.setResizeSuspended) == null || O.call(z, !1);
|
|
1064
|
-
}, pe = a ? ((Ie = (Re = e.layout) == null ? void 0 : Re.margins) == null ? void 0 : Ie.bottom) ?? Ge.bottom : te.bottom;
|
|
1065
|
-
for (let i = 0; i < t.length; i++) {
|
|
1066
|
-
const s = t[i], u = i === 0, y = i === t.length - 1, I = a ? s.showXAxis ?? !0 : s.showXAxis ?? (l === "bottom" ? y : !0), k = a ? s.showYAxis ?? (d === "left" ? u : !0) : s.showYAxis ?? !0, z = document.createElement("div");
|
|
1067
|
-
z.dataset.paneId = s.id, z.style.cssText = fe(A[i], c, i, r);
|
|
1068
|
-
const O = document.createElement("div");
|
|
1069
|
-
O.style.cssText = ne(), z.appendChild(O), n.appendChild(z), P.push(z);
|
|
1070
|
-
const E = Ee(
|
|
1071
|
-
We(
|
|
1072
|
-
s,
|
|
1073
|
-
O,
|
|
1074
|
-
e,
|
|
1075
|
-
i,
|
|
1076
|
-
t.length,
|
|
1077
|
-
{
|
|
1078
|
-
left: a && !k ? te.left : v,
|
|
1079
|
-
right: m,
|
|
1080
|
-
top: R,
|
|
1081
|
-
bottom: pe
|
|
1082
|
-
},
|
|
1083
|
-
I,
|
|
1084
|
-
k,
|
|
1085
|
-
r
|
|
1086
|
-
)
|
|
1087
|
-
);
|
|
1088
|
-
O.style.cssText = ne();
|
|
1089
|
-
const q = Oe(s.series);
|
|
1090
|
-
if (q.length)
|
|
1091
|
-
for (const G of q) E.addSeries(G);
|
|
1092
|
-
s.yRange && s.yRange !== "auto" && E.zoom({ y: s.yRange, animate: !1 }), S.set(s.id, E), M.push({
|
|
1093
|
-
chart: E,
|
|
1094
|
-
wrapper: z,
|
|
1095
|
-
baseYTickCount: He((ze = s.chart) == null ? void 0 : ze.yAxis),
|
|
1096
|
-
baseXTickCount: (($e = (Ce = s.chart) == null ? void 0 : Ce.xAxis) == null ? void 0 : $e.tickCount) ?? 8,
|
|
1097
|
-
showXAxis: I
|
|
1098
|
-
});
|
|
1099
|
-
}
|
|
1100
|
-
const we = () => {
|
|
1101
|
-
if ($ == null || $.destroy(), $ = null, !x || P.length < 2) return;
|
|
1102
|
-
const i = typeof h == "object" ? {
|
|
1103
|
-
minPaneRatio: h.minPaneRatio,
|
|
1104
|
-
minPanePx: h.minPanePx,
|
|
1105
|
-
dividerSize: h.dividerSize
|
|
1106
|
-
} : {};
|
|
1107
|
-
$ = _t(
|
|
1108
|
-
n,
|
|
1109
|
-
P,
|
|
1110
|
-
g,
|
|
1111
|
-
A,
|
|
1112
|
-
{
|
|
1113
|
-
direction: r,
|
|
1114
|
-
...i,
|
|
1115
|
-
onDragStart: (s, u) => (Y = !0, ye(!0), nt(s, u), Qe()),
|
|
1116
|
-
onDragMove: (s, u, y) => {
|
|
1117
|
-
et(s, u, y);
|
|
1118
|
-
},
|
|
1119
|
-
onDragEnd: (s) => {
|
|
1120
|
-
B && (cancelAnimationFrame(B), B = 0), Q = null, Y = !1;
|
|
1121
|
-
const u = ue(s, J());
|
|
1122
|
-
tt(u), ee(), re(), ye(!1), _();
|
|
1123
|
-
}
|
|
1124
|
-
}
|
|
1125
|
-
);
|
|
1126
|
-
};
|
|
1127
|
-
we();
|
|
1128
|
-
const ie = S.get(o);
|
|
1129
|
-
if (!ie)
|
|
1130
|
-
throw new Error(`[StackedChart] masterPaneId "${o}" not found in panes`);
|
|
1131
|
-
const U = at(
|
|
1132
|
-
Array.from(S.values()),
|
|
1133
|
-
Qt(e.sync, o, r)
|
|
1134
|
-
), ot = () => {
|
|
1135
|
-
const i = ie.theme ?? ie.baseTheme;
|
|
1136
|
-
return (i == null ? void 0 : i.backgroundColor) ?? "#ffffff";
|
|
1137
|
-
}, ve = () => {
|
|
1138
|
-
const s = Date.now();
|
|
1139
|
-
return new Promise((y) => {
|
|
1140
|
-
const I = () => {
|
|
1141
|
-
const k = it();
|
|
1142
|
-
if (k.pending === 0 && !k.isProcessing || Date.now() - s > 8e3) {
|
|
1143
|
-
y();
|
|
1144
|
-
return;
|
|
1145
|
-
}
|
|
1146
|
-
setTimeout(I, 50);
|
|
1147
|
-
};
|
|
1148
|
-
I();
|
|
1149
|
-
}).then(() => new Promise((y) => {
|
|
1150
|
-
requestAnimationFrame(() => {
|
|
1151
|
-
_(), y();
|
|
1152
|
-
});
|
|
1153
|
-
}));
|
|
1154
|
-
}, xe = async (i = {}) => {
|
|
1155
|
-
await ve();
|
|
1156
|
-
for (const u of S.values()) u.render();
|
|
1157
|
-
await new Promise((u) => requestAnimationFrame(u));
|
|
1158
|
-
const s = await Tt(
|
|
1159
|
-
n,
|
|
1160
|
-
P,
|
|
1161
|
-
Array.from(S.values()),
|
|
1162
|
-
($ == null ? void 0 : $.dividers) ?? [],
|
|
1163
|
-
ot(),
|
|
1164
|
-
i
|
|
1165
|
-
);
|
|
1166
|
-
if (i.download) {
|
|
1167
|
-
const u = i.format === "jpeg" ? "jpg" : i.format ?? "png", y = document.createElement("a");
|
|
1168
|
-
y.download = `${i.fileName ?? "velo-plot-stack"}.${u}`, y.href = s, document.body.appendChild(y), y.click(), document.body.removeChild(y);
|
|
1169
|
-
}
|
|
1170
|
-
return s;
|
|
1171
|
-
}, be = (i) => {
|
|
1172
|
-
var Le, De, ke;
|
|
1173
|
-
if (S.size >= le)
|
|
1174
|
-
throw new Error(`[StackedChart] Cannot exceed ${le} panes`);
|
|
1175
|
-
if (S.has(i.id))
|
|
1176
|
-
throw new Error(`[StackedChart] Pane "${i.id}" already exists`);
|
|
1177
|
-
if (!a && l === "bottom" && g.length > 0) {
|
|
1178
|
-
const j = g[g.length - 1], Z = S.get(j), Me = M[M.length - 1];
|
|
1179
|
-
Z == null || Z.updateXAxis({
|
|
1180
|
-
showLabels: !1,
|
|
1181
|
-
showTicks: !1,
|
|
1182
|
-
showLine: !1
|
|
1183
|
-
}), Z == null || Z.updateLayout({
|
|
1184
|
-
margins: {
|
|
1185
|
-
bottom: c > 0 ? qe.bottom : 0
|
|
1186
|
-
}
|
|
1187
|
-
}), Me && (Me.showXAxis = !1);
|
|
1188
|
-
}
|
|
1189
|
-
const s = Xe(i.height ?? 0.25), u = A.reduce((j, Z) => j + Z, 0), y = u > 0 ? (1 - s) / u : 1;
|
|
1190
|
-
for (let j = 0; j < A.length; j++) A[j] *= y;
|
|
1191
|
-
const I = g.length;
|
|
1192
|
-
g.push(i.id), A.push(s), Be(A);
|
|
1193
|
-
const k = document.createElement("div");
|
|
1194
|
-
k.dataset.paneId = i.id, k.style.cssText = fe(A[I], c, I, r);
|
|
1195
|
-
const z = document.createElement("div");
|
|
1196
|
-
z.style.cssText = ne(), k.appendChild(z), n.appendChild(k), P.push(k), re();
|
|
1197
|
-
const E = a ? i.showXAxis ?? !0 : i.showXAxis ?? (l === "bottom" ? !0 : !0), q = a ? i.showYAxis ?? (d === "left" ? I === 0 : !0) : i.showYAxis ?? !0, G = Ee(
|
|
1198
|
-
We(
|
|
1199
|
-
i,
|
|
1200
|
-
z,
|
|
1201
|
-
e,
|
|
1202
|
-
I,
|
|
1203
|
-
g.length,
|
|
1204
|
-
{
|
|
1205
|
-
left: a && !q ? te.left : v,
|
|
1206
|
-
right: m,
|
|
1207
|
-
top: R,
|
|
1208
|
-
bottom: pe
|
|
1209
|
-
},
|
|
1210
|
-
E,
|
|
1211
|
-
q,
|
|
1212
|
-
r
|
|
1213
|
-
)
|
|
1214
|
-
);
|
|
1215
|
-
z.style.cssText = ne();
|
|
1216
|
-
const rt = Oe(i.series);
|
|
1217
|
-
for (const j of rt) G.addSeries(j);
|
|
1218
|
-
return i.yRange && i.yRange !== "auto" && G.zoom({ y: i.yRange, animate: !1 }), S.set(i.id, G), M.push({
|
|
1219
|
-
chart: G,
|
|
1220
|
-
wrapper: k,
|
|
1221
|
-
baseYTickCount: He((Le = i.chart) == null ? void 0 : Le.yAxis),
|
|
1222
|
-
baseXTickCount: ((ke = (De = i.chart) == null ? void 0 : De.xAxis) == null ? void 0 : ke.tickCount) ?? 8,
|
|
1223
|
-
showXAxis: E
|
|
1224
|
-
}), U.add(G), we(), _(), G;
|
|
1225
|
-
};
|
|
1226
|
-
return {
|
|
1227
|
-
container: n,
|
|
1228
|
-
getPane(i) {
|
|
1229
|
-
return S.get(i);
|
|
1230
|
-
},
|
|
1231
|
-
/** @deprecated Prefer `getPane(id)`. **Removed in v4.0.** */
|
|
1232
|
-
getChart(i) {
|
|
1233
|
-
return S.get(i);
|
|
1234
|
-
},
|
|
1235
|
-
getPanes() {
|
|
1236
|
-
return Array.from(S.values());
|
|
1237
|
-
},
|
|
1238
|
-
getMaster() {
|
|
1239
|
-
return ie;
|
|
1240
|
-
},
|
|
1241
|
-
getGroup() {
|
|
1242
|
-
return U;
|
|
1243
|
-
},
|
|
1244
|
-
fitAll(i) {
|
|
1245
|
-
U.fitAll(i);
|
|
1246
|
-
},
|
|
1247
|
-
resetAll() {
|
|
1248
|
-
U.resetAll();
|
|
1249
|
-
},
|
|
1250
|
-
resize() {
|
|
1251
|
-
_();
|
|
1252
|
-
},
|
|
1253
|
-
getPaneRatios() {
|
|
1254
|
-
const i = {};
|
|
1255
|
-
for (let s = 0; s < g.length; s++)
|
|
1256
|
-
i[g[s]] = A[s];
|
|
1257
|
-
return i;
|
|
1258
|
-
},
|
|
1259
|
-
setPaneRatios(i) {
|
|
1260
|
-
for (let s = 0; s < g.length; s++) {
|
|
1261
|
-
const u = g[s];
|
|
1262
|
-
i[u] !== void 0 && (A[s] = i[u]);
|
|
1263
|
-
}
|
|
1264
|
-
jt(P, A, r), _();
|
|
1265
|
-
},
|
|
1266
|
-
setSyncAxis(i) {
|
|
1267
|
-
U.syncAxis(i);
|
|
1268
|
-
},
|
|
1269
|
-
getSyncAxis() {
|
|
1270
|
-
return U.getOptions().axis ?? "x";
|
|
1271
|
-
},
|
|
1272
|
-
setSyncOptions(i) {
|
|
1273
|
-
U.updateOptions(i);
|
|
1274
|
-
},
|
|
1275
|
-
whenReady() {
|
|
1276
|
-
return ve();
|
|
1277
|
-
},
|
|
1278
|
-
exportImage(i) {
|
|
1279
|
-
return xe(i);
|
|
1280
|
-
},
|
|
1281
|
-
snapshot(i) {
|
|
1282
|
-
return xe(i);
|
|
1283
|
-
},
|
|
1284
|
-
addPane(i) {
|
|
1285
|
-
return be(i);
|
|
1286
|
-
},
|
|
1287
|
-
async addIndicator(i, s = {}) {
|
|
1288
|
-
var E;
|
|
1289
|
-
const u = ie;
|
|
1290
|
-
if (s.pane !== "new")
|
|
1291
|
-
return { ...await kt(u, i, s), chart: u };
|
|
1292
|
-
const y = me(u, s.sourceSeriesId), { x: I, prices: k } = Ne(y), z = await Mt(i, I, k, {
|
|
1293
|
-
id: s.id ?? i,
|
|
1294
|
-
label: s.label ?? i.toUpperCase(),
|
|
1295
|
-
height: s.paneHeight ?? 0.25,
|
|
1296
|
-
showXAxis: s.showXAxis,
|
|
1297
|
-
period: s.period,
|
|
1298
|
-
fastPeriod: s.fastPeriod,
|
|
1299
|
-
slowPeriod: s.slowPeriod,
|
|
1300
|
-
signalPeriod: s.signalPeriod,
|
|
1301
|
-
stdDev: s.stdDev
|
|
1302
|
-
}, y), O = be(z);
|
|
1303
|
-
return {
|
|
1304
|
-
id: z.id,
|
|
1305
|
-
preset: i,
|
|
1306
|
-
placement: "oscillator",
|
|
1307
|
-
seriesIds: ((E = z.series) == null ? void 0 : E.map((q) => q.id)) ?? [],
|
|
1308
|
-
paneId: z.id,
|
|
1309
|
-
chart: O
|
|
1310
|
-
};
|
|
1311
|
-
},
|
|
1312
|
-
destroy() {
|
|
1313
|
-
N && cancelAnimationFrame(N), B && cancelAnimationFrame(B), oe.disconnect(), $ == null || $.destroy(), U.destroy();
|
|
1314
|
-
for (const i of S.values()) i.destroy();
|
|
1315
|
-
S.clear(), n.replaceChildren();
|
|
1316
|
-
}
|
|
1317
|
-
};
|
|
1318
|
-
}
|
|
1319
|
-
export {
|
|
1320
|
-
le as S,
|
|
1321
|
-
kt as a,
|
|
1322
|
-
zt as b,
|
|
1323
|
-
sn as c,
|
|
1324
|
-
an as d,
|
|
1325
|
-
Rt as e,
|
|
1326
|
-
Mt as f,
|
|
1327
|
-
Dt as g,
|
|
1328
|
-
de as h,
|
|
1329
|
-
ge as i,
|
|
1330
|
-
on as j,
|
|
1331
|
-
xt as k,
|
|
1332
|
-
Ue as l,
|
|
1333
|
-
It as m,
|
|
1334
|
-
rn as n,
|
|
1335
|
-
St as r,
|
|
1336
|
-
Pt as s
|
|
1337
|
-
};
|
|
1338
|
-
//# sourceMappingURL=createStackedChart-DqcLCFGS.js.map
|