@gearbox-protocol/ui-kit 3.14.0-next.35 → 3.14.0-next.37
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.
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { createChart as
|
|
1
|
+
import { jsxs as re, jsx as y } from "react/jsx-runtime";
|
|
2
|
+
import { createChart as Ue, CrosshairMode as et, LineStyle as Ge, LineSeries as tt, AreaSeries as ot } from "lightweight-charts";
|
|
3
3
|
import * as Ce from "react";
|
|
4
|
-
import { useRef as
|
|
5
|
-
import { useIsMobile as
|
|
6
|
-
import { cn as
|
|
7
|
-
import { resolveCSSColor as
|
|
8
|
-
import { getDefaultOptions as
|
|
9
|
-
import { getXFormatters as
|
|
10
|
-
import { GraphCurrentValue as
|
|
11
|
-
import { GraphTooltip as
|
|
12
|
-
import { VertLine as
|
|
13
|
-
class
|
|
4
|
+
import { useRef as X, useState as Se, useEffect as W } from "react";
|
|
5
|
+
import { useIsMobile as rt } from "../../hooks/use-media-query.js";
|
|
6
|
+
import { cn as ne } from "../../utils/cn.js";
|
|
7
|
+
import { resolveCSSColor as U, generateColorsFromBase as se, hslToHex as nt } from "../../utils/colors.js";
|
|
8
|
+
import { getDefaultOptions as je, getDefaultSeries as lt, getDefaultVerticalLine as at } from "./default-config.js";
|
|
9
|
+
import { getXFormatters as He, formatExactValue as xe, createAdaptiveYAxisFormatter as it } from "./formatters.js";
|
|
10
|
+
import { GraphCurrentValue as st } from "./graph-current-value.js";
|
|
11
|
+
import { GraphTooltip as ct } from "./graph-tooltip.js";
|
|
12
|
+
import { VertLine as ut } from "./plugins/vertical-line.js";
|
|
13
|
+
class ft {
|
|
14
14
|
_yTop;
|
|
15
15
|
_yBottom;
|
|
16
16
|
_color;
|
|
17
|
-
constructor(
|
|
18
|
-
this._yTop =
|
|
17
|
+
constructor(c, g, b) {
|
|
18
|
+
this._yTop = c, this._yBottom = g, this._color = b;
|
|
19
19
|
}
|
|
20
|
-
draw(
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
20
|
+
draw(c) {
|
|
21
|
+
c.useBitmapCoordinateSpace((g) => {
|
|
22
|
+
const b = g.context, d = g.verticalPixelRatio, w = this._yTop === null ? 0 : this._yTop * d, q = this._yBottom === null ? g.bitmapSize.height : this._yBottom * d, x = Math.min(w, q), k = Math.max(w, q);
|
|
23
|
+
b.fillStyle = this._color, b.fillRect(0, x, g.bitmapSize.width, k - x);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
class
|
|
27
|
+
class ht {
|
|
28
28
|
_source;
|
|
29
29
|
_yTop = null;
|
|
30
30
|
_yBottom = null;
|
|
31
|
-
constructor(
|
|
32
|
-
this._source =
|
|
31
|
+
constructor(c) {
|
|
32
|
+
this._source = c;
|
|
33
33
|
}
|
|
34
34
|
update() {
|
|
35
|
-
const
|
|
36
|
-
this._yTop = this._source.priceTop === void 0 ? null :
|
|
35
|
+
const c = this._source.series;
|
|
36
|
+
this._yTop = this._source.priceTop === void 0 ? null : c.priceToCoordinate(this._source.priceTop), this._yBottom = this._source.priceBottom === void 0 ? null : c.priceToCoordinate(this._source.priceBottom);
|
|
37
37
|
}
|
|
38
38
|
/** Draw beneath the series line/area so the data stays readable. */
|
|
39
39
|
zOrder() {
|
|
40
40
|
return "bottom";
|
|
41
41
|
}
|
|
42
42
|
renderer() {
|
|
43
|
-
return new
|
|
43
|
+
return new ft(this._yTop, this._yBottom, this._source.color);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
class
|
|
46
|
+
class gt {
|
|
47
47
|
series;
|
|
48
48
|
priceTop;
|
|
49
49
|
priceBottom;
|
|
50
50
|
color;
|
|
51
51
|
_paneViews;
|
|
52
|
-
constructor(
|
|
53
|
-
this.series =
|
|
52
|
+
constructor(c, g, b, d) {
|
|
53
|
+
this.series = c, this.priceTop = g, this.priceBottom = b, this.color = d, this._paneViews = [new ht(this)];
|
|
54
54
|
}
|
|
55
55
|
updateAllViews() {
|
|
56
|
-
for (const
|
|
56
|
+
for (const c of this._paneViews) c.update();
|
|
57
57
|
}
|
|
58
58
|
paneViews() {
|
|
59
59
|
return this._paneViews;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
) : String(
|
|
68
|
-
return { labelText:
|
|
62
|
+
function dt(o, c, g) {
|
|
63
|
+
const b = o.labelText ?? "", d = o.value, w = d === void 0 ? "" : typeof d == "number" ? c === "$" ? `$${xe(d, void 0, g)}` : c === "%" ? `${xe(d, void 0, g)}%` : xe(
|
|
64
|
+
d,
|
|
65
|
+
c !== "none" && c !== "%" && c !== "$" ? c : void 0,
|
|
66
|
+
g
|
|
67
|
+
) : String(d);
|
|
68
|
+
return { labelText: b, valueStr: w };
|
|
69
69
|
}
|
|
70
|
-
function mt(
|
|
71
|
-
for (let
|
|
72
|
-
if (Number(
|
|
73
|
-
return
|
|
70
|
+
function mt(o, c) {
|
|
71
|
+
for (let g = o.length - 1; g >= 0; g--)
|
|
72
|
+
if (Number(o[g].time) <= c)
|
|
73
|
+
return o[g].value;
|
|
74
74
|
return 0;
|
|
75
75
|
}
|
|
76
76
|
const ye = [
|
|
@@ -188,72 +188,70 @@ const ye = [
|
|
|
188
188
|
top: "rgba(71, 85, 105, 0.56)",
|
|
189
189
|
bottom: "rgba(71, 85, 105, 0.04)"
|
|
190
190
|
}
|
|
191
|
-
],
|
|
192
|
-
function
|
|
193
|
-
if (
|
|
194
|
-
return ye[
|
|
195
|
-
const
|
|
196
|
-
return { line:
|
|
191
|
+
], bt = 137.5;
|
|
192
|
+
function Xe(o) {
|
|
193
|
+
if (o < ye.length)
|
|
194
|
+
return ye[o];
|
|
195
|
+
const g = (o - ye.length) * bt % 360, b = nt(g, 70, 50), { topColor: d, bottomColor: w } = se(b);
|
|
196
|
+
return { line: b, top: d, bottom: w };
|
|
197
197
|
}
|
|
198
198
|
function Lt({
|
|
199
|
-
series:
|
|
200
|
-
className:
|
|
201
|
-
showLegend:
|
|
202
|
-
onUnselectSeries:
|
|
203
|
-
xMeasureUnit:
|
|
199
|
+
series: o,
|
|
200
|
+
className: c,
|
|
201
|
+
showLegend: g = !1,
|
|
202
|
+
onUnselectSeries: b,
|
|
203
|
+
xMeasureUnit: d = "time",
|
|
204
204
|
yMeasureUnit: w = "token",
|
|
205
|
-
optionsOverrides:
|
|
206
|
-
verticalLineOptions:
|
|
207
|
-
priceLineOptions:
|
|
208
|
-
zoneOptions:
|
|
209
|
-
currentValueDecimals:
|
|
210
|
-
useSharedPriceScale:
|
|
211
|
-
dualYAxis:
|
|
205
|
+
optionsOverrides: q,
|
|
206
|
+
verticalLineOptions: x,
|
|
207
|
+
priceLineOptions: k,
|
|
208
|
+
zoneOptions: A,
|
|
209
|
+
currentValueDecimals: ce,
|
|
210
|
+
useSharedPriceScale: $ = !1,
|
|
211
|
+
dualYAxis: _ = !1,
|
|
212
212
|
defaultVisiblePriceScaleId: we = "right",
|
|
213
|
-
leftPriceScaleTitle:
|
|
214
|
-
rightPriceScaleTitle:
|
|
215
|
-
showCurrentValue:
|
|
216
|
-
graphTitle:
|
|
217
|
-
yScaleMin:
|
|
213
|
+
leftPriceScaleTitle: Ne,
|
|
214
|
+
rightPriceScaleTitle: vt,
|
|
215
|
+
showCurrentValue: qe = !0,
|
|
216
|
+
graphTitle: ue,
|
|
217
|
+
yScaleMin: Te,
|
|
218
218
|
yScaleMinMultiple: Ve,
|
|
219
|
-
visibleTimeFrom:
|
|
220
|
-
disableZoom:
|
|
221
|
-
hideDefaultTooltip:
|
|
219
|
+
visibleTimeFrom: Z,
|
|
220
|
+
disableZoom: le = !1,
|
|
221
|
+
hideDefaultTooltip: fe = !1
|
|
222
222
|
}) {
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
if (e.data.length > 0)
|
|
229
|
-
return e.data[e.data.length - 1];
|
|
223
|
+
const I = X(null), v = X(/* @__PURE__ */ new Map()), he = X(!1), Re = X(!0), Pe = X([]), K = X(null), ge = X(null), ae = X(null), R = rt(), G = Ce.useMemo(() => o.flatMap((t) => t.data), [o]), Ze = Ce.useMemo(() => {
|
|
224
|
+
if (o.length > 0) {
|
|
225
|
+
const t = o[o.length - 1];
|
|
226
|
+
if (t.data.length > 0)
|
|
227
|
+
return t.data[t.data.length - 1];
|
|
230
228
|
}
|
|
231
|
-
}, [
|
|
232
|
-
if (!
|
|
233
|
-
const
|
|
234
|
-
for (const a of
|
|
235
|
-
a.data.length > 0 &&
|
|
236
|
-
return
|
|
237
|
-
}), [
|
|
238
|
-
|
|
239
|
-
const
|
|
229
|
+
}, [o]), [Me, de] = Se(() => {
|
|
230
|
+
if (!Ze) return;
|
|
231
|
+
const t = /* @__PURE__ */ new Map();
|
|
232
|
+
for (const a of o)
|
|
233
|
+
a.data.length > 0 && t.set(a.label, a.data[a.data.length - 1]);
|
|
234
|
+
return t;
|
|
235
|
+
}), [ke, j] = Se(null), [Le, _e] = Se([]);
|
|
236
|
+
W(() => {
|
|
237
|
+
const t = () => {
|
|
240
238
|
try {
|
|
241
|
-
if (
|
|
242
|
-
const n =
|
|
243
|
-
|
|
239
|
+
if (I.current && K.current) {
|
|
240
|
+
const n = K.current.clientWidth, i = K.current.clientHeight;
|
|
241
|
+
I.current.resize(n, i);
|
|
244
242
|
}
|
|
245
243
|
} catch {
|
|
246
244
|
}
|
|
247
|
-
}, a =
|
|
248
|
-
return
|
|
249
|
-
a && l?.unobserve(a), l?.disconnect(),
|
|
245
|
+
}, a = K.current, l = a ? new ResizeObserver(t) : null;
|
|
246
|
+
return ae.current = l, a && l?.observe(a), () => {
|
|
247
|
+
a && l?.unobserve(a), l?.disconnect(), ae.current = null;
|
|
250
248
|
};
|
|
251
|
-
}, []),
|
|
252
|
-
if (!
|
|
253
|
-
const
|
|
249
|
+
}, []), W(() => {
|
|
250
|
+
if (!ge.current || he.current) return;
|
|
251
|
+
const t = je(), a = U(
|
|
254
252
|
"hsl(var(--foreground))",
|
|
255
253
|
"rgb(0, 0, 0)"
|
|
256
|
-
), l =
|
|
254
|
+
), l = le ? {
|
|
257
255
|
handleScale: {
|
|
258
256
|
mouseWheel: !1,
|
|
259
257
|
pinch: !1,
|
|
@@ -266,34 +264,34 @@ function Lt({
|
|
|
266
264
|
horzTouchDrag: !1,
|
|
267
265
|
vertTouchDrag: !1
|
|
268
266
|
}
|
|
269
|
-
} : {}, n =
|
|
270
|
-
...
|
|
267
|
+
} : {}, n = Ue(ge.current, {
|
|
268
|
+
...t,
|
|
271
269
|
leftPriceScale: {
|
|
272
|
-
...
|
|
270
|
+
...t.leftPriceScale || {},
|
|
273
271
|
visible: !1,
|
|
274
272
|
textColor: a
|
|
275
273
|
},
|
|
276
274
|
rightPriceScale: {
|
|
277
|
-
...
|
|
278
|
-
visible: !
|
|
275
|
+
...t.rightPriceScale || {},
|
|
276
|
+
visible: !R,
|
|
279
277
|
textColor: a
|
|
280
278
|
},
|
|
281
|
-
...
|
|
279
|
+
...R && {
|
|
282
280
|
crosshair: {
|
|
283
|
-
...
|
|
284
|
-
mode:
|
|
281
|
+
...t.crosshair,
|
|
282
|
+
mode: et.Magnet
|
|
285
283
|
}
|
|
286
284
|
},
|
|
287
285
|
...l,
|
|
288
|
-
...
|
|
286
|
+
...q
|
|
289
287
|
});
|
|
290
|
-
return
|
|
291
|
-
|
|
288
|
+
return I.current = n, he.current = !0, () => {
|
|
289
|
+
ae.current?.disconnect(), ae.current = null, n.remove(), I.current = null, he.current = !1, v.current.clear();
|
|
292
290
|
};
|
|
293
|
-
}, [
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
|
|
291
|
+
}, [R, q, le]), W(() => {
|
|
292
|
+
const t = I.current;
|
|
293
|
+
t && t.applyOptions(
|
|
294
|
+
le ? {
|
|
297
295
|
handleScale: {
|
|
298
296
|
mouseWheel: !1,
|
|
299
297
|
pinch: !1,
|
|
@@ -321,58 +319,89 @@ function Lt({
|
|
|
321
319
|
}
|
|
322
320
|
}
|
|
323
321
|
);
|
|
324
|
-
}, [
|
|
325
|
-
const
|
|
326
|
-
if (!
|
|
327
|
-
const l =
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
const
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
322
|
+
}, [le]), W(() => {
|
|
323
|
+
const t = I.current;
|
|
324
|
+
if (!t || o.length === 0) return;
|
|
325
|
+
const l = o.filter((r) => r.data.length > 0).length <= 1 ? Te : Ve, n = d === "time" ? He(d, G) : He(d), i = /* @__PURE__ */ new Map();
|
|
326
|
+
{
|
|
327
|
+
let r = 0;
|
|
328
|
+
for (const e of o)
|
|
329
|
+
e.data.length !== 0 && (i.set(
|
|
330
|
+
e.label,
|
|
331
|
+
e.priceScaleId ?? (r === 0 ? "left" : "right")
|
|
332
|
+
), r++);
|
|
333
|
+
}
|
|
334
|
+
const f = (r, e, s) => {
|
|
335
|
+
const {
|
|
336
|
+
formatter: L,
|
|
337
|
+
tickmarksFormatter: V,
|
|
338
|
+
updateVisibleRange: z,
|
|
339
|
+
updateLastValues: De
|
|
340
|
+
} = it(r, e, {
|
|
341
|
+
yScaleMin: l
|
|
342
|
+
}), be = o.filter((O) => O.data.length > 0 && s.has(O.label)).map((O) => O.data[O.data.length - 1].value);
|
|
343
|
+
return De(be), { formatter: L, tickmarksFormatter: V, updateVisibleRange: z, labels: s };
|
|
344
|
+
}, u = [];
|
|
345
|
+
if (_)
|
|
346
|
+
for (const r of ["left", "right"]) {
|
|
347
|
+
const e = /* @__PURE__ */ new Set(), s = [];
|
|
348
|
+
let L = w;
|
|
349
|
+
for (const V of o)
|
|
350
|
+
if (V.data.length !== 0 && i.get(V.label) === r) {
|
|
351
|
+
e.size === 0 && V.yMeasureUnit && (L = V.yMeasureUnit), e.add(V.label);
|
|
352
|
+
for (const z of V.data) s.push(z.value);
|
|
353
|
+
}
|
|
354
|
+
e.size > 0 && u.push(f(s, L, e));
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
const r = G.map((s) => s.value), e = new Set(
|
|
358
|
+
o.filter((s) => s.data.length > 0).map((s) => s.label)
|
|
359
|
+
);
|
|
360
|
+
u.push(f(r, w, e));
|
|
361
|
+
}
|
|
362
|
+
Pe.current = u;
|
|
363
|
+
const p = /* @__PURE__ */ new Map();
|
|
364
|
+
for (const r of u)
|
|
365
|
+
for (const e of r.labels)
|
|
366
|
+
p.set(e, r);
|
|
367
|
+
const C = je();
|
|
368
|
+
t.applyOptions({
|
|
340
369
|
localization: {
|
|
341
|
-
...
|
|
370
|
+
...C.localization || {},
|
|
342
371
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
343
|
-
timeFormatter: (
|
|
372
|
+
timeFormatter: (r) => (
|
|
344
373
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
345
|
-
n.timeFormatter(parseFloat(
|
|
374
|
+
n.timeFormatter(parseFloat(r), void 0)
|
|
346
375
|
)
|
|
347
376
|
},
|
|
348
377
|
timeScale: {
|
|
349
|
-
...
|
|
378
|
+
...C.timeScale || {},
|
|
350
379
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
351
380
|
tickMarkFormatter: n.tickMarkFormatter,
|
|
352
381
|
minBarSpacing: 0
|
|
353
382
|
}
|
|
354
383
|
});
|
|
355
|
-
const
|
|
384
|
+
const B = (G.length > 0 ? Math.min(...G.map((r) => r.value)) : 0) < 0, N = G.some((r) => r.value === 0), m = !B && N, S = !_ && o.length > 1 && !$, P = _ ? R : o.length > 1 && !$ || R, M = U(
|
|
356
385
|
"hsl(var(--foreground))",
|
|
357
386
|
"rgb(0, 0, 0)"
|
|
358
387
|
);
|
|
359
|
-
|
|
360
|
-
...
|
|
388
|
+
t.applyOptions({
|
|
389
|
+
..._ && {
|
|
361
390
|
defaultVisiblePriceScaleId: we
|
|
362
391
|
},
|
|
363
392
|
leftPriceScale: {
|
|
364
|
-
...
|
|
365
|
-
visible:
|
|
366
|
-
textColor:
|
|
367
|
-
...
|
|
393
|
+
...C.leftPriceScale || {},
|
|
394
|
+
visible: _ && !R,
|
|
395
|
+
textColor: M,
|
|
396
|
+
..._ && Ne && {
|
|
368
397
|
// lightweight-charts uses scale margins; title shown via localization if needed
|
|
369
398
|
}
|
|
370
399
|
},
|
|
371
400
|
rightPriceScale: {
|
|
372
|
-
...
|
|
373
|
-
visible:
|
|
374
|
-
textColor:
|
|
375
|
-
...
|
|
401
|
+
...C.rightPriceScale || {},
|
|
402
|
+
visible: _ ? !R : !P,
|
|
403
|
+
textColor: M,
|
|
404
|
+
...m && !_ && {
|
|
376
405
|
scaleMargins: {
|
|
377
406
|
top: 0.3,
|
|
378
407
|
bottom: 0
|
|
@@ -380,129 +409,129 @@ function Lt({
|
|
|
380
409
|
}
|
|
381
410
|
}
|
|
382
411
|
});
|
|
383
|
-
const
|
|
384
|
-
for (const
|
|
385
|
-
if (!
|
|
386
|
-
const
|
|
387
|
-
|
|
412
|
+
const T = new Set(v.current.keys()), J = new Set(o.map((r) => r.label));
|
|
413
|
+
for (const r of T)
|
|
414
|
+
if (!J.has(r)) {
|
|
415
|
+
const e = v.current.get(r);
|
|
416
|
+
e && (t.removeSeries(e), v.current.delete(r));
|
|
388
417
|
}
|
|
389
|
-
const
|
|
390
|
-
let
|
|
391
|
-
const
|
|
392
|
-
if (
|
|
393
|
-
for (const
|
|
394
|
-
if (!Number.isFinite(
|
|
395
|
-
const
|
|
396
|
-
if (!
|
|
397
|
-
const
|
|
398
|
-
|
|
418
|
+
const Q = lt(), ee = [];
|
|
419
|
+
let te = 0;
|
|
420
|
+
const Fe = o.find((r) => r.data.length > 0), oe = /* @__PURE__ */ new Map();
|
|
421
|
+
if (k && k.length > 0)
|
|
422
|
+
for (const r of k) {
|
|
423
|
+
if (!Number.isFinite(r.price)) continue;
|
|
424
|
+
const e = r.seriesLabel ?? Fe?.label;
|
|
425
|
+
if (!e) continue;
|
|
426
|
+
const s = oe.get(e) ?? [];
|
|
427
|
+
s.push(r.price), oe.set(e, s);
|
|
399
428
|
}
|
|
400
|
-
if (
|
|
401
|
-
for (const
|
|
402
|
-
const
|
|
403
|
-
if (!
|
|
404
|
-
const
|
|
405
|
-
Number.isFinite(
|
|
429
|
+
if (A && A.length > 0)
|
|
430
|
+
for (const r of A) {
|
|
431
|
+
const e = r.seriesLabel ?? Fe?.label;
|
|
432
|
+
if (!e) continue;
|
|
433
|
+
const s = oe.get(e) ?? [];
|
|
434
|
+
Number.isFinite(r.priceTop) && s.push(r.priceTop), Number.isFinite(r.priceBottom) && s.push(r.priceBottom), oe.set(e, s);
|
|
406
435
|
}
|
|
407
|
-
for (let
|
|
408
|
-
const
|
|
409
|
-
let
|
|
410
|
-
if (
|
|
411
|
-
if (
|
|
412
|
-
|
|
413
|
-
else if (
|
|
414
|
-
const
|
|
415
|
-
|
|
416
|
-
} else if (
|
|
417
|
-
|
|
436
|
+
for (let r = 0; r < o.length; r++) {
|
|
437
|
+
const e = o[r], s = Xe(r), L = e.lineColor ?? e.color ?? s.line;
|
|
438
|
+
let V, z;
|
|
439
|
+
if (e.lineColor ?? e.color)
|
|
440
|
+
if (e.topColor && e.bottomColor)
|
|
441
|
+
V = e.topColor, z = e.bottomColor;
|
|
442
|
+
else if (e.topColor) {
|
|
443
|
+
const h = se(L);
|
|
444
|
+
V = e.topColor, z = h.bottomColor;
|
|
445
|
+
} else if (e.bottomColor)
|
|
446
|
+
V = se(L).topColor, z = e.bottomColor;
|
|
418
447
|
else {
|
|
419
|
-
const
|
|
420
|
-
|
|
448
|
+
const h = se(L);
|
|
449
|
+
V = h.topColor, z = h.bottomColor;
|
|
421
450
|
}
|
|
422
451
|
else
|
|
423
|
-
|
|
424
|
-
if (
|
|
425
|
-
const
|
|
426
|
-
|
|
452
|
+
V = e.topColor || s.top, z = e.bottomColor || s.bottom;
|
|
453
|
+
if (e.data.length === 0) {
|
|
454
|
+
const h = v.current.get(e.label);
|
|
455
|
+
h && (t.removeSeries(h), v.current.delete(e.label));
|
|
427
456
|
continue;
|
|
428
457
|
}
|
|
429
|
-
const
|
|
430
|
-
|
|
431
|
-
priceScaleId:
|
|
458
|
+
const be = (e.data.length > 0 ? Math.min(...e.data.map((h) => h.value)) : 0) < 0, O = e.data.some((h) => h.value === 0), Ke = !be && O, Ie = _ ? e.priceScaleId ?? (te === 0 ? "left" : "right") : $ || !S || te === 0 ? "right" : `scale-${te}`;
|
|
459
|
+
S && ee.push({
|
|
460
|
+
priceScaleId: Ie || "right",
|
|
432
461
|
shouldPreventNegativeAxis: Ke,
|
|
433
|
-
seriesIndex:
|
|
462
|
+
seriesIndex: te
|
|
434
463
|
});
|
|
435
|
-
const
|
|
436
|
-
const
|
|
437
|
-
if (
|
|
438
|
-
|
|
439
|
-
for (const
|
|
440
|
-
|
|
464
|
+
const ze = ($ || !S) && l !== void 0 && typeof l == "number", Oe = oe.get(e.label) ?? [], Je = (h) => {
|
|
465
|
+
const D = h();
|
|
466
|
+
if (D?.priceRange) {
|
|
467
|
+
ze && (D.priceRange.minValue = l);
|
|
468
|
+
for (const E of Oe)
|
|
469
|
+
E < D.priceRange.minValue && (D.priceRange.minValue = E), E > D.priceRange.maxValue && (D.priceRange.maxValue = E);
|
|
441
470
|
}
|
|
442
|
-
return
|
|
443
|
-
}, pe = {
|
|
444
|
-
lineColor:
|
|
445
|
-
topColor:
|
|
446
|
-
bottomColor:
|
|
447
|
-
priceScaleId:
|
|
448
|
-
...
|
|
449
|
-
lineStyle:
|
|
471
|
+
return D;
|
|
472
|
+
}, We = p.get(e.label) ?? u[0], $e = We.formatter, Qe = We.tickmarksFormatter, pe = {
|
|
473
|
+
lineColor: L,
|
|
474
|
+
topColor: V,
|
|
475
|
+
bottomColor: z,
|
|
476
|
+
priceScaleId: Ie,
|
|
477
|
+
...e.seriesType === "line" && {
|
|
478
|
+
lineStyle: e.lineStyle ?? Ge.Solid
|
|
450
479
|
},
|
|
451
480
|
priceFormat: {
|
|
452
481
|
type: "custom",
|
|
453
482
|
minMove: 0.01,
|
|
454
|
-
formatter:
|
|
455
|
-
|
|
456
|
-
) :
|
|
457
|
-
tickmarksFormatter:
|
|
483
|
+
formatter: ze && typeof l == "number" ? (h) => $e(
|
|
484
|
+
h < l ? l : h
|
|
485
|
+
) : $e,
|
|
486
|
+
tickmarksFormatter: Qe
|
|
458
487
|
},
|
|
459
488
|
autoscaleInfoProvider: Je
|
|
460
|
-
},
|
|
461
|
-
let
|
|
462
|
-
const
|
|
463
|
-
...
|
|
464
|
-
time:
|
|
489
|
+
}, Ee = e.seriesType === "line";
|
|
490
|
+
let F = v.current.get(e.label);
|
|
491
|
+
const Y = e.data.map((h) => ({
|
|
492
|
+
...h,
|
|
493
|
+
time: h.time
|
|
465
494
|
}));
|
|
466
|
-
if (
|
|
467
|
-
const
|
|
468
|
-
for (let ve =
|
|
469
|
-
|
|
470
|
-
|
|
495
|
+
if (Z !== void 0 && Y.length > 0 && Number(Y[0].time) > Z) {
|
|
496
|
+
const h = Number(Y[0].time), D = h - Z, E = 86400, Ye = D > 180 * E ? 7 * E : D > 30 * E ? E : 6 * 3600, Ae = [];
|
|
497
|
+
for (let ve = Z; ve < h; ve += Ye)
|
|
498
|
+
Ae.push({ time: ve });
|
|
499
|
+
Y.unshift(...Ae);
|
|
471
500
|
}
|
|
472
|
-
|
|
473
|
-
...
|
|
501
|
+
F && F.seriesType() !== (Ee ? "Line" : "Area") && (t.removeSeries(F), v.current.delete(e.label), F = void 0), F ? (F.applyOptions(pe), F.setData(Y)) : (Ee ? F = t.addSeries(tt, {
|
|
502
|
+
...Q,
|
|
474
503
|
...pe
|
|
475
|
-
}) :
|
|
476
|
-
...
|
|
504
|
+
}) : F = t.addSeries(ot, {
|
|
505
|
+
...Q,
|
|
477
506
|
...pe
|
|
478
|
-
}),
|
|
507
|
+
}), F.setData(Y), v.current.set(e.label, F)), te++;
|
|
479
508
|
}
|
|
480
|
-
if (
|
|
509
|
+
if (_)
|
|
481
510
|
try {
|
|
482
|
-
const
|
|
483
|
-
visible: !
|
|
511
|
+
const r = t.priceScale("left"), e = t.priceScale("right"), s = {
|
|
512
|
+
visible: !R,
|
|
484
513
|
autoScale: !0,
|
|
485
514
|
scaleMargins: { top: 0.1, bottom: 0.1 },
|
|
486
515
|
alignLabels: !0,
|
|
487
516
|
borderVisible: !0,
|
|
488
517
|
borderColor: "rgba(224, 227, 235, 0.1)",
|
|
489
518
|
entireTextOnly: !1,
|
|
490
|
-
textColor:
|
|
519
|
+
textColor: M
|
|
491
520
|
};
|
|
492
|
-
|
|
521
|
+
r?.applyOptions(s), e?.applyOptions(s);
|
|
493
522
|
} catch {
|
|
494
523
|
}
|
|
495
|
-
else if (
|
|
496
|
-
for (const
|
|
524
|
+
else if (S && ee.length > 0)
|
|
525
|
+
for (const r of ee)
|
|
497
526
|
try {
|
|
498
|
-
const
|
|
499
|
-
|
|
527
|
+
const e = t.priceScale(r.priceScaleId);
|
|
528
|
+
e && e.applyOptions({
|
|
500
529
|
visible: !1,
|
|
501
530
|
autoScale: !0,
|
|
502
531
|
scaleMargins: {
|
|
503
532
|
top: 0.1,
|
|
504
533
|
bottom: 0.1,
|
|
505
|
-
...
|
|
534
|
+
...r.shouldPreventNegativeAxis && {
|
|
506
535
|
top: 0.3,
|
|
507
536
|
bottom: 0
|
|
508
537
|
}
|
|
@@ -511,25 +540,25 @@ function Lt({
|
|
|
511
540
|
borderVisible: !0,
|
|
512
541
|
borderColor: "rgba(224, 227, 235, 0.1)",
|
|
513
542
|
entireTextOnly: !1,
|
|
514
|
-
textColor:
|
|
543
|
+
textColor: M
|
|
515
544
|
});
|
|
516
|
-
} catch (
|
|
545
|
+
} catch (e) {
|
|
517
546
|
console.warn(
|
|
518
|
-
`Failed to configure price scale ${
|
|
519
|
-
|
|
547
|
+
`Failed to configure price scale ${r.priceScaleId} for series ${r.seriesIndex}:`,
|
|
548
|
+
e
|
|
520
549
|
);
|
|
521
550
|
}
|
|
522
|
-
else if (!
|
|
551
|
+
else if (!S)
|
|
523
552
|
try {
|
|
524
|
-
const
|
|
525
|
-
|
|
526
|
-
visible: !
|
|
553
|
+
const r = t.priceScale("right");
|
|
554
|
+
r && r.applyOptions({
|
|
555
|
+
visible: !R,
|
|
527
556
|
autoScale: !0,
|
|
528
557
|
scaleMargins: {
|
|
529
558
|
top: 0.1,
|
|
530
559
|
// No bottom margin when yScaleMin is set so the scale doesn't extend below the minimum (avoids negative labels like -10M)
|
|
531
|
-
bottom: l !== void 0 ||
|
|
532
|
-
...
|
|
560
|
+
bottom: l !== void 0 || m ? 0 : 0.1,
|
|
561
|
+
...m && {
|
|
533
562
|
top: 0.3
|
|
534
563
|
}
|
|
535
564
|
},
|
|
@@ -537,141 +566,159 @@ function Lt({
|
|
|
537
566
|
borderVisible: !0,
|
|
538
567
|
borderColor: "rgba(224, 227, 235, 0.1)",
|
|
539
568
|
entireTextOnly: !1,
|
|
540
|
-
textColor:
|
|
569
|
+
textColor: M
|
|
541
570
|
});
|
|
542
571
|
} catch {
|
|
543
572
|
}
|
|
544
|
-
if (l !== void 0 && !
|
|
573
|
+
if (l !== void 0 && !R && ($ || !S) && t.applyOptions({
|
|
545
574
|
handleScroll: {
|
|
546
575
|
vertTouchDrag: !1
|
|
547
576
|
}
|
|
548
577
|
}), G.length > 0) {
|
|
549
|
-
const
|
|
550
|
-
|
|
578
|
+
const r = G.map((e) => Number(e.time)).filter((e) => Number.isFinite(e));
|
|
579
|
+
if (r.length > 0) {
|
|
580
|
+
const e = Math.min(...r), s = Z !== void 0 ? Math.min(Z, e) : e, L = Math.max(...r);
|
|
581
|
+
if (Number(s) <= Number(L))
|
|
582
|
+
try {
|
|
583
|
+
t.timeScale().setVisibleRange({ from: s, to: L });
|
|
584
|
+
} catch {
|
|
585
|
+
try {
|
|
586
|
+
t.timeScale().fitContent();
|
|
587
|
+
} catch {
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
551
591
|
}
|
|
552
592
|
Re.current && (Re.current = !1);
|
|
553
|
-
const
|
|
554
|
-
for (const
|
|
555
|
-
|
|
556
|
-
|
|
593
|
+
const me = /* @__PURE__ */ new Map();
|
|
594
|
+
for (const r of o)
|
|
595
|
+
r.data.length > 0 && me.set(r.label, r.data[r.data.length - 1]);
|
|
596
|
+
de(me.size > 0 ? me : void 0);
|
|
557
597
|
}, [
|
|
558
|
-
|
|
598
|
+
o,
|
|
559
599
|
G,
|
|
560
|
-
|
|
600
|
+
d,
|
|
561
601
|
w,
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
602
|
+
R,
|
|
603
|
+
$,
|
|
604
|
+
_,
|
|
565
605
|
we,
|
|
566
|
-
Te,
|
|
567
606
|
Ne,
|
|
607
|
+
Te,
|
|
568
608
|
Ve,
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
]),
|
|
573
|
-
const
|
|
574
|
-
if (!
|
|
575
|
-
const a =
|
|
609
|
+
Z,
|
|
610
|
+
k,
|
|
611
|
+
A
|
|
612
|
+
]), W(() => {
|
|
613
|
+
const t = I.current;
|
|
614
|
+
if (!t || o.length === 0) return;
|
|
615
|
+
const a = o.length === 1;
|
|
576
616
|
let l;
|
|
577
|
-
for (const i of
|
|
617
|
+
for (const i of o)
|
|
578
618
|
if (i.data.length > 0) {
|
|
579
619
|
l = i.data[i.data.length - 1].time;
|
|
580
620
|
break;
|
|
581
621
|
}
|
|
582
622
|
if (!l) return;
|
|
583
623
|
const n = (i) => {
|
|
584
|
-
const { time:
|
|
585
|
-
if (!
|
|
586
|
-
const
|
|
587
|
-
for (const
|
|
588
|
-
|
|
589
|
-
if (
|
|
624
|
+
const { time: f = l, seriesData: u, point: p } = i || {}, C = Array.from(v.current.values());
|
|
625
|
+
if (!p || !f) {
|
|
626
|
+
const N = /* @__PURE__ */ new Map();
|
|
627
|
+
for (const m of o)
|
|
628
|
+
m.data.length > 0 && N.set(m.label, m.data[m.data.length - 1]);
|
|
629
|
+
if (de(N.size > 0 ? N : void 0), a || $ || fe)
|
|
590
630
|
j(null);
|
|
591
|
-
else if (
|
|
592
|
-
const
|
|
593
|
-
if (
|
|
594
|
-
const
|
|
595
|
-
|
|
631
|
+
else if (C[0] && l) {
|
|
632
|
+
const S = t.timeScale().timeToCoordinate(l), P = o[0];
|
|
633
|
+
if (P.data.length > 0) {
|
|
634
|
+
const M = P.data[P.data.length - 1].value, T = C[0].priceToCoordinate(M);
|
|
635
|
+
S !== null && T !== null && j({ x: S, y: T });
|
|
596
636
|
}
|
|
597
637
|
}
|
|
598
638
|
return;
|
|
599
639
|
}
|
|
600
|
-
const
|
|
601
|
-
let
|
|
602
|
-
for (let
|
|
603
|
-
const
|
|
604
|
-
if (!
|
|
605
|
-
const
|
|
606
|
-
let
|
|
607
|
-
if (
|
|
608
|
-
|
|
640
|
+
const H = /* @__PURE__ */ new Map();
|
|
641
|
+
let B;
|
|
642
|
+
for (let N = 0; N < o.length; N++) {
|
|
643
|
+
const m = o[N], S = v.current.get(m.label);
|
|
644
|
+
if (!S) continue;
|
|
645
|
+
const P = u?.get(S), M = P && "value" in P ? P.value : void 0;
|
|
646
|
+
let T;
|
|
647
|
+
if (M !== void 0)
|
|
648
|
+
T = M;
|
|
609
649
|
else if (a) {
|
|
610
|
-
const
|
|
611
|
-
|
|
650
|
+
const J = Number(f), Q = m.data.length > 0 ? Number(m.data[0].time) : Number.POSITIVE_INFINITY;
|
|
651
|
+
J < Q ? T = Number.NaN : T = m.data[m.data.length - 1]?.value ?? 0;
|
|
612
652
|
} else
|
|
613
|
-
|
|
614
|
-
Number.isNaN(
|
|
653
|
+
T = mt(m.data, Number(f));
|
|
654
|
+
Number.isNaN(T) || (B === void 0 && (B = T), H.set(m.label, { value: T, time: f }));
|
|
615
655
|
}
|
|
616
|
-
if (
|
|
617
|
-
const
|
|
618
|
-
if (
|
|
619
|
-
const
|
|
620
|
-
if (
|
|
621
|
-
const
|
|
656
|
+
if (de(H), B !== void 0 && C[0]) {
|
|
657
|
+
const m = t.timeScale().timeToCoordinate(f), S = C[0].priceToCoordinate(B);
|
|
658
|
+
if (m !== null && S !== null) {
|
|
659
|
+
const P = K.current;
|
|
660
|
+
if (P) {
|
|
661
|
+
const M = P.querySelector(
|
|
622
662
|
".LightweightChart"
|
|
623
663
|
);
|
|
624
|
-
if (
|
|
625
|
-
const
|
|
626
|
-
j({ x: Q, y:
|
|
664
|
+
if (M) {
|
|
665
|
+
const T = M.getBoundingClientRect(), J = P.getBoundingClientRect(), Q = m + (T.left - J.left), ee = S + (T.top - J.top);
|
|
666
|
+
j({ x: Q, y: ee });
|
|
627
667
|
} else
|
|
628
|
-
j({ x:
|
|
668
|
+
j({ x: m, y: S });
|
|
629
669
|
} else
|
|
630
|
-
j({ x:
|
|
670
|
+
j({ x: m, y: S });
|
|
631
671
|
} else
|
|
632
672
|
j(null);
|
|
633
673
|
} else
|
|
634
674
|
j(null);
|
|
635
675
|
};
|
|
636
|
-
return
|
|
637
|
-
const i = Array.from(
|
|
638
|
-
if (i[0] && l &&
|
|
639
|
-
const
|
|
640
|
-
|
|
676
|
+
return t.subscribeCrosshairMove(n), R && t.subscribeClick(n), !a && !$ && !fe && requestAnimationFrame(() => {
|
|
677
|
+
const i = Array.from(v.current.values());
|
|
678
|
+
if (i[0] && l && o[0]?.data.length > 0) {
|
|
679
|
+
const u = t.timeScale().timeToCoordinate(l), p = o[0].data[o[0].data.length - 1].value, C = i[0].priceToCoordinate(p);
|
|
680
|
+
u !== null && C !== null && j({ x: u, y: C });
|
|
641
681
|
}
|
|
642
682
|
}), () => {
|
|
643
|
-
|
|
683
|
+
t.unsubscribeCrosshairMove(n), R && t.unsubscribeClick(n);
|
|
644
684
|
};
|
|
645
|
-
}, [
|
|
646
|
-
const
|
|
647
|
-
if (!
|
|
648
|
-
const a =
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
685
|
+
}, [o, $, R, fe]), W(() => {
|
|
686
|
+
const t = I.current;
|
|
687
|
+
if (!t || o.length === 0) return;
|
|
688
|
+
const a = t.timeScale(), l = () => {
|
|
689
|
+
const n = Pe.current;
|
|
690
|
+
if (n.length === 0) return;
|
|
691
|
+
const i = a.getVisibleRange();
|
|
692
|
+
if (!i) return;
|
|
693
|
+
const f = Number(i.from), u = Number(i.to);
|
|
694
|
+
for (const p of n) {
|
|
695
|
+
const C = [];
|
|
696
|
+
for (const H of o)
|
|
697
|
+
if (p.labels.has(H.label))
|
|
698
|
+
for (const B of H.data) {
|
|
699
|
+
const N = Number(B.time);
|
|
700
|
+
N >= f && N <= u && C.push(B.value);
|
|
701
|
+
}
|
|
702
|
+
C.length > 0 && p.updateVisibleRange(C);
|
|
703
|
+
}
|
|
659
704
|
};
|
|
660
705
|
return a.subscribeVisibleLogicalRangeChange(l), () => {
|
|
661
706
|
a.unsubscribeVisibleLogicalRangeChange(
|
|
662
707
|
l
|
|
663
708
|
);
|
|
664
709
|
};
|
|
665
|
-
}, [
|
|
666
|
-
const
|
|
667
|
-
if (
|
|
668
|
-
const n =
|
|
669
|
-
for (const
|
|
670
|
-
const
|
|
710
|
+
}, [o]), W(() => {
|
|
711
|
+
const t = I.current, a = Array.from(v.current.values()), l = [];
|
|
712
|
+
if (t && a.length > 0 && x) {
|
|
713
|
+
const n = at(), i = a[0];
|
|
714
|
+
for (const f of x) {
|
|
715
|
+
const u = {
|
|
671
716
|
...n,
|
|
672
|
-
...
|
|
673
|
-
}
|
|
674
|
-
|
|
717
|
+
...f.options || {}
|
|
718
|
+
};
|
|
719
|
+
u.color && (u.color = U(u.color, u.color));
|
|
720
|
+
const p = new ut(t, i, f.xCoordinate, u);
|
|
721
|
+
i.attachPrimitive(p), l.push(p);
|
|
675
722
|
}
|
|
676
723
|
}
|
|
677
724
|
return () => {
|
|
@@ -681,145 +728,156 @@ function Lt({
|
|
|
681
728
|
n.detachPrimitive(i);
|
|
682
729
|
}
|
|
683
730
|
};
|
|
684
|
-
}, [
|
|
685
|
-
const
|
|
686
|
-
if (
|
|
687
|
-
const a = Array.from(
|
|
731
|
+
}, [x, o]), W(() => {
|
|
732
|
+
const t = [];
|
|
733
|
+
if (k && k.length > 0) {
|
|
734
|
+
const a = Array.from(v.current.values())[0], l = U(
|
|
688
735
|
"hsl(var(--destructive))",
|
|
689
736
|
"rgb(239, 68, 68)"
|
|
690
737
|
);
|
|
691
|
-
for (const n of
|
|
738
|
+
for (const n of k) {
|
|
692
739
|
if (!Number.isFinite(n.price)) continue;
|
|
693
|
-
const i = n.seriesLabel ?
|
|
740
|
+
const i = n.seriesLabel ? v.current.get(n.seriesLabel) : a;
|
|
694
741
|
if (!i) continue;
|
|
695
|
-
const
|
|
742
|
+
const f = i.createPriceLine({
|
|
696
743
|
price: n.price,
|
|
697
|
-
color: n.color ?
|
|
744
|
+
color: n.color ? U(n.color, n.color) : l,
|
|
698
745
|
lineWidth: n.lineWidth ?? 1,
|
|
699
|
-
lineStyle: n.lineStyle ??
|
|
746
|
+
lineStyle: n.lineStyle ?? Ge.Dashed,
|
|
700
747
|
axisLabelVisible: n.axisLabelVisible ?? !0,
|
|
701
748
|
title: n.title ?? ""
|
|
702
749
|
});
|
|
703
|
-
|
|
750
|
+
t.push({ series: i, line: f });
|
|
704
751
|
}
|
|
705
752
|
}
|
|
706
753
|
return () => {
|
|
707
|
-
for (const { series: a, line: l } of
|
|
754
|
+
for (const { series: a, line: l } of t)
|
|
708
755
|
try {
|
|
709
756
|
a.removePriceLine(l);
|
|
710
757
|
} catch {
|
|
711
758
|
}
|
|
712
759
|
};
|
|
713
|
-
}, [
|
|
714
|
-
const
|
|
715
|
-
if (
|
|
716
|
-
const a = Array.from(
|
|
717
|
-
for (const n of
|
|
718
|
-
const i = n.seriesLabel ?
|
|
760
|
+
}, [k, o]), W(() => {
|
|
761
|
+
const t = [];
|
|
762
|
+
if (A && A.length > 0) {
|
|
763
|
+
const a = Array.from(v.current.values())[0], l = "rgba(239, 68, 68, 0.12)";
|
|
764
|
+
for (const n of A) {
|
|
765
|
+
const i = n.seriesLabel ? v.current.get(n.seriesLabel) : a;
|
|
719
766
|
if (!i) continue;
|
|
720
|
-
const
|
|
767
|
+
const f = n.color ? U(n.color, l) : l, u = new gt(
|
|
721
768
|
i,
|
|
722
769
|
n.priceTop,
|
|
723
770
|
n.priceBottom,
|
|
724
|
-
|
|
771
|
+
f
|
|
725
772
|
);
|
|
726
|
-
i.attachPrimitive(
|
|
773
|
+
i.attachPrimitive(u), t.push({ series: i, zone: u });
|
|
727
774
|
}
|
|
728
775
|
}
|
|
729
776
|
return () => {
|
|
730
|
-
for (const { series: a, zone: l } of
|
|
777
|
+
for (const { series: a, zone: l } of t)
|
|
731
778
|
try {
|
|
732
779
|
a.detachPrimitive(l);
|
|
733
780
|
} catch {
|
|
734
781
|
}
|
|
735
782
|
};
|
|
736
|
-
}, [
|
|
737
|
-
const
|
|
738
|
-
if (!
|
|
739
|
-
|
|
783
|
+
}, [A, o]), W(() => {
|
|
784
|
+
const t = I.current;
|
|
785
|
+
if (!t || !x?.length) {
|
|
786
|
+
_e([]);
|
|
740
787
|
return;
|
|
741
788
|
}
|
|
742
789
|
const a = () => {
|
|
743
|
-
const i =
|
|
744
|
-
|
|
790
|
+
const i = t.timeScale(), f = x.map((u) => i.timeToCoordinate(u.xCoordinate) ?? null);
|
|
791
|
+
_e(f);
|
|
745
792
|
};
|
|
746
793
|
a();
|
|
747
|
-
const l =
|
|
794
|
+
const l = t.timeScale(), n = () => {
|
|
748
795
|
a();
|
|
749
796
|
};
|
|
750
797
|
return l.subscribeVisibleLogicalRangeChange(n), () => {
|
|
751
798
|
l.unsubscribeVisibleLogicalRangeChange(n);
|
|
752
799
|
};
|
|
753
|
-
}, [
|
|
754
|
-
const
|
|
755
|
-
if (
|
|
756
|
-
const
|
|
757
|
-
if (
|
|
758
|
-
return
|
|
800
|
+
}, [x, o]);
|
|
801
|
+
const ie = o.length === 1, Be = Ce.useMemo(() => {
|
|
802
|
+
if (ie && o.length > 0) {
|
|
803
|
+
const t = o[0];
|
|
804
|
+
if (t.data.length > 0)
|
|
805
|
+
return t.data[t.data.length - 1];
|
|
759
806
|
}
|
|
760
|
-
}, [
|
|
761
|
-
return /* @__PURE__ */
|
|
807
|
+
}, [ie, o]);
|
|
808
|
+
return /* @__PURE__ */ re(
|
|
762
809
|
"div",
|
|
763
810
|
{
|
|
764
|
-
ref:
|
|
765
|
-
className:
|
|
811
|
+
ref: K,
|
|
812
|
+
className: ne(
|
|
766
813
|
"relative z-[1] w-full h-full overflow-hidden p-0",
|
|
767
|
-
|
|
814
|
+
c
|
|
768
815
|
),
|
|
769
816
|
children: [
|
|
770
|
-
|
|
771
|
-
|
|
817
|
+
ue != null && ue !== !1 && ie ? /* @__PURE__ */ y("div", { className: "absolute top-2 left-2 right-2 z-[100] pointer-events-none", children: /* @__PURE__ */ y("div", { className: "text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis", children: ue }) }) : qe && ie && Be && /* @__PURE__ */ y(
|
|
818
|
+
st,
|
|
772
819
|
{
|
|
773
|
-
point:
|
|
774
|
-
xMeasureUnit:
|
|
820
|
+
point: Be,
|
|
821
|
+
xMeasureUnit: d,
|
|
775
822
|
yMeasureUnit: w,
|
|
776
|
-
decimals:
|
|
823
|
+
decimals: ce
|
|
777
824
|
}
|
|
778
825
|
),
|
|
779
|
-
|
|
780
|
-
|
|
826
|
+
Me && ke && /* @__PURE__ */ y(
|
|
827
|
+
ct,
|
|
781
828
|
{
|
|
782
|
-
points:
|
|
783
|
-
xMeasureUnit:
|
|
829
|
+
points: Me,
|
|
830
|
+
xMeasureUnit: d,
|
|
784
831
|
yMeasureUnit: w,
|
|
785
|
-
series:
|
|
786
|
-
position:
|
|
787
|
-
containerRef:
|
|
788
|
-
decimals:
|
|
832
|
+
series: o,
|
|
833
|
+
position: ke,
|
|
834
|
+
containerRef: K,
|
|
835
|
+
decimals: ce
|
|
789
836
|
}
|
|
790
837
|
),
|
|
791
|
-
|
|
792
|
-
|
|
838
|
+
g && /* @__PURE__ */ y(pt, { series: o, onUnselect: b }),
|
|
839
|
+
x && x.length > 0 && Le.length === x.length && /* @__PURE__ */ y(
|
|
793
840
|
"div",
|
|
794
841
|
{
|
|
795
842
|
className: "absolute inset-0 z-[5] pointer-events-none",
|
|
796
843
|
"aria-hidden": !0,
|
|
797
|
-
children:
|
|
798
|
-
const l =
|
|
844
|
+
children: x.map((t, a) => {
|
|
845
|
+
const l = Le[a], n = t.options ?? {}, i = n.showLabel !== !1;
|
|
799
846
|
if (l === null || !i) return null;
|
|
800
|
-
const { labelText:
|
|
847
|
+
const { labelText: f, valueStr: u } = dt(
|
|
801
848
|
n,
|
|
802
849
|
w,
|
|
803
|
-
|
|
804
|
-
);
|
|
805
|
-
if (!(
|
|
806
|
-
const
|
|
807
|
-
return /* @__PURE__ */
|
|
850
|
+
ce
|
|
851
|
+
), p = n.tooltipText ?? "";
|
|
852
|
+
if (!(f || u || p)) return null;
|
|
853
|
+
const H = n.labelBackgroundColor ?? n.color ?? "hsl(var(--background))", B = n.labelTextColor ?? "hsl(var(--foreground))", N = `${String(t.xCoordinate)}-${f}-${p}`;
|
|
854
|
+
return /* @__PURE__ */ re(
|
|
808
855
|
"div",
|
|
809
856
|
{
|
|
810
|
-
className:
|
|
857
|
+
className: ne(
|
|
858
|
+
"group absolute top-2 px-2 py-1 rounded text-xs font-medium whitespace-nowrap shadow-sm border border-border",
|
|
859
|
+
p && "pointer-events-auto cursor-default"
|
|
860
|
+
),
|
|
811
861
|
style: {
|
|
812
862
|
left: l,
|
|
813
863
|
transform: "translateX(-50%)",
|
|
814
|
-
backgroundColor:
|
|
815
|
-
color:
|
|
864
|
+
backgroundColor: H,
|
|
865
|
+
color: B
|
|
816
866
|
},
|
|
817
867
|
children: [
|
|
818
|
-
|
|
819
|
-
|
|
868
|
+
f && /* @__PURE__ */ y("span", { className: "block", children: f }),
|
|
869
|
+
u && /* @__PURE__ */ y("span", { className: ne("block", f && "mt-0.5"), children: u }),
|
|
870
|
+
p && /* @__PURE__ */ y(
|
|
871
|
+
"span",
|
|
872
|
+
{
|
|
873
|
+
className: "pointer-events-none absolute right-0 top-full z-10 mt-1 hidden w-[280px] whitespace-normal rounded border border-border bg-popover px-2.5 py-1.5 text-left leading-snug text-popover-foreground shadow-md group-hover:block",
|
|
874
|
+
role: "tooltip",
|
|
875
|
+
children: p
|
|
876
|
+
}
|
|
877
|
+
)
|
|
820
878
|
]
|
|
821
879
|
},
|
|
822
|
-
|
|
880
|
+
N
|
|
823
881
|
);
|
|
824
882
|
})
|
|
825
883
|
}
|
|
@@ -827,7 +885,7 @@ function Lt({
|
|
|
827
885
|
/* @__PURE__ */ y(
|
|
828
886
|
"div",
|
|
829
887
|
{
|
|
830
|
-
ref:
|
|
888
|
+
ref: ge,
|
|
831
889
|
className: "LightweightChart w-full h-full overflow-hidden"
|
|
832
890
|
}
|
|
833
891
|
)
|
|
@@ -835,49 +893,49 @@ function Lt({
|
|
|
835
893
|
}
|
|
836
894
|
);
|
|
837
895
|
}
|
|
838
|
-
function
|
|
839
|
-
series:
|
|
840
|
-
onUnselect:
|
|
841
|
-
inline:
|
|
896
|
+
function pt({
|
|
897
|
+
series: o,
|
|
898
|
+
onUnselect: c,
|
|
899
|
+
inline: g = !1
|
|
842
900
|
}) {
|
|
843
901
|
return /* @__PURE__ */ y(
|
|
844
902
|
"div",
|
|
845
903
|
{
|
|
846
|
-
className:
|
|
904
|
+
className: ne(
|
|
847
905
|
"flex flex-wrap gap-2",
|
|
848
|
-
|
|
906
|
+
g ? "items-center" : "absolute top-0 left-2 z-[10]"
|
|
849
907
|
),
|
|
850
|
-
children:
|
|
851
|
-
const w =
|
|
852
|
-
return /* @__PURE__ */
|
|
908
|
+
children: o.map((b, d) => {
|
|
909
|
+
const w = Xe(d), q = (b.lineColor ?? b.color) || w.line, x = b.data.length === 0;
|
|
910
|
+
return /* @__PURE__ */ re(
|
|
853
911
|
"div",
|
|
854
912
|
{
|
|
855
|
-
className:
|
|
913
|
+
className: ne(
|
|
856
914
|
"flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",
|
|
857
|
-
|
|
915
|
+
x && "opacity-50"
|
|
858
916
|
),
|
|
859
917
|
children: [
|
|
860
918
|
/* @__PURE__ */ y(
|
|
861
919
|
"div",
|
|
862
920
|
{
|
|
863
921
|
className: "w-3 h-3 rounded-sm",
|
|
864
|
-
style: { backgroundColor:
|
|
922
|
+
style: { backgroundColor: q }
|
|
865
923
|
}
|
|
866
924
|
),
|
|
867
|
-
/* @__PURE__ */
|
|
868
|
-
|
|
869
|
-
|
|
925
|
+
/* @__PURE__ */ re("span", { className: "text-[10px] sm:text-xs font-medium text-foreground", children: [
|
|
926
|
+
b.label,
|
|
927
|
+
x && " (no data)"
|
|
870
928
|
] }),
|
|
871
|
-
|
|
929
|
+
c && /* @__PURE__ */ y(
|
|
872
930
|
"button",
|
|
873
931
|
{
|
|
874
932
|
type: "button",
|
|
875
|
-
onClick: (
|
|
876
|
-
|
|
933
|
+
onClick: (k) => {
|
|
934
|
+
k.stopPropagation(), c(b.label);
|
|
877
935
|
},
|
|
878
936
|
className: "ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer",
|
|
879
|
-
"aria-label": `Remove ${
|
|
880
|
-
children: /* @__PURE__ */
|
|
937
|
+
"aria-label": `Remove ${b.label}`,
|
|
938
|
+
children: /* @__PURE__ */ re(
|
|
881
939
|
"svg",
|
|
882
940
|
{
|
|
883
941
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -902,7 +960,7 @@ function bt({
|
|
|
902
960
|
)
|
|
903
961
|
]
|
|
904
962
|
},
|
|
905
|
-
|
|
963
|
+
b.label
|
|
906
964
|
);
|
|
907
965
|
})
|
|
908
966
|
}
|
|
@@ -911,8 +969,8 @@ function bt({
|
|
|
911
969
|
export {
|
|
912
970
|
ye as DEFAULT_SERIES_COLORS,
|
|
913
971
|
Lt as Graph,
|
|
914
|
-
|
|
915
|
-
|
|
972
|
+
pt as GraphLegend,
|
|
973
|
+
Xe as getSeriesColorPalette,
|
|
916
974
|
mt as getStepForwardValue,
|
|
917
|
-
|
|
975
|
+
dt as getVerticalLineTooltipContent
|
|
918
976
|
};
|