@overdoser/react-toolkit 0.16.0 → 0.18.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.
- package/AGENTS.md +1 -1
- package/CHANGELOG.md +74 -0
- package/components/Chart/AreaChart.d.ts +5 -1
- package/components/Chart/AreaChart.js +155 -144
- package/components/Chart/BarChart.js +5 -5
- package/components/Chart/PieChart.js +2 -5
- package/components/Chart/RadarChart.js +2 -5
- package/components/Chart/TradingChart.js +258 -257
- package/components/Drawer/Drawer.js +69 -70
- package/components/Dropdown/Dropdown.js +51 -56
- package/components/Loader/Loader.d.ts +104 -0
- package/components/Loader/Loader.js +186 -0
- package/components/Loader/Loader.module.scss.js +70 -0
- package/components/Loader/index.d.ts +2 -0
- package/components/Modal/Modal.js +42 -47
- package/components/Popover/Popover.js +52 -55
- package/components/SplitButton/SplitButton.js +50 -55
- package/components/inputs/DatePicker/DatePicker.js +82 -76
- package/components/inputs/DateTimePicker/DateTimePicker.js +4 -2
- package/components/inputs/DateTimePicker/DateTimeSegments.d.ts +2 -1
- package/components/inputs/DateTimePicker/DateTimeSegments.js +1 -1
- package/components/inputs/NumberInput/NumberInput.js +79 -81
- package/components/inputs/Select/Select.d.ts +5 -0
- package/components/inputs/Select/Select.js +340 -285
- package/hooks/useEscapeLayer.d.ts +36 -0
- package/hooks/useEscapeLayer.js +33 -0
- package/index.css +1 -1
- package/index.d.ts +2 -0
- package/index.js +74 -72
- package/index.layered.css +1 -1
- package/llms.txt +43 -2
- package/manifest.json +73 -0
- package/package.json +1 -1
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { jsxs as et, jsx as x } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as U, useState as
|
|
3
|
-
import
|
|
4
|
-
import { niceTicks as
|
|
5
|
-
import { rsi as
|
|
6
|
-
import { periodToSeconds as
|
|
7
|
-
import
|
|
8
|
-
import { Popover as
|
|
9
|
-
import { Button as
|
|
10
|
-
import { Dropdown as
|
|
11
|
-
const
|
|
12
|
-
function
|
|
2
|
+
import { useRef as U, useState as kt, useCallback as X, useMemo as Qt, useLayoutEffect as te, useEffect as ee } from "react";
|
|
3
|
+
import ne from "clsx";
|
|
4
|
+
import { niceTicks as Dt } from "./scales.js";
|
|
5
|
+
import { rsi as oe, sma as re, ema as ie, bollinger as le } from "./trading/indicators.js";
|
|
6
|
+
import { periodToSeconds as se } from "./trading/period.js";
|
|
7
|
+
import gt from "./Chart.module.scss.js";
|
|
8
|
+
import { Popover as ae } from "../Popover/Popover.js";
|
|
9
|
+
import { Button as ce } from "../Button/Button.js";
|
|
10
|
+
import { Dropdown as fe } from "../Dropdown/Dropdown.js";
|
|
11
|
+
const he = 420, vt = 64, wt = 28, ue = 40, pe = 4, Ct = { rsi: 0.18, volume: 0.14 }, de = 1, me = 40, Lt = 0.1, ge = 500, Me = [];
|
|
12
|
+
function Ge({
|
|
13
13
|
datafeed: t,
|
|
14
14
|
symbol: n,
|
|
15
15
|
resolution: e,
|
|
16
16
|
period: o,
|
|
17
17
|
seriesType: r = "candle",
|
|
18
|
-
indicators: l =
|
|
18
|
+
indicators: l = Me,
|
|
19
19
|
precision: i = 2,
|
|
20
|
-
initialLookback: s =
|
|
21
|
-
height: c =
|
|
20
|
+
initialLookback: s = ge,
|
|
21
|
+
height: c = he,
|
|
22
22
|
upColor: g = "var(--crk-color-success)",
|
|
23
|
-
downColor:
|
|
23
|
+
downColor: u = "var(--crk-color-danger)",
|
|
24
24
|
lineColor: f = "var(--crk-chart-1)",
|
|
25
25
|
timezone: d,
|
|
26
26
|
defaultTimezone: M = "local",
|
|
27
27
|
onTimezoneChange: k,
|
|
28
|
-
showConfigPanel:
|
|
29
|
-
priceBadgeColorByDirection:
|
|
28
|
+
showConfigPanel: L = !0,
|
|
29
|
+
priceBadgeColorByDirection: W = !1,
|
|
30
30
|
priceBadgeShowTime: P = !1,
|
|
31
31
|
priceBadgeTimeFormat: j,
|
|
32
32
|
onCrosshair: N,
|
|
@@ -34,241 +34,242 @@ function Ze({
|
|
|
34
34
|
className: _,
|
|
35
35
|
style: J
|
|
36
36
|
}) {
|
|
37
|
-
const
|
|
38
|
-
}),
|
|
39
|
-
|
|
40
|
-
const [st,
|
|
37
|
+
const Z = U(null), G = U(null), I = U([]), y = U({ from: 0, to: 0 }), F = U(null), V = U(null), z = U(!1), K = U(0), ht = U(null), ut = U(null), yt = U(1), pt = U({ width: 0, height: 0 }), dt = U(() => {
|
|
38
|
+
}), bt = U(N), lt = U(Y);
|
|
39
|
+
bt.current = N, lt.current = Y;
|
|
40
|
+
const [st, Ut] = kt(null), [_t, xt] = kt(M), mt = d ?? _t, Ft = X(
|
|
41
41
|
(p) => {
|
|
42
|
-
d === void 0 &&
|
|
42
|
+
d === void 0 && xt(p), k?.(p);
|
|
43
43
|
},
|
|
44
44
|
[d, k]
|
|
45
|
-
),
|
|
46
|
-
() => ({ up: g, down:
|
|
47
|
-
[g,
|
|
48
|
-
), q = l, nt = q.some((p) => p.type === "rsi"), ot = q.some((p) => p.type === "volume"),
|
|
49
|
-
const p =
|
|
45
|
+
), Rt = Qt(
|
|
46
|
+
() => ({ up: g, down: u, line: f }),
|
|
47
|
+
[g, u, f]
|
|
48
|
+
), q = l, nt = q.some((p) => p.type === "rsi"), ot = q.some((p) => p.type === "volume"), Nt = X(() => {
|
|
49
|
+
const p = G.current;
|
|
50
50
|
if (!p) return;
|
|
51
51
|
const a = p.getContext("2d");
|
|
52
52
|
if (!a) return;
|
|
53
|
-
const { width:
|
|
54
|
-
if (
|
|
55
|
-
const R =
|
|
53
|
+
const { width: S, height: b } = pt.current;
|
|
54
|
+
if (S === 0 || b === 0) return;
|
|
55
|
+
const R = yt.current;
|
|
56
56
|
a.save(), a.setTransform(1, 0, 0, 1, 0, 0), a.clearRect(0, 0, p.width, p.height), a.scale(R, R);
|
|
57
|
-
const m =
|
|
58
|
-
if (
|
|
59
|
-
|
|
57
|
+
const m = Se(Z.current, Rt), $ = It(Z.current), A = I.current;
|
|
58
|
+
if (A.length === 0) {
|
|
59
|
+
Ae(a, S, b, m), a.restore();
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
|
-
const
|
|
63
|
-
y.current = { from: T, to:
|
|
64
|
-
const
|
|
65
|
-
const it =
|
|
66
|
-
return
|
|
67
|
-
}, rt =
|
|
68
|
-
|
|
69
|
-
for (let
|
|
70
|
-
const it = q[
|
|
71
|
-
tt &&
|
|
62
|
+
const h = Mt(S, b, nt, ot), { from: T, to: v } = ye(y.current, A.length);
|
|
63
|
+
y.current = { from: T, to: v };
|
|
64
|
+
const C = A.slice(Math.max(0, Math.floor(T)), Math.min(A.length, Math.ceil(v) + 1)), H = (w) => {
|
|
65
|
+
const it = v - T + 1, tt = h.plotWidth / it;
|
|
66
|
+
return h.plotLeft + (w - T + 0.5) * tt;
|
|
67
|
+
}, rt = h.plotWidth / (v - T + 1), Q = q.map((w) => be(w, A)).filter((w) => w !== null).map((w) => ({ ...w, color: $(w.color) })), E = Pt(h.main, C, Q, T, v);
|
|
68
|
+
Tt(a, h.plotLeft, h.plotRight, E, m), ke(a, h, E, i, m), a.save(), a.beginPath(), a.rect(h.plotLeft, E.paneTop, h.plotWidth, E.paneHeight), a.clip();
|
|
69
|
+
for (let w = 0; w < q.length; w++) {
|
|
70
|
+
const it = q[w], tt = Q[w];
|
|
71
|
+
tt && $e(a, tt, it, A, T, v, H, E);
|
|
72
72
|
}
|
|
73
|
-
if (r === "candle" ?
|
|
74
|
-
const
|
|
75
|
-
|
|
73
|
+
if (r === "candle" ? Ce(a, A, T, v, H, rt, E, { up: m.up, down: m.down }) : r === "bar" ? Le(a, A, T, v, H, rt, E, { up: m.up, down: m.down }) : We(a, A, T, v, H, E, m.line, r === "area"), a.restore(), h.volume) {
|
|
74
|
+
const w = Re(h.volume, A, T, v);
|
|
75
|
+
Tt(a, h.plotLeft, h.plotRight, w, m, !0), Wt(a, h, h.volume, "Volume", m), a.save(), a.beginPath(), a.rect(h.plotLeft, w.paneTop, h.plotWidth, w.paneHeight), a.clip(), He(a, A, T, v, H, rt, w, { up: m.up, down: m.down }), a.restore();
|
|
76
76
|
}
|
|
77
|
-
if (
|
|
78
|
-
const
|
|
79
|
-
paneTop:
|
|
80
|
-
paneBottom:
|
|
81
|
-
paneHeight:
|
|
77
|
+
if (h.rsi) {
|
|
78
|
+
const w = q.find((qt) => qt.type === "rsi"), it = w && w.type === "rsi" ? w.period ?? 14 : 14, tt = w && w.type === "rsi" ? w.overbought ?? 70 : 70, At = w && w.type === "rsi" ? w.oversold ?? 30 : 30, Kt = (w && w.type === "rsi" ? w.color : void 0) ?? "var(--crk-chart-5)", jt = $(Kt), Jt = oe(A, it), ct = {
|
|
79
|
+
paneTop: h.rsi.top,
|
|
80
|
+
paneBottom: h.rsi.bottom,
|
|
81
|
+
paneHeight: h.rsi.height,
|
|
82
82
|
priceMin: 0,
|
|
83
83
|
priceMax: 100,
|
|
84
|
-
ticks: [
|
|
84
|
+
ticks: [At, 50, tt]
|
|
85
85
|
};
|
|
86
|
-
|
|
86
|
+
Tt(a, h.plotLeft, h.plotRight, ct, m, !0), Wt(a, h, h.rsi, `RSI ${it}`, m), a.save(), a.beginPath(), a.rect(h.plotLeft, ct.paneTop, h.plotWidth, ct.paneHeight), a.clip(), ft(a, Jt, T, v, H, ct, jt), a.restore(), Be(a, h, ct, tt, At, m);
|
|
87
87
|
}
|
|
88
|
-
|
|
88
|
+
De(a, h, A, T, v, e, m), F.current && Pe(
|
|
89
89
|
a,
|
|
90
|
-
|
|
90
|
+
h,
|
|
91
91
|
F.current,
|
|
92
|
-
|
|
92
|
+
A,
|
|
93
93
|
T,
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
v,
|
|
95
|
+
H,
|
|
96
96
|
i,
|
|
97
97
|
E,
|
|
98
|
-
|
|
98
|
+
mt,
|
|
99
99
|
m,
|
|
100
100
|
e,
|
|
101
|
-
|
|
101
|
+
W,
|
|
102
102
|
P,
|
|
103
103
|
j
|
|
104
104
|
), a.restore();
|
|
105
|
-
}, [r, q, nt, ot, i,
|
|
106
|
-
|
|
105
|
+
}, [r, q, nt, ot, i, Rt, e, mt, W, P, j]);
|
|
106
|
+
dt.current = Nt;
|
|
107
107
|
const O = X(() => {
|
|
108
|
-
if (
|
|
108
|
+
if (ut.current === null) {
|
|
109
109
|
if (typeof requestAnimationFrame > "u") {
|
|
110
|
-
|
|
110
|
+
dt.current();
|
|
111
111
|
return;
|
|
112
112
|
}
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
ut.current = requestAnimationFrame(() => {
|
|
114
|
+
ut.current = null, dt.current();
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
}, []);
|
|
118
|
-
|
|
119
|
-
const p =
|
|
118
|
+
te(() => {
|
|
119
|
+
const p = Z.current;
|
|
120
120
|
if (!p) return;
|
|
121
121
|
const a = () => {
|
|
122
122
|
const b = p.getBoundingClientRect(), R = typeof window < "u" && window.devicePixelRatio || 1;
|
|
123
|
-
|
|
124
|
-
const m =
|
|
123
|
+
yt.current = R, pt.current = { width: b.width, height: b.height };
|
|
124
|
+
const m = G.current;
|
|
125
125
|
m && (m.width = Math.round(b.width * R), m.height = Math.round(b.height * R), m.style.width = `${b.width}px`, m.style.height = `${b.height}px`), O();
|
|
126
126
|
};
|
|
127
127
|
if (a(), typeof ResizeObserver > "u") return;
|
|
128
|
-
const
|
|
129
|
-
return
|
|
130
|
-
}, [O]),
|
|
128
|
+
const S = new ResizeObserver(a);
|
|
129
|
+
return S.observe(p), () => S.disconnect();
|
|
130
|
+
}, [O]), ee(() => {
|
|
131
131
|
let p = !1;
|
|
132
|
-
const a = Math.floor(Date.now() / 1e3),
|
|
133
|
-
I.current = [], y.current = { from: 0, to: 0 }, O(), t.getBars({ symbol: n, resolution: e, from:
|
|
132
|
+
const a = Math.floor(Date.now() / 1e3), S = Bt(e), b = o === "MAX", R = o !== void 0 ? se(o) : S * s, m = o !== void 0 ? Math.max(10, Math.ceil(R / S)) : s, $ = b ? 0 : a - R;
|
|
133
|
+
I.current = [], y.current = { from: 0, to: 0 }, K.current += 1, z.current = !1, O(), t.getBars({ symbol: n, resolution: e, from: $, to: a, countBack: m }).then((h) => {
|
|
134
134
|
if (p) return;
|
|
135
|
-
const T = [...
|
|
135
|
+
const T = [...h].sort((C, H) => C.time - H.time);
|
|
136
136
|
I.current = T;
|
|
137
|
-
const
|
|
137
|
+
const v = T.length - 1;
|
|
138
138
|
if (o !== void 0)
|
|
139
|
-
y.current = { from: 0, to:
|
|
139
|
+
y.current = { from: 0, to: v };
|
|
140
140
|
else {
|
|
141
|
-
const
|
|
141
|
+
const C = Math.min(T.length, Math.min(200, s));
|
|
142
142
|
y.current = {
|
|
143
|
-
from: Math.max(0,
|
|
144
|
-
to:
|
|
143
|
+
from: Math.max(0, v - C + 1),
|
|
144
|
+
to: v
|
|
145
145
|
};
|
|
146
146
|
}
|
|
147
147
|
lt.current?.(y.current, T), O();
|
|
148
148
|
}).catch(() => {
|
|
149
149
|
});
|
|
150
|
-
const
|
|
150
|
+
const A = t.subscribeBars({
|
|
151
151
|
symbol: n,
|
|
152
152
|
resolution: e,
|
|
153
|
-
onTick: (
|
|
153
|
+
onTick: (h) => {
|
|
154
154
|
if (p) return;
|
|
155
|
-
const T = I.current,
|
|
156
|
-
if (
|
|
157
|
-
T[T.length - 1] =
|
|
158
|
-
else if (!
|
|
159
|
-
T.push(
|
|
160
|
-
const
|
|
161
|
-
|
|
155
|
+
const T = I.current, v = T[T.length - 1];
|
|
156
|
+
if (v && v.time === h.time)
|
|
157
|
+
T[T.length - 1] = h;
|
|
158
|
+
else if (!v || h.time > v.time) {
|
|
159
|
+
T.push(h);
|
|
160
|
+
const C = y.current;
|
|
161
|
+
C.to >= T.length - 2 && (y.current = { from: C.from + 1, to: C.to + 1 });
|
|
162
162
|
}
|
|
163
163
|
O();
|
|
164
164
|
}
|
|
165
165
|
});
|
|
166
|
-
return
|
|
167
|
-
p = !0,
|
|
166
|
+
return ht.current = A, () => {
|
|
167
|
+
p = !0, ht.current !== null && (t.unsubscribeBars(ht.current), ht.current = null);
|
|
168
168
|
};
|
|
169
169
|
}, [t, n, e, o, s]);
|
|
170
170
|
const at = X((p) => {
|
|
171
|
-
|
|
172
|
-
}, []),
|
|
171
|
+
Ut(p), bt.current?.(p);
|
|
172
|
+
}, []), Xt = X((p) => {
|
|
173
173
|
p.currentTarget.setPointerCapture(p.pointerId);
|
|
174
174
|
const a = y.current;
|
|
175
175
|
V.current = { startX: p.clientX, from: a.from, to: a.to };
|
|
176
|
-
}, []),
|
|
176
|
+
}, []), St = X(() => {
|
|
177
|
+
if (z.current) return;
|
|
178
|
+
const p = I.current;
|
|
179
|
+
if (p.length === 0) return;
|
|
180
|
+
z.current = !0;
|
|
181
|
+
const a = K.current, S = Bt(e), b = p[0].time, R = b - S * s, m = b - S;
|
|
182
|
+
t.getBars({ symbol: n, resolution: e, from: R, to: m, countBack: s }).then(($) => {
|
|
183
|
+
if (a !== K.current) return;
|
|
184
|
+
if ($.length === 0) {
|
|
185
|
+
z.current = !1;
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const h = [...$].sort((v, C) => v.time - C.time).filter((v) => v.time < b), T = y.current;
|
|
189
|
+
I.current = [...h, ...I.current], y.current = { from: T.from + h.length, to: T.to + h.length }, z.current = !1, O();
|
|
190
|
+
}).catch(() => {
|
|
191
|
+
a === K.current && (z.current = !1);
|
|
192
|
+
});
|
|
193
|
+
}, [t, n, e, s, O]), Yt = X(
|
|
177
194
|
(p) => {
|
|
178
|
-
const a = p.currentTarget.getBoundingClientRect(),
|
|
179
|
-
if (F.current = { x:
|
|
180
|
-
const { startX:
|
|
181
|
-
let Q =
|
|
182
|
-
const
|
|
183
|
-
Q < 0 && (
|
|
195
|
+
const a = p.currentTarget.getBoundingClientRect(), S = p.clientX - a.left, b = p.clientY - a.top;
|
|
196
|
+
if (F.current = { x: S, y: b }, V.current) {
|
|
197
|
+
const { startX: $, from: A, to: h } = V.current, { width: T } = pt.current, v = Math.max(1, T - vt), C = h - A + 1, H = v / C, rt = -(p.clientX - $) / H;
|
|
198
|
+
let Q = A + rt, E = h + rt;
|
|
199
|
+
const w = I.current.length;
|
|
200
|
+
Q < 0 && (St(), Q = 0, E = C - 1), E > w - 1 && (E = w - 1, Q = E - C + 1), y.current = { from: Q, to: E }, lt.current?.(y.current, I.current);
|
|
184
201
|
}
|
|
185
|
-
const R =
|
|
186
|
-
if (
|
|
187
|
-
const
|
|
188
|
-
at({ barIndex:
|
|
202
|
+
const R = Mt(a.width, a.height, nt, ot), m = y.current;
|
|
203
|
+
if (S >= R.plotLeft && S <= R.plotRight) {
|
|
204
|
+
const $ = m.to - m.from + 1, A = R.plotWidth / $, h = Math.round(m.from + (S - R.plotLeft) / A - 0.5), T = I.current, v = Math.max(0, Math.min(T.length - 1, h)), C = T[v] ?? null, H = Ie(b, R, T, m.from, m.to);
|
|
205
|
+
at({ barIndex: v, bar: C, priceAtCursor: H });
|
|
189
206
|
} else
|
|
190
207
|
at(null);
|
|
191
208
|
O();
|
|
192
209
|
},
|
|
193
|
-
[nt, ot, O, at]
|
|
194
|
-
),
|
|
210
|
+
[nt, ot, St, O, at]
|
|
211
|
+
), Vt = X((p) => {
|
|
195
212
|
p.currentTarget.releasePointerCapture(p.pointerId), V.current = null;
|
|
196
|
-
}, []),
|
|
213
|
+
}, []), zt = X(() => {
|
|
197
214
|
F.current = null, V.current = null, at(null), O();
|
|
198
|
-
}, [O, at]),
|
|
215
|
+
}, [O, at]), Zt = X(
|
|
199
216
|
(p) => {
|
|
200
217
|
p.preventDefault();
|
|
201
|
-
const a = p.currentTarget.getBoundingClientRect(),
|
|
218
|
+
const a = p.currentTarget.getBoundingClientRect(), S = p.clientX - a.left, b = Mt(a.width, a.height, nt, ot), R = y.current, m = I.current;
|
|
202
219
|
if (m.length === 0) return;
|
|
203
|
-
const
|
|
204
|
-
b.plotWidth /
|
|
205
|
-
Math.min(m.length, b.plotWidth /
|
|
206
|
-
), T = R.from + (
|
|
207
|
-
let
|
|
208
|
-
|
|
220
|
+
const $ = R.to - R.from + 1, A = p.deltaY > 0 ? 1 + Lt : 1 / (1 + Lt), h = Math.max(
|
|
221
|
+
b.plotWidth / me,
|
|
222
|
+
Math.min(m.length, b.plotWidth / de, $ * A)
|
|
223
|
+
), T = R.from + (S - b.plotLeft) / (b.plotWidth / $), v = (T - R.from) / $;
|
|
224
|
+
let C = T - v * h, H = C + h - 1;
|
|
225
|
+
C < 0 && (C = 0, H = h - 1), H > m.length - 1 && (H = m.length - 1, C = H - h + 1), y.current = { from: C, to: H }, lt.current?.(y.current, m), O();
|
|
209
226
|
},
|
|
210
227
|
[nt, ot, O]
|
|
211
|
-
),
|
|
228
|
+
), Gt = X(
|
|
212
229
|
(p) => {
|
|
213
|
-
const a = y.current,
|
|
230
|
+
const a = y.current, S = a.to - a.from + 1, b = I.current;
|
|
214
231
|
if (b.length === 0) return;
|
|
215
232
|
let R = 0;
|
|
216
|
-
if (p.key === "ArrowLeft") R = -Math.max(1, Math.floor(
|
|
217
|
-
else if (p.key === "ArrowRight") R = Math.max(1, Math.floor(
|
|
233
|
+
if (p.key === "ArrowLeft") R = -Math.max(1, Math.floor(S * 0.1));
|
|
234
|
+
else if (p.key === "ArrowRight") R = Math.max(1, Math.floor(S * 0.1));
|
|
218
235
|
else return;
|
|
219
236
|
p.preventDefault();
|
|
220
|
-
let m = a.from + R,
|
|
221
|
-
m < 0 && (m = 0,
|
|
237
|
+
let m = a.from + R, $ = a.to + R;
|
|
238
|
+
m < 0 && (m = 0, $ = S - 1), $ > b.length - 1 && ($ = b.length - 1, m = $ - S + 1), y.current = { from: m, to: $ }, lt.current?.(y.current, b), O();
|
|
222
239
|
},
|
|
223
240
|
[O]
|
|
224
|
-
)
|
|
225
|
-
if (G.current) return;
|
|
226
|
-
const p = I.current;
|
|
227
|
-
if (p.length === 0) return;
|
|
228
|
-
G.current = !0;
|
|
229
|
-
const a = $t(e), A = p[0].time, b = A - a * s, R = A - a;
|
|
230
|
-
t.getBars({ symbol: n, resolution: e, from: b, to: R, countBack: s }).then((m) => {
|
|
231
|
-
if (m.length === 0) {
|
|
232
|
-
G.current = !1;
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
const S = [...m].sort((T, w) => T.time - w.time).filter((T) => T.time < A), u = y.current;
|
|
236
|
-
I.current = [...S, ...p], y.current = { from: u.from + S.length, to: u.to + S.length }, G.current = !1, O();
|
|
237
|
-
}).catch(() => {
|
|
238
|
-
G.current = !1;
|
|
239
|
-
});
|
|
240
|
-
}, [t, n, e, s, O]);
|
|
241
|
+
);
|
|
241
242
|
return /* @__PURE__ */ et(
|
|
242
243
|
"div",
|
|
243
244
|
{
|
|
244
|
-
ref:
|
|
245
|
-
className:
|
|
245
|
+
ref: Z,
|
|
246
|
+
className: ne(gt.root, _),
|
|
246
247
|
style: { ...J, height: c, position: "relative" },
|
|
247
248
|
tabIndex: 0,
|
|
248
249
|
role: "figure",
|
|
249
250
|
"aria-label": `${n} ${e} chart`,
|
|
250
|
-
onKeyDown:
|
|
251
|
+
onKeyDown: Gt,
|
|
251
252
|
children: [
|
|
252
253
|
/* @__PURE__ */ x(
|
|
253
254
|
"canvas",
|
|
254
255
|
{
|
|
255
|
-
ref:
|
|
256
|
-
className:
|
|
257
|
-
onPointerDown:
|
|
258
|
-
onPointerMove:
|
|
259
|
-
onPointerUp:
|
|
260
|
-
onPointerLeave:
|
|
261
|
-
onWheel:
|
|
256
|
+
ref: G,
|
|
257
|
+
className: gt.svg,
|
|
258
|
+
onPointerDown: Xt,
|
|
259
|
+
onPointerMove: Yt,
|
|
260
|
+
onPointerUp: Vt,
|
|
261
|
+
onPointerLeave: zt,
|
|
262
|
+
onWheel: Zt,
|
|
262
263
|
style: { cursor: V.current ? "grabbing" : "crosshair", touchAction: "none" }
|
|
263
264
|
}
|
|
264
265
|
),
|
|
265
266
|
/* @__PURE__ */ et(
|
|
266
267
|
"div",
|
|
267
268
|
{
|
|
268
|
-
className:
|
|
269
|
+
className: gt.tradingHeader,
|
|
269
270
|
style: {
|
|
270
271
|
position: "absolute",
|
|
271
|
-
top:
|
|
272
|
+
top: pe,
|
|
272
273
|
left: 8,
|
|
273
274
|
right: 8,
|
|
274
275
|
pointerEvents: "none",
|
|
@@ -293,26 +294,26 @@ function Ze({
|
|
|
293
294
|
st.bar.close.toFixed(i)
|
|
294
295
|
] })
|
|
295
296
|
] }),
|
|
296
|
-
|
|
297
|
-
|
|
297
|
+
L && /* @__PURE__ */ x("div", { style: { pointerEvents: "auto" }, children: /* @__PURE__ */ x(
|
|
298
|
+
ae,
|
|
298
299
|
{
|
|
299
300
|
position: "bottom",
|
|
300
301
|
asChild: !0,
|
|
301
302
|
trigger: /* @__PURE__ */ x(
|
|
302
|
-
|
|
303
|
+
ce,
|
|
303
304
|
{
|
|
304
305
|
variant: "ghost",
|
|
305
306
|
size: "sm",
|
|
306
307
|
iconOnly: !0,
|
|
307
308
|
"aria-label": "Chart settings",
|
|
308
|
-
children: /* @__PURE__ */ x(
|
|
309
|
+
children: /* @__PURE__ */ x(we, {})
|
|
309
310
|
}
|
|
310
311
|
),
|
|
311
312
|
content: /* @__PURE__ */ x(
|
|
312
|
-
|
|
313
|
+
ve,
|
|
313
314
|
{
|
|
314
|
-
timezone:
|
|
315
|
-
onTimezoneChange:
|
|
315
|
+
timezone: mt,
|
|
316
|
+
onTimezoneChange: Ft
|
|
316
317
|
}
|
|
317
318
|
)
|
|
318
319
|
}
|
|
@@ -324,7 +325,7 @@ function Ze({
|
|
|
324
325
|
}
|
|
325
326
|
);
|
|
326
327
|
}
|
|
327
|
-
const
|
|
328
|
+
const Te = [
|
|
328
329
|
{ value: "local", label: "Local time" },
|
|
329
330
|
{ value: "utc", label: "UTC" },
|
|
330
331
|
{ value: "America/New_York", label: "America / New York" },
|
|
@@ -334,7 +335,7 @@ const Me = [
|
|
|
334
335
|
{ value: "Asia/Tokyo", label: "Asia / Tokyo" },
|
|
335
336
|
{ value: "Asia/Singapore", label: "Asia / Singapore" }
|
|
336
337
|
];
|
|
337
|
-
function
|
|
338
|
+
function ve({
|
|
338
339
|
timezone: t,
|
|
339
340
|
onTimezoneChange: n
|
|
340
341
|
}) {
|
|
@@ -353,9 +354,9 @@ function Te({
|
|
|
353
354
|
/* @__PURE__ */ et("label", { style: { display: "flex", flexDirection: "column", gap: 4, padding: "4px" }, children: [
|
|
354
355
|
/* @__PURE__ */ x("span", { style: { fontSize: "var(--crk-font-size-xs)", color: "var(--crk-color-text-muted)" }, children: "Timezone" }),
|
|
355
356
|
/* @__PURE__ */ x(
|
|
356
|
-
|
|
357
|
+
fe,
|
|
357
358
|
{
|
|
358
|
-
options:
|
|
359
|
+
options: Te.map((e) => ({ value: e.value, label: e.label })),
|
|
359
360
|
value: t,
|
|
360
361
|
onChange: (e) => n(e)
|
|
361
362
|
}
|
|
@@ -363,7 +364,7 @@ function Te({
|
|
|
363
364
|
] })
|
|
364
365
|
] });
|
|
365
366
|
}
|
|
366
|
-
function
|
|
367
|
+
function we() {
|
|
367
368
|
return /* @__PURE__ */ et(
|
|
368
369
|
"svg",
|
|
369
370
|
{
|
|
@@ -381,15 +382,15 @@ function ve() {
|
|
|
381
382
|
}
|
|
382
383
|
);
|
|
383
384
|
}
|
|
384
|
-
function
|
|
385
|
-
const l = Math.max(0, t -
|
|
386
|
-
let
|
|
385
|
+
function Mt(t, n, e, o) {
|
|
386
|
+
const l = Math.max(0, t - vt), i = ue, s = Math.max(i, n - wt), c = Math.max(0, l - 0), g = Math.max(0, s - i);
|
|
387
|
+
let u = g, f = i;
|
|
387
388
|
const d = { top: i, bottom: s, height: g };
|
|
388
389
|
let M = null, k = null;
|
|
389
|
-
const
|
|
390
|
-
return
|
|
390
|
+
const L = e ? Ct.rsi : 0, W = o ? Ct.volume : 0;
|
|
391
|
+
return u = g * (1 - L - W), d.top = f, d.height = u, d.bottom = d.top + u, f = d.bottom, e && (M = { top: f, height: g * L, bottom: f + g * L }, f = M.bottom), o && (k = { top: f, height: g * W, bottom: f + g * W }), { width: t, height: n, plotLeft: 0, plotRight: l, plotTop: i, plotBottom: s, plotWidth: c, plotHeight: g, main: d, rsi: M, volume: k };
|
|
391
392
|
}
|
|
392
|
-
function
|
|
393
|
+
function ye(t, n) {
|
|
393
394
|
if (n === 0) return { from: 0, to: 0 };
|
|
394
395
|
let { from: e, to: o } = t;
|
|
395
396
|
if (o >= n) {
|
|
@@ -398,13 +399,13 @@ function we(t, n) {
|
|
|
398
399
|
}
|
|
399
400
|
return e < 0 && (e = 0), o < e && (o = e), { from: e, to: o };
|
|
400
401
|
}
|
|
401
|
-
function
|
|
402
|
+
function be(t, n) {
|
|
402
403
|
if (t.type === "sma")
|
|
403
|
-
return { kind: "line", values:
|
|
404
|
+
return { kind: "line", values: re(n, t.period), color: t.color ?? "var(--crk-chart-2)" };
|
|
404
405
|
if (t.type === "ema")
|
|
405
|
-
return { kind: "line", values:
|
|
406
|
+
return { kind: "line", values: ie(n, t.period), color: t.color ?? "var(--crk-chart-3)" };
|
|
406
407
|
if (t.type === "bollinger") {
|
|
407
|
-
const e =
|
|
408
|
+
const e = le(n, t.period, t.stdDev ?? 2);
|
|
408
409
|
return {
|
|
409
410
|
kind: "bollinger",
|
|
410
411
|
middle: e.middle,
|
|
@@ -416,39 +417,39 @@ function ye(t, n) {
|
|
|
416
417
|
}
|
|
417
418
|
return null;
|
|
418
419
|
}
|
|
419
|
-
function
|
|
420
|
+
function Pt(t, n, e, o, r) {
|
|
420
421
|
let l = 1 / 0, i = -1 / 0;
|
|
421
422
|
for (const f of n)
|
|
422
423
|
f.low < l && (l = f.low), f.high > i && (i = f.high);
|
|
423
424
|
for (const f of e) {
|
|
424
425
|
const d = f.kind === "line" ? [f.values] : [f.upper, f.lower];
|
|
425
426
|
for (const M of d) {
|
|
426
|
-
const k = Math.max(0, Math.floor(o)),
|
|
427
|
-
for (let
|
|
428
|
-
const P = M[
|
|
427
|
+
const k = Math.max(0, Math.floor(o)), L = Math.min(M.length - 1, Math.ceil(r));
|
|
428
|
+
for (let W = k; W <= L; W++) {
|
|
429
|
+
const P = M[W];
|
|
429
430
|
P != null && (P < l && (l = P), P > i && (i = P));
|
|
430
431
|
}
|
|
431
432
|
}
|
|
432
433
|
}
|
|
433
434
|
(!isFinite(l) || !isFinite(i)) && (l = 0, i = 1);
|
|
434
|
-
const s = (i - l) * 0.08 || 1, c =
|
|
435
|
-
return { paneTop: t.top, paneBottom: t.bottom, paneHeight: t.height, priceMin: g, priceMax:
|
|
435
|
+
const s = (i - l) * 0.08 || 1, c = Dt(l - s, i + s, 5), g = Math.min(c[0], l), u = Math.max(c[c.length - 1], i);
|
|
436
|
+
return { paneTop: t.top, paneBottom: t.bottom, paneHeight: t.height, priceMin: g, priceMax: u, ticks: c };
|
|
436
437
|
}
|
|
437
|
-
function
|
|
438
|
+
function Re(t, n, e, o) {
|
|
438
439
|
let r = 0;
|
|
439
440
|
const l = Math.max(0, Math.floor(e)), i = Math.min(n.length - 1, Math.ceil(o));
|
|
440
441
|
for (let g = l; g <= i; g++) {
|
|
441
|
-
const
|
|
442
|
-
|
|
442
|
+
const u = n[g].volume ?? 0;
|
|
443
|
+
u > r && (r = u);
|
|
443
444
|
}
|
|
444
|
-
const s =
|
|
445
|
+
const s = Dt(0, r || 1, 3), c = Math.max(s[s.length - 1], r);
|
|
445
446
|
return { paneTop: t.top, paneBottom: t.bottom, paneHeight: t.height, priceMin: 0, priceMax: c, ticks: s };
|
|
446
447
|
}
|
|
447
448
|
function B(t, n) {
|
|
448
449
|
const e = (t - n.priceMin) / (n.priceMax - n.priceMin || 1);
|
|
449
450
|
return n.paneBottom - e * n.paneHeight;
|
|
450
451
|
}
|
|
451
|
-
function
|
|
452
|
+
function It(t) {
|
|
452
453
|
if (!t || typeof getComputedStyle > "u") return (r) => r;
|
|
453
454
|
const n = getComputedStyle(t), e = /* @__PURE__ */ new Map(), o = (r) => {
|
|
454
455
|
if (!r || !r.includes("var(")) return r;
|
|
@@ -465,8 +466,8 @@ function Dt(t) {
|
|
|
465
466
|
};
|
|
466
467
|
return o;
|
|
467
468
|
}
|
|
468
|
-
function
|
|
469
|
-
const e =
|
|
469
|
+
function Se(t, n) {
|
|
470
|
+
const e = It(t);
|
|
470
471
|
return {
|
|
471
472
|
up: e(n.up),
|
|
472
473
|
down: e(n.down),
|
|
@@ -478,10 +479,10 @@ function Re(t, n) {
|
|
|
478
479
|
bg: e("var(--crk-color-bg)") || "#ffffff"
|
|
479
480
|
};
|
|
480
481
|
}
|
|
481
|
-
function
|
|
482
|
+
function Ae(t, n, e, o) {
|
|
482
483
|
t.fillStyle = o.textMuted, t.font = "13px system-ui, sans-serif", t.textAlign = "center", t.textBaseline = "middle", t.fillText("Loading…", n / 2, e / 2);
|
|
483
484
|
}
|
|
484
|
-
function
|
|
485
|
+
function Tt(t, n, e, o, r, l = !1) {
|
|
485
486
|
t.strokeStyle = r.grid, t.lineWidth = 1, t.beginPath();
|
|
486
487
|
for (const i of o.ticks) {
|
|
487
488
|
const s = Math.round(B(i, o)) + 0.5;
|
|
@@ -489,54 +490,54 @@ function Mt(t, n, e, o, r, l = !1) {
|
|
|
489
490
|
}
|
|
490
491
|
t.stroke();
|
|
491
492
|
}
|
|
492
|
-
function
|
|
493
|
+
function ke(t, n, e, o, r) {
|
|
493
494
|
t.fillStyle = r.axis, t.font = "11px system-ui, sans-serif", t.textAlign = "left", t.textBaseline = "middle";
|
|
494
495
|
for (const l of e.ticks) {
|
|
495
496
|
const i = B(l, e);
|
|
496
497
|
t.fillText(l.toFixed(o), n.plotRight + 6, i);
|
|
497
498
|
}
|
|
498
499
|
}
|
|
499
|
-
function
|
|
500
|
-
const c = Math.max(0, Math.floor(e)), g = Math.min(n.length - 1, Math.ceil(o)),
|
|
500
|
+
function Ce(t, n, e, o, r, l, i, s) {
|
|
501
|
+
const c = Math.max(0, Math.floor(e)), g = Math.min(n.length - 1, Math.ceil(o)), u = Math.max(1, l * 0.7);
|
|
501
502
|
for (let f = c; f <= g; f++) {
|
|
502
|
-
const d = n[f], M = r(f), k = B(d.open, i),
|
|
503
|
+
const d = n[f], M = r(f), k = B(d.open, i), L = B(d.close, i), W = B(d.high, i), P = B(d.low, i), N = d.close >= d.open ? s.up : s.down;
|
|
503
504
|
t.strokeStyle = N, t.fillStyle = N, t.beginPath();
|
|
504
505
|
const Y = Math.round(M) + 0.5;
|
|
505
|
-
t.moveTo(Y,
|
|
506
|
-
const _ = Math.min(k,
|
|
507
|
-
t.fillRect(Math.round(M -
|
|
506
|
+
t.moveTo(Y, W), t.lineTo(Y, P), t.stroke();
|
|
507
|
+
const _ = Math.min(k, L), J = Math.max(1, Math.abs(L - k));
|
|
508
|
+
t.fillRect(Math.round(M - u / 2), Math.round(_), Math.round(u), Math.round(J));
|
|
508
509
|
}
|
|
509
510
|
}
|
|
510
|
-
function
|
|
511
|
-
const c = Math.max(0, Math.floor(e)), g = Math.min(n.length - 1, Math.ceil(o)),
|
|
511
|
+
function Le(t, n, e, o, r, l, i, s) {
|
|
512
|
+
const c = Math.max(0, Math.floor(e)), g = Math.min(n.length - 1, Math.ceil(o)), u = Math.max(2, Math.min(l * 0.4, 8));
|
|
512
513
|
t.lineWidth = Math.max(1, Math.min(2, l * 0.18)), t.lineCap = "butt";
|
|
513
514
|
for (let f = c; f <= g; f++) {
|
|
514
|
-
const d = n[f], M = Math.round(r(f)) + 0.5, k = B(d.high, i),
|
|
515
|
-
t.strokeStyle = j ? s.up : s.down, t.beginPath(), t.moveTo(M, k), t.lineTo(M,
|
|
515
|
+
const d = n[f], M = Math.round(r(f)) + 0.5, k = B(d.high, i), L = B(d.low, i), W = B(d.open, i), P = B(d.close, i), j = d.close >= d.open;
|
|
516
|
+
t.strokeStyle = j ? s.up : s.down, t.beginPath(), t.moveTo(M, k), t.lineTo(M, L), t.moveTo(M - u, W), t.lineTo(M, W), t.moveTo(M, P), t.lineTo(M + u, P), t.stroke();
|
|
516
517
|
}
|
|
517
518
|
}
|
|
518
|
-
function
|
|
519
|
+
function We(t, n, e, o, r, l, i, s) {
|
|
519
520
|
const c = Math.max(0, Math.floor(e)), g = Math.min(n.length - 1, Math.ceil(o));
|
|
520
521
|
if (!(g <= c)) {
|
|
521
522
|
t.strokeStyle = i, t.lineWidth = 1.5, t.beginPath(), t.moveTo(r(c), B(n[c].close, l));
|
|
522
|
-
for (let
|
|
523
|
-
t.lineTo(r(
|
|
523
|
+
for (let u = c + 1; u <= g; u++)
|
|
524
|
+
t.lineTo(r(u), B(n[u].close, l));
|
|
524
525
|
t.stroke(), s && (t.globalAlpha = 0.18, t.fillStyle = i, t.lineTo(r(g), l.paneBottom), t.lineTo(r(c), l.paneBottom), t.closePath(), t.fill(), t.globalAlpha = 1);
|
|
525
526
|
}
|
|
526
527
|
}
|
|
527
|
-
function
|
|
528
|
+
function $e(t, n, e, o, r, l, i, s) {
|
|
528
529
|
if (n.kind === "line") {
|
|
529
530
|
ft(t, n.values, r, l, i, s, n.color);
|
|
530
531
|
return;
|
|
531
532
|
}
|
|
532
533
|
const c = Math.max(0, Math.floor(r)), g = Math.min(o.length - 1, Math.ceil(l));
|
|
533
534
|
t.globalAlpha = n.fillOpacity, t.fillStyle = n.color, t.beginPath();
|
|
534
|
-
let
|
|
535
|
+
let u = !1;
|
|
535
536
|
for (let f = c; f <= g; f++) {
|
|
536
537
|
const d = n.upper[f];
|
|
537
538
|
if (d == null) continue;
|
|
538
539
|
const M = i(f), k = B(d, s);
|
|
539
|
-
|
|
540
|
+
u ? t.lineTo(M, k) : (t.moveTo(M, k), u = !0);
|
|
540
541
|
}
|
|
541
542
|
for (let f = g; f >= c; f--) {
|
|
542
543
|
const d = n.lower[f];
|
|
@@ -548,30 +549,30 @@ function ft(t, n, e, o, r, l, i) {
|
|
|
548
549
|
t.strokeStyle = i, t.lineWidth = 1.25, t.beginPath();
|
|
549
550
|
let s = !1;
|
|
550
551
|
const c = Math.max(0, Math.floor(e)), g = Math.min(n.length - 1, Math.ceil(o));
|
|
551
|
-
for (let
|
|
552
|
-
const f = n[
|
|
552
|
+
for (let u = c; u <= g; u++) {
|
|
553
|
+
const f = n[u];
|
|
553
554
|
if (f == null) {
|
|
554
555
|
s = !1;
|
|
555
556
|
continue;
|
|
556
557
|
}
|
|
557
|
-
const d = r(
|
|
558
|
+
const d = r(u), M = B(f, l);
|
|
558
559
|
s ? t.lineTo(d, M) : (t.moveTo(d, M), s = !0);
|
|
559
560
|
}
|
|
560
561
|
t.stroke();
|
|
561
562
|
}
|
|
562
|
-
function
|
|
563
|
-
const c = Math.max(0, Math.floor(e)), g = Math.min(n.length - 1, Math.ceil(o)),
|
|
563
|
+
function He(t, n, e, o, r, l, i, s) {
|
|
564
|
+
const c = Math.max(0, Math.floor(e)), g = Math.min(n.length - 1, Math.ceil(o)), u = Math.max(1, l * 0.7);
|
|
564
565
|
for (let f = c; f <= g; f++) {
|
|
565
566
|
const d = n[f], M = d.volume ?? 0;
|
|
566
567
|
if (M === 0) continue;
|
|
567
568
|
const k = d.close >= d.open;
|
|
568
569
|
t.fillStyle = k ? s.up : s.down, t.globalAlpha = 0.55;
|
|
569
|
-
const
|
|
570
|
-
t.fillRect(Math.round(r(f) -
|
|
570
|
+
const L = B(M, i), W = i.paneBottom - L;
|
|
571
|
+
t.fillRect(Math.round(r(f) - u / 2), Math.round(L), Math.round(u), Math.round(W));
|
|
571
572
|
}
|
|
572
573
|
t.globalAlpha = 1;
|
|
573
574
|
}
|
|
574
|
-
function
|
|
575
|
+
function Be(t, n, e, o, r, l) {
|
|
575
576
|
t.strokeStyle = l.grid, t.setLineDash([3, 3]), t.beginPath();
|
|
576
577
|
for (const i of [o, r]) {
|
|
577
578
|
const s = Math.round(B(i, e)) + 0.5;
|
|
@@ -579,64 +580,64 @@ function He(t, n, e, o, r, l) {
|
|
|
579
580
|
}
|
|
580
581
|
t.stroke(), t.setLineDash([]), t.fillStyle = l.axis, t.font = "10px system-ui, sans-serif", t.textAlign = "left", t.textBaseline = "middle", t.fillText(String(o), n.plotRight + 6, B(o, e)), t.fillText(String(r), n.plotRight + 6, B(r, e));
|
|
581
582
|
}
|
|
582
|
-
function
|
|
583
|
+
function Wt(t, n, e, o, r) {
|
|
583
584
|
t.fillStyle = r.textMuted, t.font = "11px system-ui, sans-serif", t.textAlign = "left", t.textBaseline = "top", t.fillText(o, n.plotLeft + 6, e.top + 4);
|
|
584
585
|
}
|
|
585
|
-
function
|
|
586
|
+
function De(t, n, e, o, r, l, i) {
|
|
586
587
|
const s = r - o + 1, c = n.plotWidth / s, g = Math.max(1, Math.round(80 / c));
|
|
587
588
|
t.fillStyle = i.axis, t.font = "11px system-ui, sans-serif", t.textAlign = "center", t.textBaseline = "middle";
|
|
588
|
-
const
|
|
589
|
-
for (let M =
|
|
590
|
-
const k = e[M],
|
|
591
|
-
t.fillText(
|
|
589
|
+
const u = Math.max(0, Math.floor(o)), f = Math.min(e.length - 1, Math.ceil(r)), d = n.plotBottom + wt / 2;
|
|
590
|
+
for (let M = u; M <= f; M += g) {
|
|
591
|
+
const k = e[M], L = n.plotLeft + (M - o + 0.5) * c;
|
|
592
|
+
t.fillText(Oe(k.time, l), L, d);
|
|
592
593
|
}
|
|
593
594
|
}
|
|
594
|
-
function
|
|
595
|
+
function Pe(t, n, e, o, r, l, i, s, c, g, u, f, d, M, k) {
|
|
595
596
|
if (e.x < n.plotLeft || e.x > n.plotRight) return;
|
|
596
|
-
const
|
|
597
|
-
if (t.save(), t.strokeStyle =
|
|
597
|
+
const L = l - r + 1, W = n.plotWidth / L, P = r + (e.x - n.plotLeft) / W - 0.5, j = Math.round(P), N = Math.max(0, Math.min(o.length - 1, j)), Y = i(N);
|
|
598
|
+
if (t.save(), t.strokeStyle = u.textMuted, t.setLineDash([3, 3]), t.lineWidth = 1, t.beginPath(), t.moveTo(Y + 0.5, n.plotTop), t.lineTo(Y + 0.5, n.plotBottom), t.moveTo(n.plotLeft, e.y + 0.5), t.lineTo(n.plotRight, e.y + 0.5), t.stroke(), t.setLineDash([]), e.y >= c.paneTop && e.y <= c.paneBottom) {
|
|
598
599
|
const _ = c.priceMax - (e.y - c.paneTop) / c.paneHeight * (c.priceMax - c.priceMin);
|
|
599
|
-
t.fillStyle =
|
|
600
|
+
t.fillStyle = u.text, t.fillRect(n.plotRight, e.y - 9, vt, 18), t.fillStyle = u.bg, t.font = "11px system-ui, sans-serif", t.textAlign = "left", t.textBaseline = "middle", t.fillText(_.toFixed(s), n.plotRight + 6, e.y);
|
|
600
601
|
}
|
|
601
602
|
if (o[N]) {
|
|
602
|
-
const _ =
|
|
603
|
+
const _ = Et(o[N].time, g);
|
|
603
604
|
t.font = "11px system-ui, sans-serif", t.textBaseline = "middle";
|
|
604
|
-
const
|
|
605
|
+
const G = t.measureText(_).width + 8 * 2, I = wt, y = Math.max(
|
|
605
606
|
n.plotLeft,
|
|
606
|
-
Math.min(n.plotRight -
|
|
607
|
+
Math.min(n.plotRight - G, Y - G / 2)
|
|
607
608
|
), F = n.plotBottom;
|
|
608
|
-
t.fillStyle =
|
|
609
|
+
t.fillStyle = u.text, t.fillRect(y, F, G, I), t.fillStyle = u.bg, t.textAlign = "center", t.fillText(_, y + G / 2, F + I / 2);
|
|
609
610
|
}
|
|
610
611
|
if (o[N]) {
|
|
611
612
|
const _ = o[N], J = _.close.toFixed(s);
|
|
612
|
-
let
|
|
613
|
+
let Z = J;
|
|
613
614
|
if (M) {
|
|
614
|
-
const K = (k ??
|
|
615
|
-
K && (
|
|
615
|
+
const K = (k ?? Ot)(_.time, f, g);
|
|
616
|
+
K && (Z = `${J} · ${K}`);
|
|
616
617
|
}
|
|
617
618
|
t.font = "11px system-ui, sans-serif", t.textBaseline = "middle";
|
|
618
|
-
const y = t.measureText(
|
|
619
|
+
const y = t.measureText(Z).width + 8 * 2, F = 18, V = Math.max(
|
|
619
620
|
n.plotLeft,
|
|
620
621
|
Math.min(n.plotRight - y, Y - y / 2)
|
|
621
|
-
),
|
|
622
|
+
), z = Math.max(0, n.plotTop - F - 2);
|
|
622
623
|
if (d) {
|
|
623
624
|
const K = _.close >= _.open;
|
|
624
|
-
t.fillStyle = K ?
|
|
625
|
+
t.fillStyle = K ? u.up : u.down, t.fillRect(V, z, y, F), t.fillStyle = "#ffffff";
|
|
625
626
|
} else
|
|
626
|
-
t.fillStyle =
|
|
627
|
-
t.textAlign = "center", t.fillText(
|
|
627
|
+
t.fillStyle = u.text, t.fillRect(V, z, y, F), t.fillStyle = u.bg;
|
|
628
|
+
t.textAlign = "center", t.fillText(Z, V + y / 2, z + F / 2);
|
|
628
629
|
}
|
|
629
630
|
t.restore();
|
|
630
631
|
}
|
|
631
|
-
function
|
|
632
|
-
const s = e.slice(Math.max(0, Math.floor(o)), Math.min(e.length, Math.ceil(r) + 1)), c =
|
|
632
|
+
function Ie(t, n, e, o, r, l, i) {
|
|
633
|
+
const s = e.slice(Math.max(0, Math.floor(o)), Math.min(e.length, Math.ceil(r) + 1)), c = Pt(n.main, s, [], o, r);
|
|
633
634
|
return t < c.paneTop || t > c.paneBottom ? null : c.priceMax - (t - c.paneTop) / c.paneHeight * (c.priceMax - c.priceMin);
|
|
634
635
|
}
|
|
635
|
-
function
|
|
636
|
+
function Oe(t, n) {
|
|
636
637
|
const e = new Date(t * 1e3);
|
|
637
638
|
return n === "D" || n === "W" || n === "M" ? `${e.getUTCFullYear()}-${D(e.getUTCMonth() + 1)}-${D(e.getUTCDate())}` : `${D(e.getUTCHours())}:${D(e.getUTCMinutes())}`;
|
|
638
639
|
}
|
|
639
|
-
const
|
|
640
|
+
const $t = [
|
|
640
641
|
"Jan",
|
|
641
642
|
"Feb",
|
|
642
643
|
"Mar",
|
|
@@ -649,14 +650,14 @@ const Lt = [
|
|
|
649
650
|
"Oct",
|
|
650
651
|
"Nov",
|
|
651
652
|
"Dec"
|
|
652
|
-
],
|
|
653
|
-
function
|
|
653
|
+
], Ht = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
654
|
+
function Ot(t, n, e) {
|
|
654
655
|
const o = new Date(t * 1e3), r = n === "D" || n === "W" || n === "M";
|
|
655
|
-
let l, i, s, c, g,
|
|
656
|
+
let l, i, s, c, g, u;
|
|
656
657
|
if (e === "local")
|
|
657
|
-
l = o.getDate(), i = o.getMonth(), s = o.getFullYear(), c = o.getHours(), g = o.getMinutes(),
|
|
658
|
+
l = o.getDate(), i = o.getMonth(), s = o.getFullYear(), c = o.getHours(), g = o.getMinutes(), u = o.getDay();
|
|
658
659
|
else if (e === "utc")
|
|
659
|
-
l = o.getUTCDate(), i = o.getUTCMonth(), s = o.getUTCFullYear(), c = o.getUTCHours(), g = o.getUTCMinutes(),
|
|
660
|
+
l = o.getUTCDate(), i = o.getUTCMonth(), s = o.getUTCFullYear(), c = o.getUTCHours(), g = o.getUTCMinutes(), u = o.getUTCDay();
|
|
660
661
|
else
|
|
661
662
|
try {
|
|
662
663
|
const d = new Intl.DateTimeFormat("en-US", {
|
|
@@ -669,19 +670,19 @@ function Pt(t, n, e) {
|
|
|
669
670
|
weekday: "short",
|
|
670
671
|
hour12: !1,
|
|
671
672
|
hourCycle: "h23"
|
|
672
|
-
}).formatToParts(o), M = (
|
|
673
|
+
}).formatToParts(o), M = (W) => d.find((P) => P.type === W)?.value ?? "";
|
|
673
674
|
l = Number(M("day")), i = Number(M("month")) - 1, s = Number(M("year")), c = Number(M("hour")), g = Number(M("minute"));
|
|
674
|
-
const k = M("weekday"),
|
|
675
|
-
|
|
675
|
+
const k = M("weekday"), L = Ht.indexOf(k);
|
|
676
|
+
u = L >= 0 ? L : 0;
|
|
676
677
|
} catch {
|
|
677
|
-
return
|
|
678
|
+
return Ot(t, n, "utc");
|
|
678
679
|
}
|
|
679
|
-
return r ? `${l} ${
|
|
680
|
+
return r ? `${l} ${$t[i]} ${s}` : `${Ht[u]} ${l} ${$t[i]} ${D(c)}:${D(g)}`;
|
|
680
681
|
}
|
|
681
|
-
function
|
|
682
|
+
function Et(t, n) {
|
|
682
683
|
const e = new Date(t * 1e3);
|
|
683
684
|
if (n === "local")
|
|
684
|
-
return `${e.getFullYear()}-${D(e.getMonth() + 1)}-${D(e.getDate())} ${D(e.getHours())}:${D(e.getMinutes())}:${D(e.getSeconds())} ${
|
|
685
|
+
return `${e.getFullYear()}-${D(e.getMonth() + 1)}-${D(e.getDate())} ${D(e.getHours())}:${D(e.getMinutes())}:${D(e.getSeconds())} ${Ee(e)}`;
|
|
685
686
|
if (n === "utc")
|
|
686
687
|
return `${e.getUTCFullYear()}-${D(e.getUTCMonth() + 1)}-${D(e.getUTCDate())} ${D(e.getUTCHours())}:${D(e.getUTCMinutes())}:${D(e.getUTCSeconds())} UTC`;
|
|
687
688
|
try {
|
|
@@ -699,17 +700,17 @@ function It(t, n) {
|
|
|
699
700
|
}).formatToParts(e), l = (s) => r.find((c) => c.type === s)?.value ?? "", i = l("timeZoneName") || n;
|
|
700
701
|
return `${l("year")}-${l("month")}-${l("day")} ${l("hour")}:${l("minute")}:${l("second")} ${i}`;
|
|
701
702
|
} catch {
|
|
702
|
-
return
|
|
703
|
+
return Et(t, "utc");
|
|
703
704
|
}
|
|
704
705
|
}
|
|
705
|
-
function
|
|
706
|
+
function Ee(t) {
|
|
706
707
|
const n = -t.getTimezoneOffset(), e = n >= 0 ? "+" : "-", o = Math.abs(n);
|
|
707
708
|
return `${e}${D(Math.floor(o / 60))}:${D(o % 60)}`;
|
|
708
709
|
}
|
|
709
710
|
function D(t) {
|
|
710
711
|
return t < 10 ? `0${t}` : String(t);
|
|
711
712
|
}
|
|
712
|
-
function
|
|
713
|
+
function Bt(t) {
|
|
713
714
|
if (t === "D") return 86400;
|
|
714
715
|
if (t === "W") return 86400 * 7;
|
|
715
716
|
if (t === "M") return 86400 * 30;
|
|
@@ -726,7 +727,7 @@ function $t(t) {
|
|
|
726
727
|
return 60;
|
|
727
728
|
}
|
|
728
729
|
export {
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
730
|
+
Ge as TradingChart,
|
|
731
|
+
Bt as approxIntervalSeconds,
|
|
732
|
+
Et as formatCrosshairTime
|
|
732
733
|
};
|