p1-charts 0.1.0 → 0.2.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/README.md +15 -1
- package/dist/CategoryBarChart-YEJ9VB8h.js +453 -0
- package/dist/CategoryBarChart-YEJ9VB8h.js.map +1 -0
- package/dist/{PolarChart-D_ULWctY.js → PolarChart-BUEhn3CI.js} +135 -83
- package/dist/PolarChart-BUEhn3CI.js.map +1 -0
- package/dist/{TimeSeriesChart-tYmzRNzV.js → TimeSeriesChart-BIwJxgnD.js} +483 -418
- package/dist/TimeSeriesChart-BIwJxgnD.js.map +1 -0
- package/dist/category.d.ts +2 -2
- package/dist/category.d.ts.map +1 -1
- package/dist/category.js +1 -1
- package/dist/charts/CategoryBarChart/index.d.ts +1 -1
- package/dist/charts/CategoryBarChart/index.d.ts.map +1 -1
- package/dist/charts/PolarChart/index.d.ts.map +1 -1
- package/dist/charts/ScatterChart/index.d.ts +1 -1
- package/dist/charts/ScatterChart/index.d.ts.map +1 -1
- package/dist/charts/TimeSeriesChart/index.d.ts +1 -1
- package/dist/charts/TimeSeriesChart/index.d.ts.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/scatter.js +1 -1
- package/dist/series.d.ts +1 -1
- package/dist/series.d.ts.map +1 -1
- package/dist/series.js +1 -1
- package/dist/types/category.d.ts +41 -2
- package/dist/types/category.d.ts.map +1 -1
- package/dist/types/polar.d.ts +7 -1
- package/dist/types/polar.d.ts.map +1 -1
- package/dist/types/scatter.d.ts +13 -0
- package/dist/types/scatter.d.ts.map +1 -1
- package/dist/types/timeSeries.d.ts +31 -0
- package/dist/types/timeSeries.d.ts.map +1 -1
- package/dist/utils/category.utils.d.ts +46 -7
- package/dist/utils/category.utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/category.ts +13 -2
- package/src/charts/CategoryBarChart/index.tsx +301 -50
- package/src/charts/PolarChart/index.tsx +63 -18
- package/src/charts/ScatterChart/index.tsx +51 -7
- package/src/charts/TimeSeriesChart/index.tsx +117 -2
- package/src/index.ts +13 -1
- package/src/series.ts +4 -0
- package/src/types/category.ts +47 -2
- package/src/types/polar.ts +11 -1
- package/src/types/scatter.ts +13 -0
- package/src/types/timeSeries.ts +35 -0
- package/src/utils/category.utils.ts +321 -43
- package/dist/CategoryBarChart-CV58kvIr.js +0 -182
- package/dist/CategoryBarChart-CV58kvIr.js.map +0 -1
- package/dist/PolarChart-D_ULWctY.js.map +0 -1
- package/dist/TimeSeriesChart-tYmzRNzV.js.map +0 -1
|
@@ -4,28 +4,28 @@ import { r as d, t as f } from "./tooltip.utils-D7xaBSUK.js";
|
|
|
4
4
|
import { t as p } from "./useChartTheme-B06p_jvu.js";
|
|
5
5
|
import { t as m } from "./motion.utils-C1eaZJdQ.js";
|
|
6
6
|
import { AreaSeries as h, BaselineSeries as g, CandlestickSeries as _, ColorType as v, CrosshairMode as y, HistogramSeries as b, LineSeries as x, LineStyle as S, createChart as C, createSeriesMarkers as w } from "lightweight-charts";
|
|
7
|
-
import { forwardRef as T, useCallback as E, useEffect as D, useImperativeHandle as
|
|
8
|
-
import { Fragment as
|
|
7
|
+
import { forwardRef as T, useCallback as E, useEffect as D, useImperativeHandle as ee, useMemo as O, useRef as k, useState as A } from "react";
|
|
8
|
+
import { Fragment as j, jsx as M, jsxs as N } from "react/jsx-runtime";
|
|
9
9
|
//#region src/utils/timeScale.utils.ts
|
|
10
|
-
function
|
|
10
|
+
function P(e, t) {
|
|
11
11
|
let n = e.logicalToCoordinate(t), r = n === null ? null : e.coordinateToTime(n);
|
|
12
12
|
return r === null ? null : Number(r);
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function F(e, t) {
|
|
15
15
|
let n = e.timeToCoordinate(t);
|
|
16
16
|
if (n !== null) return n;
|
|
17
17
|
let r = e.timeToIndex(t, !0);
|
|
18
18
|
if (r === null) return null;
|
|
19
|
-
let i = Math.max(0, r - 1), a =
|
|
19
|
+
let i = Math.max(0, r - 1), a = P(e, i), o = P(e, i + 1), s = e.logicalToCoordinate(i), c = e.logicalToCoordinate(i + 1);
|
|
20
20
|
return a === null || o === null || s === null || c === null || !(o > a) ? null : s + (t - a) / (o - a) * (c - s);
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function I(e, t, n) {
|
|
23
23
|
let r = (t) => {
|
|
24
24
|
let n = e.timeToIndex(t, !0);
|
|
25
25
|
return n === null ? null : Number(n);
|
|
26
26
|
}, i = r(t), a = r(n);
|
|
27
27
|
if (i === null || a === null) return null;
|
|
28
|
-
let o =
|
|
28
|
+
let o = P(e, i), s = P(e, a);
|
|
29
29
|
if (o === null || s === null || o < t) return null;
|
|
30
30
|
let c = s < n ? a : a - 1, l = e.logicalToCoordinate(i), u = e.logicalToCoordinate(c);
|
|
31
31
|
if (c < i || l === null || u === null) return null;
|
|
@@ -34,30 +34,30 @@ function L(e, t, n) {
|
|
|
34
34
|
}
|
|
35
35
|
//#endregion
|
|
36
36
|
//#region src/styles/seriesChart.ts
|
|
37
|
-
var
|
|
37
|
+
var te = { position: "relative" }, ne = {
|
|
38
38
|
position: "absolute",
|
|
39
39
|
inset: 0,
|
|
40
40
|
zIndex: 0
|
|
41
|
-
},
|
|
41
|
+
}, re = {
|
|
42
42
|
position: "absolute",
|
|
43
43
|
top: 0,
|
|
44
44
|
left: 0,
|
|
45
45
|
display: "none",
|
|
46
46
|
opacity: .15,
|
|
47
47
|
pointerEvents: "none"
|
|
48
|
-
},
|
|
48
|
+
}, L = {
|
|
49
49
|
position: "absolute",
|
|
50
50
|
top: 0,
|
|
51
51
|
right: 0,
|
|
52
52
|
opacity: 0,
|
|
53
53
|
pointerEvents: "none"
|
|
54
|
-
},
|
|
54
|
+
}, R = {
|
|
55
55
|
position: "absolute",
|
|
56
56
|
bottom: 40,
|
|
57
57
|
left: "50%",
|
|
58
58
|
transform: "translateX(-50%)"
|
|
59
|
-
},
|
|
60
|
-
...
|
|
59
|
+
}, z = {
|
|
60
|
+
...R,
|
|
61
61
|
minHeight: 28,
|
|
62
62
|
padding: "4px 12px",
|
|
63
63
|
borderRadius: 999,
|
|
@@ -68,7 +68,7 @@ var ee = { position: "relative" }, te = {
|
|
|
68
68
|
fontSize: 12,
|
|
69
69
|
cursor: "pointer",
|
|
70
70
|
touchAction: "manipulation"
|
|
71
|
-
},
|
|
71
|
+
}, B = {
|
|
72
72
|
position: "absolute",
|
|
73
73
|
top: 8,
|
|
74
74
|
right: 8,
|
|
@@ -80,16 +80,16 @@ var ee = { position: "relative" }, te = {
|
|
|
80
80
|
padding: 0,
|
|
81
81
|
listStyle: "none",
|
|
82
82
|
pointerEvents: "none"
|
|
83
|
-
},
|
|
83
|
+
}, V = {
|
|
84
84
|
display: "flex",
|
|
85
85
|
alignItems: "center",
|
|
86
86
|
gap: 6
|
|
87
|
-
},
|
|
87
|
+
}, H = {
|
|
88
88
|
flex: "none",
|
|
89
89
|
width: 10,
|
|
90
90
|
height: 10,
|
|
91
91
|
boxSizing: "border-box"
|
|
92
|
-
},
|
|
92
|
+
}, ie = {
|
|
93
93
|
position: "absolute",
|
|
94
94
|
top: 0,
|
|
95
95
|
left: 0,
|
|
@@ -98,7 +98,7 @@ var ee = { position: "relative" }, te = {
|
|
|
98
98
|
};
|
|
99
99
|
//#endregion
|
|
100
100
|
//#region src/hooks/useChart.ts
|
|
101
|
-
function
|
|
101
|
+
function U(e = {}) {
|
|
102
102
|
if (!e.layout) return e;
|
|
103
103
|
let { colorSpace: t, colorParsers: n, ...r } = e.layout;
|
|
104
104
|
return {
|
|
@@ -106,18 +106,18 @@ function oe(e = {}) {
|
|
|
106
106
|
layout: r
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function ae(e, t, n, i) {
|
|
110
110
|
let a = e.current.owner === t ? e.current.options : {}, o = r(n, a, i);
|
|
111
111
|
return o && (e.current = {
|
|
112
112
|
owner: t,
|
|
113
113
|
options: i
|
|
114
114
|
}), o;
|
|
115
115
|
}
|
|
116
|
-
function
|
|
117
|
-
let [i, a] =
|
|
116
|
+
function oe(e, t, n, r) {
|
|
117
|
+
let [i, a] = A(null), [o, c] = A(0), l = k(n), u = k({
|
|
118
118
|
owner: null,
|
|
119
119
|
options: {}
|
|
120
|
-
}), d =
|
|
120
|
+
}), d = k({
|
|
121
121
|
owner: null,
|
|
122
122
|
options: {}
|
|
123
123
|
});
|
|
@@ -131,7 +131,7 @@ function ce(e, t, n, r) {
|
|
|
131
131
|
return a({
|
|
132
132
|
chart: i,
|
|
133
133
|
series: o,
|
|
134
|
-
chartDefaults:
|
|
134
|
+
chartDefaults: U(s(i.options())),
|
|
135
135
|
seriesDefaults: s(o.options())
|
|
136
136
|
}), () => {
|
|
137
137
|
a(null), i.remove();
|
|
@@ -142,31 +142,31 @@ function ce(e, t, n, r) {
|
|
|
142
142
|
o
|
|
143
143
|
]), D(() => {
|
|
144
144
|
if (!i) return;
|
|
145
|
-
let e =
|
|
145
|
+
let e = U(n), t = ae(u, i, i.chartDefaults, e);
|
|
146
146
|
t ? i.chart.applyOptions(t) : c((e) => e + 1);
|
|
147
147
|
}, [i, n]), D(() => {
|
|
148
148
|
if (!i) return;
|
|
149
|
-
let e = r ?? {}, t =
|
|
149
|
+
let e = r ?? {}, t = ae(d, i, i.seriesDefaults, e);
|
|
150
150
|
t ? i.series.applyOptions(t) : c((e) => e + 1);
|
|
151
151
|
}, [i, r]), i;
|
|
152
152
|
}
|
|
153
153
|
//#endregion
|
|
154
154
|
//#region src/utils/time.utils.ts
|
|
155
|
-
var
|
|
156
|
-
function
|
|
155
|
+
var se = 1e11;
|
|
156
|
+
function W(e) {
|
|
157
157
|
let t, n;
|
|
158
158
|
if (e instanceof Date) t = e.getTime(), n = !0;
|
|
159
159
|
else if (typeof e == "string") {
|
|
160
160
|
if (t = Date.parse(e), n = !0, !Number.isFinite(t)) {
|
|
161
161
|
let r = e.trim();
|
|
162
|
-
t = r === "" ? NaN : Number(r), n = Math.abs(t) >
|
|
162
|
+
t = r === "" ? NaN : Number(r), n = Math.abs(t) > se;
|
|
163
163
|
}
|
|
164
|
-
} else t = e, n = Math.abs(t) >
|
|
164
|
+
} else t = e, n = Math.abs(t) > se;
|
|
165
165
|
return Number.isFinite(t) ? Math.floor(n ? t / 1e3 : t) : null;
|
|
166
166
|
}
|
|
167
167
|
//#endregion
|
|
168
168
|
//#region src/utils/data.utils.ts
|
|
169
|
-
function
|
|
169
|
+
function ce(e, t) {
|
|
170
170
|
let n = /* @__PURE__ */ new Map();
|
|
171
171
|
for (let r of e) {
|
|
172
172
|
let e = t.time(r);
|
|
@@ -183,7 +183,7 @@ function ue(e, t) {
|
|
|
183
183
|
indexByTime: s
|
|
184
184
|
};
|
|
185
185
|
}
|
|
186
|
-
function
|
|
186
|
+
function le(e) {
|
|
187
187
|
return [
|
|
188
188
|
e.open,
|
|
189
189
|
e.high,
|
|
@@ -191,10 +191,10 @@ function de(e) {
|
|
|
191
191
|
e.close
|
|
192
192
|
].every(Number.isFinite);
|
|
193
193
|
}
|
|
194
|
-
function
|
|
195
|
-
return
|
|
196
|
-
time: (e) =>
|
|
197
|
-
valid:
|
|
194
|
+
function ue(e) {
|
|
195
|
+
return ce(e, {
|
|
196
|
+
time: (e) => W(e.time),
|
|
197
|
+
valid: le,
|
|
198
198
|
row: (e) => e,
|
|
199
199
|
data: (e, t) => {
|
|
200
200
|
let { open: n, high: r, low: i, close: a, color: o, borderColor: s, wickColor: c } = e;
|
|
@@ -211,9 +211,9 @@ function fe(e) {
|
|
|
211
211
|
}
|
|
212
212
|
});
|
|
213
213
|
}
|
|
214
|
-
function
|
|
215
|
-
return
|
|
216
|
-
time: (e) =>
|
|
214
|
+
function G(e) {
|
|
215
|
+
return ce(e, {
|
|
216
|
+
time: (e) => W(e.time),
|
|
217
217
|
valid: (e) => Number.isFinite(e.value),
|
|
218
218
|
row: (e) => ({
|
|
219
219
|
time: e.time,
|
|
@@ -229,23 +229,23 @@ function U(e) {
|
|
|
229
229
|
})
|
|
230
230
|
});
|
|
231
231
|
}
|
|
232
|
-
function
|
|
233
|
-
return typeof e == "number" || typeof e == "string" || e instanceof Date ?
|
|
232
|
+
function de(e) {
|
|
233
|
+
return typeof e == "number" || typeof e == "string" || e instanceof Date ? W(e) : null;
|
|
234
234
|
}
|
|
235
|
-
function
|
|
235
|
+
function K(e, t) {
|
|
236
236
|
let n = 0, r = e.length - 1, i = null;
|
|
237
237
|
for (; n <= r;) {
|
|
238
|
-
let a = n + r >> 1, o =
|
|
238
|
+
let a = n + r >> 1, o = de(e[a].time);
|
|
239
239
|
o !== null && o <= t ? (i = a, n = a + 1) : r = a - 1;
|
|
240
240
|
}
|
|
241
241
|
return i;
|
|
242
242
|
}
|
|
243
243
|
//#endregion
|
|
244
244
|
//#region src/utils/bands.utils.ts
|
|
245
|
-
var
|
|
246
|
-
function
|
|
245
|
+
var fe = "rgba(128,128,128,0.15)";
|
|
246
|
+
function q(e) {
|
|
247
247
|
return e.flatMap((e) => {
|
|
248
|
-
let t =
|
|
248
|
+
let t = W(e.from), n = W(e.to);
|
|
249
249
|
return t === null || n === null || n < t ? [] : [{
|
|
250
250
|
...e,
|
|
251
251
|
start: t,
|
|
@@ -253,23 +253,23 @@ function G(e) {
|
|
|
253
253
|
}];
|
|
254
254
|
}).sort((e, t) => e.start - t.start);
|
|
255
255
|
}
|
|
256
|
-
function
|
|
256
|
+
function pe(e) {
|
|
257
257
|
return [...new Set(e.map((e) => e.key))];
|
|
258
258
|
}
|
|
259
|
-
function
|
|
259
|
+
function me(e, t, r = {}) {
|
|
260
260
|
let i = t?.palette.categorical ?? [];
|
|
261
261
|
return Object.fromEntries(e.map((e, a) => {
|
|
262
|
-
let o = i[a % i.length], c = t && (n(o, t.bands.opacity) ?? o) ||
|
|
262
|
+
let o = i[a % i.length], c = t && (n(o, t.bands.opacity) ?? o) || fe, l = r[e];
|
|
263
263
|
return [e, s({
|
|
264
264
|
fill: c,
|
|
265
265
|
label: e
|
|
266
266
|
}, t?.bands.styles?.[e], typeof l == "string" ? { fill: l } : l)];
|
|
267
267
|
}));
|
|
268
268
|
}
|
|
269
|
-
function
|
|
270
|
-
let i =
|
|
269
|
+
function he(e, t, n, r = {}) {
|
|
270
|
+
let i = q(e).filter(({ start: e, end: n }) => e <= t && t < n).pop();
|
|
271
271
|
if (!i) return null;
|
|
272
|
-
let a =
|
|
272
|
+
let a = K(n, t), o = K(n, i.start - 1), s = a === null ? 0 : a - (o ?? -1);
|
|
273
273
|
return {
|
|
274
274
|
key: i.key,
|
|
275
275
|
label: r[i.key]?.label ?? i.key,
|
|
@@ -280,11 +280,11 @@ function _e(e, t, n, r = {}) {
|
|
|
280
280
|
}
|
|
281
281
|
//#endregion
|
|
282
282
|
//#region src/primitives/TimeRangePrimitive.ts
|
|
283
|
-
var
|
|
284
|
-
function
|
|
283
|
+
var J = 8;
|
|
284
|
+
function Y(e, t) {
|
|
285
285
|
return e === "dashed" ? [4 * t, 3 * t] : e === "dotted" ? [t, 2 * t] : [];
|
|
286
286
|
}
|
|
287
|
-
function
|
|
287
|
+
function ge(e, t, n) {
|
|
288
288
|
let { style: r } = n, { x: i, y: a, width: o, height: s } = t, c = n.color ?? r.fill, { stroke: l, hatch: u, text: d } = r;
|
|
289
289
|
if (e.save(), e.beginPath(), e.rect(i, a, o, s), e.clip(), c && (e.fillStyle = c, e.fillRect(i, a, o, s)), u && u.color) {
|
|
290
290
|
let t = Math.max(1, u.spacing ?? 6);
|
|
@@ -294,11 +294,11 @@ function ve(e, t, n) {
|
|
|
294
294
|
}
|
|
295
295
|
if (l?.color) {
|
|
296
296
|
let t = l.width ?? 1;
|
|
297
|
-
e.strokeStyle = l.color, e.lineWidth = t, e.setLineDash(
|
|
297
|
+
e.strokeStyle = l.color, e.lineWidth = t, e.setLineDash(Y(l.style, t)), e.strokeRect(i + t / 2, a + t / 2, o - t, s - t), e.setLineDash([]);
|
|
298
298
|
}
|
|
299
|
-
n.label && d?.color && (e.fillStyle = d.color, e.font = `${d.weight ?? 400} ${d.size ?? 12}px ${d.family ?? "sans-serif"}`, e.textBaseline = "middle", e.fillText(n.label, i + (r.inset ??
|
|
299
|
+
n.label && d?.color && (e.fillStyle = d.color, e.font = `${d.weight ?? 400} ${d.size ?? 12}px ${d.family ?? "sans-serif"}`, e.textBaseline = "middle", e.fillText(n.label, i + (r.inset ?? J), a + s / 2)), e.restore();
|
|
300
300
|
}
|
|
301
|
-
var
|
|
301
|
+
var X = class {
|
|
302
302
|
zOrder = "normal";
|
|
303
303
|
edges = "time";
|
|
304
304
|
items = [];
|
|
@@ -313,7 +313,7 @@ var ye = class {
|
|
|
313
313
|
}
|
|
314
314
|
applyOptions(e) {
|
|
315
315
|
this.zOrder = e.zOrder ?? "normal", this.edges = e.edges ?? "time", this.items = e.items.flatMap((t) => {
|
|
316
|
-
let n =
|
|
316
|
+
let n = W(t.from), r = W(t.to);
|
|
317
317
|
return n === null || r === null ? [] : [{
|
|
318
318
|
...t,
|
|
319
319
|
from: Math.min(n, r),
|
|
@@ -337,12 +337,12 @@ var ye = class {
|
|
|
337
337
|
let n = t.timeScale();
|
|
338
338
|
e.useMediaCoordinateSpace(({ context: e, mediaSize: t }) => {
|
|
339
339
|
for (let r of this.items) {
|
|
340
|
-
let [i = null, a = null] = this.edges === "between-bars" ?
|
|
340
|
+
let [i = null, a = null] = this.edges === "between-bars" ? I(n, r.from, r.to) ?? [] : [F(n, r.from), F(n, r.to)];
|
|
341
341
|
if (i === null || a === null) continue;
|
|
342
342
|
let o = Math.max(0, i), s = Math.min(t.width, a);
|
|
343
343
|
if (s <= o) continue;
|
|
344
344
|
let c = Math.min(t.height, r.style.height ?? Infinity);
|
|
345
|
-
|
|
345
|
+
ge(e, {
|
|
346
346
|
x: o,
|
|
347
347
|
y: (t.height - c) / 2,
|
|
348
348
|
width: s - o,
|
|
@@ -354,12 +354,12 @@ var ye = class {
|
|
|
354
354
|
};
|
|
355
355
|
//#endregion
|
|
356
356
|
//#region src/hooks/useBands.ts
|
|
357
|
-
function
|
|
358
|
-
let a =
|
|
357
|
+
function _e(e, t, n, r, i) {
|
|
358
|
+
let a = O(() => n ? q(n) : null, [n]), o = O(() => a ? me(pe(a), i, r) : {}, [
|
|
359
359
|
a,
|
|
360
360
|
i,
|
|
361
361
|
r
|
|
362
|
-
]), s =
|
|
362
|
+
]), s = O(() => a && {
|
|
363
363
|
items: a.map(({ from: e, to: t, key: n }) => ({
|
|
364
364
|
from: e,
|
|
365
365
|
to: t,
|
|
@@ -368,25 +368,25 @@ function be(e, t, n, r, i) {
|
|
|
368
368
|
style: (e) => o[e] ?? {},
|
|
369
369
|
zOrder: "bottom",
|
|
370
370
|
edges: "between-bars"
|
|
371
|
-
}, [a, o]), c =
|
|
371
|
+
}, [a, o]), c = k(null), l = k(null), u = k(s), d = s !== null;
|
|
372
372
|
u.current = s, D(() => {
|
|
373
373
|
let t = e?.chart.panes()[0];
|
|
374
374
|
if (!t || !u.current) return;
|
|
375
|
-
let n = new
|
|
375
|
+
let n = new X(u.current);
|
|
376
376
|
return t.attachPrimitive(n), c.current = n, l.current = u.current, () => {
|
|
377
377
|
t.detachPrimitive(n), c.current = null;
|
|
378
378
|
};
|
|
379
379
|
}, [e, d]), D(() => {
|
|
380
380
|
s && c.current && l.current !== s && (c.current.applyOptions(s), l.current = s);
|
|
381
381
|
}, [s]);
|
|
382
|
-
let f =
|
|
382
|
+
let f = O(() => Object.entries(o).map(([e, t]) => ({
|
|
383
383
|
key: e,
|
|
384
384
|
label: t.label ?? e,
|
|
385
385
|
fill: t.fill ?? "",
|
|
386
386
|
legendColor: t.legendColor
|
|
387
387
|
})), [o]), p = E((e) => {
|
|
388
388
|
let n = t.data[e]?.time;
|
|
389
|
-
return a && typeof n == "number" ?
|
|
389
|
+
return a && typeof n == "number" ? he(a, n, t.data, o) : null;
|
|
390
390
|
}, [
|
|
391
391
|
a,
|
|
392
392
|
t,
|
|
@@ -399,8 +399,8 @@ function be(e, t, n, r, i) {
|
|
|
399
399
|
}
|
|
400
400
|
//#endregion
|
|
401
401
|
//#region src/hooks/useOverlays.ts
|
|
402
|
-
function
|
|
403
|
-
let n =
|
|
402
|
+
function ve(e, t = []) {
|
|
403
|
+
let n = k([]);
|
|
404
404
|
return D(() => {
|
|
405
405
|
n.current = [];
|
|
406
406
|
}, [e]), D(() => {
|
|
@@ -419,21 +419,21 @@ function xe(e, t = []) {
|
|
|
419
419
|
let e = r(s.defaults, s.options, n);
|
|
420
420
|
e ? (s.series.applyOptions(e), s.options = n) : (i.removeSeries(s.series), s = void 0);
|
|
421
421
|
}
|
|
422
|
-
s || (a[t] = s = o(n)), s.series.setData(
|
|
422
|
+
s || (a[t] = s = o(n)), s.series.setData(G(e.data).data);
|
|
423
423
|
}), a.splice(t.length).forEach((e) => i.removeSeries(e.series));
|
|
424
424
|
}, [e, t]), n;
|
|
425
425
|
}
|
|
426
426
|
//#endregion
|
|
427
427
|
//#region src/utils/live.utils.ts
|
|
428
|
-
var
|
|
429
|
-
function
|
|
428
|
+
var ye = 2, be = .002, xe = .5;
|
|
429
|
+
function Se(e, t) {
|
|
430
430
|
if (!e) return null;
|
|
431
431
|
let n = e.rows[e.rows.length - 1], r = t.rows[t.rows.length - 1];
|
|
432
432
|
if (!n || !r) return null;
|
|
433
|
-
let i =
|
|
433
|
+
let i = W(n.time), a = W(r.time), o = t.rows[t.rows.length - 2], s = t.rows.length === e.rows.length && a === i, c = t.rows.length === e.rows.length + 1 && o !== void 0 && W(o.time) === i;
|
|
434
434
|
return !s && !c || r.close === n.close ? null : r.close > n.close ? "up" : "down";
|
|
435
435
|
}
|
|
436
|
-
function
|
|
436
|
+
function Ce(e) {
|
|
437
437
|
if (typeof e != "object" || !e) return null;
|
|
438
438
|
let t = e, n = t.upColor, r = t.downColor;
|
|
439
439
|
if (typeof n == "string" && typeof r == "string") return {
|
|
@@ -451,30 +451,30 @@ function Ee(e) {
|
|
|
451
451
|
down: o
|
|
452
452
|
} : null;
|
|
453
453
|
}
|
|
454
|
-
function
|
|
455
|
-
let r = Math.exp(n *
|
|
454
|
+
function we(e, t, n) {
|
|
455
|
+
let r = Math.exp(n * be);
|
|
456
456
|
if (!Number.isFinite(r)) return null;
|
|
457
457
|
let i = {
|
|
458
458
|
from: t - (t - e.from) * r,
|
|
459
459
|
to: t + (e.to - t) * r
|
|
460
460
|
};
|
|
461
|
-
return i.to - i.from <
|
|
461
|
+
return i.to - i.from < ye ? null : i;
|
|
462
462
|
}
|
|
463
|
-
function
|
|
463
|
+
function Te(e) {
|
|
464
464
|
let t = Math.abs(e.deltaX) > Math.abs(e.deltaY) ? e.deltaX : e.deltaY, n = e.deltaMode === 1 ? t * 16 : t;
|
|
465
465
|
return Number.isFinite(n) ? n : 0;
|
|
466
466
|
}
|
|
467
|
-
function
|
|
467
|
+
function Ee(e, t) {
|
|
468
468
|
return e === null || t < 0 || e.to >= t - .5;
|
|
469
469
|
}
|
|
470
470
|
//#endregion
|
|
471
471
|
//#region src/hooks/useWheelZoom.ts
|
|
472
|
-
function
|
|
472
|
+
function De(e, t, n) {
|
|
473
473
|
D(() => {
|
|
474
474
|
let r = t.current;
|
|
475
475
|
if (!e || !r || !n) return;
|
|
476
476
|
let { chart: i } = e, a = i.timeScale(), o = (e) => {
|
|
477
|
-
let t =
|
|
477
|
+
let t = Te(e);
|
|
478
478
|
if (t === 0) return;
|
|
479
479
|
if (e.preventDefault(), !e.ctrlKey) {
|
|
480
480
|
let e = a.options().barSpacing;
|
|
@@ -483,7 +483,7 @@ function Ae(e, t, n) {
|
|
|
483
483
|
}
|
|
484
484
|
let n = r.getBoundingClientRect(), o = e.clientX - n.left - i.priceScale("left").width(), s = a.coordinateToLogical(o), c = a.getVisibleLogicalRange();
|
|
485
485
|
if (s === null || c === null) return;
|
|
486
|
-
let l =
|
|
486
|
+
let l = we(c, s, t);
|
|
487
487
|
l && a.setVisibleLogicalRange(l);
|
|
488
488
|
};
|
|
489
489
|
return r.addEventListener("wheel", o, { passive: !1 }), () => r.removeEventListener("wheel", o);
|
|
@@ -495,7 +495,7 @@ function Ae(e, t, n) {
|
|
|
495
495
|
}
|
|
496
496
|
//#endregion
|
|
497
497
|
//#region src/utils/bucket.utils.ts
|
|
498
|
-
function
|
|
498
|
+
function Oe(e, t, n, r) {
|
|
499
499
|
if (!(t > 0) || !Number.isFinite(t)) return e;
|
|
500
500
|
let i = e;
|
|
501
501
|
if (!Number.isFinite(i) || i <= 0) return e;
|
|
@@ -503,7 +503,7 @@ function je(e, t, n, r) {
|
|
|
503
503
|
for (; i > 1 && i / 2 * t >= n * 1.5;) i /= 2;
|
|
504
504
|
return i;
|
|
505
505
|
}
|
|
506
|
-
function
|
|
506
|
+
function ke(e, t) {
|
|
507
507
|
if (!Number.isInteger(t) || t <= 0) throw Error("bucketSize must be a positive integer");
|
|
508
508
|
let n = [];
|
|
509
509
|
for (let r = 0; r < e.length; r += t) n.push(e.slice(r, r + t));
|
|
@@ -511,12 +511,12 @@ function Me(e, t) {
|
|
|
511
511
|
}
|
|
512
512
|
//#endregion
|
|
513
513
|
//#region src/hooks/useAutoBucket.ts
|
|
514
|
-
var
|
|
515
|
-
function
|
|
516
|
-
return e ? e === !0 ?
|
|
514
|
+
var Ae = 150, je = 6;
|
|
515
|
+
function Me(e) {
|
|
516
|
+
return e ? e === !0 ? je : e.minBarWidth ?? je : null;
|
|
517
517
|
}
|
|
518
|
-
function
|
|
519
|
-
let [r, i] =
|
|
518
|
+
function Ne(e, t, n) {
|
|
519
|
+
let [r, i] = A(1), a = Me(n), o = k(r), s = k(t.points.length);
|
|
520
520
|
return o.current = r, s.current = t.points.length, D(() => {
|
|
521
521
|
if (!e || a === null) {
|
|
522
522
|
i(1);
|
|
@@ -526,11 +526,11 @@ function Ie(e, t, n) {
|
|
|
526
526
|
let e = t.getVisibleLogicalRange(), n = e ? e.to - e.from : 0;
|
|
527
527
|
if (n <= 0) return;
|
|
528
528
|
let r = t.width() / (n * o.current);
|
|
529
|
-
i(
|
|
529
|
+
i(Oe(o.current, r, a, s.current));
|
|
530
530
|
}, l = () => {
|
|
531
531
|
clearTimeout(n), cancelAnimationFrame(r), n = setTimeout(() => {
|
|
532
532
|
r = requestAnimationFrame(c);
|
|
533
|
-
},
|
|
533
|
+
}, Ae);
|
|
534
534
|
};
|
|
535
535
|
return t.subscribeVisibleLogicalRangeChange(l), l(), () => {
|
|
536
536
|
t.unsubscribeVisibleLogicalRangeChange(l), clearTimeout(n), cancelAnimationFrame(r);
|
|
@@ -539,13 +539,13 @@ function Ie(e, t, n) {
|
|
|
539
539
|
}
|
|
540
540
|
//#endregion
|
|
541
541
|
//#region src/hooks/useSeriesData.ts
|
|
542
|
-
function
|
|
543
|
-
let a =
|
|
542
|
+
function Pe(e, t, n, r, i) {
|
|
543
|
+
let a = O(() => n(t), [t, n]), o = Ne(e, a, i), s = O(() => o > 1 && r ? n(r(a.points, o)) : a, [
|
|
544
544
|
a,
|
|
545
545
|
o,
|
|
546
546
|
n,
|
|
547
547
|
r
|
|
548
|
-
]), c =
|
|
548
|
+
]), c = k(o);
|
|
549
549
|
return D(() => {
|
|
550
550
|
if (!e) return;
|
|
551
551
|
let t = e.chart.timeScale(), n = c.current / o, r = n === 1 ? null : t.getVisibleLogicalRange();
|
|
@@ -561,23 +561,23 @@ function Le(e, t, n, r, i) {
|
|
|
561
561
|
}
|
|
562
562
|
//#endregion
|
|
563
563
|
//#region src/hooks/useLiveFollow.ts
|
|
564
|
-
var
|
|
564
|
+
var Fe = 3e3, Ie = [
|
|
565
565
|
"pointermove",
|
|
566
566
|
"pointerdown",
|
|
567
567
|
"wheel",
|
|
568
568
|
"keydown"
|
|
569
569
|
];
|
|
570
|
-
function
|
|
570
|
+
function Le(e, t) {
|
|
571
571
|
return e === null || t === null ? e === t : Math.abs(e.from - t.from) < .5 && Math.abs(e.to - t.to) < .5;
|
|
572
572
|
}
|
|
573
|
-
function
|
|
574
|
-
let [i, a] =
|
|
573
|
+
function Re(e, t, n, r) {
|
|
574
|
+
let [i, a] = A(!1), o = k(n);
|
|
575
575
|
return o.current = n, D(() => {
|
|
576
576
|
if (!e || !r) {
|
|
577
577
|
a(!1);
|
|
578
578
|
return;
|
|
579
579
|
}
|
|
580
|
-
let t = e.chart.timeScale(), i = () => a(!
|
|
580
|
+
let t = e.chart.timeScale(), i = () => a(!Ee(t.getVisibleLogicalRange(), n));
|
|
581
581
|
return i(), t.subscribeVisibleLogicalRangeChange(i), () => t.unsubscribeVisibleLogicalRangeChange(i);
|
|
582
582
|
}, [
|
|
583
583
|
e,
|
|
@@ -589,20 +589,20 @@ function Ve(e, t, n, r) {
|
|
|
589
589
|
let i = e.chart.timeScale(), a, s = null, c = () => {
|
|
590
590
|
if (!s) return;
|
|
591
591
|
let { range: e, wasLive: t, shift: n } = s;
|
|
592
|
-
s = null, i.applyOptions({ shiftVisibleRangeOnNewBar: n }), t && n &&
|
|
592
|
+
s = null, i.applyOptions({ shiftVisibleRangeOnNewBar: n }), t && n && Le(e, i.getVisibleLogicalRange()) && i.scrollToRealTime();
|
|
593
593
|
}, l = () => {
|
|
594
594
|
if (!s) {
|
|
595
595
|
let e = i.getVisibleLogicalRange();
|
|
596
596
|
s = {
|
|
597
597
|
range: e,
|
|
598
|
-
wasLive:
|
|
598
|
+
wasLive: Ee(e, o.current),
|
|
599
599
|
shift: i.options().shiftVisibleRangeOnNewBar
|
|
600
600
|
}, i.applyOptions({ shiftVisibleRangeOnNewBar: !1 });
|
|
601
601
|
}
|
|
602
|
-
clearTimeout(a), a = setTimeout(c,
|
|
602
|
+
clearTimeout(a), a = setTimeout(c, Fe);
|
|
603
603
|
};
|
|
604
|
-
return
|
|
605
|
-
clearTimeout(a),
|
|
604
|
+
return Ie.forEach((e) => n.addEventListener(e, l, { passive: !0 })), () => {
|
|
605
|
+
clearTimeout(a), Ie.forEach((e) => n.removeEventListener(e, l)), s && i.applyOptions({ shiftVisibleRangeOnNewBar: s.shift });
|
|
606
606
|
};
|
|
607
607
|
}, [
|
|
608
608
|
e,
|
|
@@ -615,20 +615,20 @@ function Ve(e, t, n, r) {
|
|
|
615
615
|
}
|
|
616
616
|
//#endregion
|
|
617
617
|
//#region src/hooks/usePriceFlash.ts
|
|
618
|
-
var
|
|
619
|
-
function
|
|
620
|
-
let i =
|
|
618
|
+
var ze = 600, Be = 8;
|
|
619
|
+
function Ve(e, t, n, r) {
|
|
620
|
+
let i = k(null);
|
|
621
621
|
D(() => {
|
|
622
622
|
let a = i.current;
|
|
623
623
|
i.current = t;
|
|
624
|
-
let o = n.current, s =
|
|
624
|
+
let o = n.current, s = Se(a, t), c = t.rows[t.rows.length - 1];
|
|
625
625
|
if (!e || !o || !r || !s || !c || typeof o.animate != "function" || m()) return;
|
|
626
626
|
let { chart: l, series: u } = e, d = requestAnimationFrame(() => {
|
|
627
|
-
let e = u.priceToCoordinate(c.close), t = l.priceScale("right").width(), n =
|
|
627
|
+
let e = u.priceToCoordinate(c.close), t = l.priceScale("right").width(), n = Ce(u.options());
|
|
628
628
|
if (e === null || t === 0 || n === null) return;
|
|
629
|
-
let r = l.options().layout.fontSize +
|
|
629
|
+
let r = l.options().layout.fontSize + Be;
|
|
630
630
|
o.style.width = `${t}px`, o.style.height = `${r}px`, o.style.transform = `translateY(${e - r / 2}px)`, o.style.background = s === "up" ? n.up : n.down, o.animate([{ opacity: .9 }, { opacity: 0 }], {
|
|
631
|
-
duration:
|
|
631
|
+
duration: ze,
|
|
632
632
|
easing: "ease-out"
|
|
633
633
|
});
|
|
634
634
|
});
|
|
@@ -642,8 +642,8 @@ function We(e, t, n, r) {
|
|
|
642
642
|
}
|
|
643
643
|
//#endregion
|
|
644
644
|
//#region src/hooks/usePriceLines.ts
|
|
645
|
-
var
|
|
646
|
-
function
|
|
645
|
+
var He = [];
|
|
646
|
+
function Ue(e, t = He) {
|
|
647
647
|
D(() => {
|
|
648
648
|
if (!e) return;
|
|
649
649
|
let { series: n } = e, r = t.map((e) => n.createPriceLine(e));
|
|
@@ -652,9 +652,9 @@ function Ke(e, t = Ge) {
|
|
|
652
652
|
}
|
|
653
653
|
//#endregion
|
|
654
654
|
//#region src/hooks/useSeriesTheme.ts
|
|
655
|
-
function
|
|
655
|
+
function We(e, { magnet: t, magnetMode: n, ctrlWheelZoom: r, chartOptions: i, anchorLine: o, overlays: l }) {
|
|
656
656
|
return {
|
|
657
|
-
options:
|
|
657
|
+
options: O(() => s(a(e), t && { crosshair: { mode: n } }, r && {
|
|
658
658
|
handleScale: { mouseWheel: !1 },
|
|
659
659
|
handleScroll: { mouseWheel: !1 }
|
|
660
660
|
}, i), [
|
|
@@ -664,8 +664,8 @@ function qe(e, { magnet: t, magnetMode: n, ctrlWheelZoom: r, chartOptions: i, an
|
|
|
664
664
|
r,
|
|
665
665
|
i
|
|
666
666
|
]),
|
|
667
|
-
themedAnchorLine:
|
|
668
|
-
themedOverlays:
|
|
667
|
+
themedAnchorLine: O(() => u(c(e, e?.anchor, void 0), o), [e, o]),
|
|
668
|
+
themedOverlays: O(() => {
|
|
669
669
|
let t = e?.line.overlays;
|
|
670
670
|
return t?.length && l ? l.map((e, n) => ({
|
|
671
671
|
...e,
|
|
@@ -676,26 +676,26 @@ function qe(e, { magnet: t, magnetMode: n, ctrlWheelZoom: r, chartOptions: i, an
|
|
|
676
676
|
}
|
|
677
677
|
//#endregion
|
|
678
678
|
//#region src/utils/range.utils.ts
|
|
679
|
-
var
|
|
680
|
-
function
|
|
679
|
+
var Ge = 86400;
|
|
680
|
+
function Z(e, t) {
|
|
681
681
|
let n = /* @__PURE__ */ new Date(e * 1e3), r = new Date(Date.UTC(n.getUTCFullYear(), n.getUTCMonth() - t + 1, 0));
|
|
682
682
|
return r.setUTCDate(Math.min(n.getUTCDate(), r.getUTCDate())), r.setUTCHours(n.getUTCHours(), n.getUTCMinutes(), n.getUTCSeconds()), r.getTime() / 1e3;
|
|
683
683
|
}
|
|
684
|
-
function
|
|
684
|
+
function Ke(e, t) {
|
|
685
685
|
switch (e) {
|
|
686
|
-
case "1D": return t -
|
|
687
|
-
case "1W": return t - 7 *
|
|
688
|
-
case "1M": return
|
|
689
|
-
case "3M": return
|
|
690
|
-
case "1Y": return
|
|
691
|
-
case "3Y": return
|
|
692
|
-
case "5Y": return
|
|
686
|
+
case "1D": return t - Ge;
|
|
687
|
+
case "1W": return t - 7 * Ge;
|
|
688
|
+
case "1M": return Z(t, 1);
|
|
689
|
+
case "3M": return Z(t, 3);
|
|
690
|
+
case "1Y": return Z(t, 12);
|
|
691
|
+
case "3Y": return Z(t, 36);
|
|
692
|
+
case "5Y": return Z(t, 60);
|
|
693
693
|
case "YTD": return Date.UTC((/* @__PURE__ */ new Date(t * 1e3)).getUTCFullYear(), 0, 1) / 1e3;
|
|
694
694
|
case "All": return null;
|
|
695
695
|
}
|
|
696
696
|
}
|
|
697
|
-
function
|
|
698
|
-
let r =
|
|
697
|
+
function qe(e, t, n) {
|
|
698
|
+
let r = Ke(n, t);
|
|
699
699
|
return r === null || r <= e ? null : {
|
|
700
700
|
from: r,
|
|
701
701
|
to: t
|
|
@@ -703,15 +703,15 @@ function Xe(e, t, n) {
|
|
|
703
703
|
}
|
|
704
704
|
//#endregion
|
|
705
705
|
//#region src/hooks/useRangePreset.ts
|
|
706
|
-
function
|
|
707
|
-
let r =
|
|
706
|
+
function Je(e, t, n) {
|
|
707
|
+
let r = k(t), i = t.data.length > 0;
|
|
708
708
|
r.current = t, D(() => {
|
|
709
709
|
if (!e || !n || !i) return;
|
|
710
710
|
let t = r.current.rows, a = e.chart.timeScale(), o = t[0], s = t[t.length - 1];
|
|
711
711
|
if (!o || !s) return;
|
|
712
|
-
let c =
|
|
712
|
+
let c = W(o.time), l = W(s.time);
|
|
713
713
|
if (c === null || l === null) return;
|
|
714
|
-
let u =
|
|
714
|
+
let u = qe(c, l, n);
|
|
715
715
|
if (!u) {
|
|
716
716
|
a.fitContent();
|
|
717
717
|
return;
|
|
@@ -728,10 +728,10 @@ function Ze(e, t, n) {
|
|
|
728
728
|
}
|
|
729
729
|
//#endregion
|
|
730
730
|
//#region src/utils/stats.utils.ts
|
|
731
|
-
function
|
|
731
|
+
function Ye(e, t) {
|
|
732
732
|
return e === 0 ? null : (t - e) / e * 100;
|
|
733
733
|
}
|
|
734
|
-
function
|
|
734
|
+
function Xe(e) {
|
|
735
735
|
let { high: t, low: n } = e[0];
|
|
736
736
|
for (let r of e) r.high > t && (t = r.high), r.low < n && (n = r.low);
|
|
737
737
|
return {
|
|
@@ -739,23 +739,23 @@ function $e(e) {
|
|
|
739
739
|
low: n
|
|
740
740
|
};
|
|
741
741
|
}
|
|
742
|
-
function
|
|
742
|
+
function Ze(e, t, n) {
|
|
743
743
|
let r = Math.max(0, Math.ceil(t)), i = Math.min(e.length - 1, Math.floor(n)), a = e[r], o = e[i];
|
|
744
744
|
return r > i || !a || !o ? null : {
|
|
745
745
|
from: a.time,
|
|
746
746
|
to: o.time,
|
|
747
747
|
open: a.open,
|
|
748
|
-
|
|
748
|
+
...Xe(e.slice(r, i + 1)),
|
|
749
749
|
close: o.close,
|
|
750
|
-
change:
|
|
750
|
+
change: Ye(a.open, o.close),
|
|
751
751
|
bars: i - r + 1
|
|
752
752
|
};
|
|
753
753
|
}
|
|
754
754
|
//#endregion
|
|
755
755
|
//#region src/hooks/useRangeSelect.ts
|
|
756
|
-
var
|
|
757
|
-
function
|
|
758
|
-
let [a, o] =
|
|
756
|
+
var Qe = 3;
|
|
757
|
+
function $e(e, t, n, r, i) {
|
|
758
|
+
let [a, o] = A(!1), s = k({
|
|
759
759
|
normalized: r,
|
|
760
760
|
options: i
|
|
761
761
|
});
|
|
@@ -776,8 +776,8 @@ function nt(e, t, n, r, i) {
|
|
|
776
776
|
e.key === "Escape" && f();
|
|
777
777
|
}, h = (e) => {
|
|
778
778
|
let t = Math.min(c ?? 0, u(e)), n = Math.max(c ?? 0, u(e));
|
|
779
|
-
if (f(), n - t <
|
|
780
|
-
let r = a.coordinateToLogical(t), i = a.coordinateToLogical(n), o = r === null || i === null ? null :
|
|
779
|
+
if (f(), n - t < Qe) return;
|
|
780
|
+
let r = a.coordinateToLogical(t), i = a.coordinateToLogical(n), o = r === null || i === null ? null : Ze(s.current.normalized.rows, r, i);
|
|
781
781
|
o && r !== null && i !== null && (a.setVisibleLogicalRange({
|
|
782
782
|
from: r - .5,
|
|
783
783
|
to: i + .5
|
|
@@ -798,34 +798,34 @@ function nt(e, t, n, r, i) {
|
|
|
798
798
|
}
|
|
799
799
|
//#endregion
|
|
800
800
|
//#region src/utils/interaction.utils.ts
|
|
801
|
-
function
|
|
801
|
+
function et({ points: e, rows: t }, n, r, i) {
|
|
802
802
|
let a = e[n], o = t[n];
|
|
803
803
|
if (a === void 0 || !o) return null;
|
|
804
804
|
let s = t[n - 1], c = r === null ? void 0 : t[r], l = i?.(n);
|
|
805
805
|
return {
|
|
806
806
|
point: a,
|
|
807
807
|
index: n,
|
|
808
|
-
change: s ?
|
|
808
|
+
change: s ? Ye(s.close, o.close) : null,
|
|
809
809
|
fromAnchor: c && r !== null ? {
|
|
810
|
-
change:
|
|
810
|
+
change: Ye(c.close, o.close),
|
|
811
811
|
bars: n - r
|
|
812
812
|
} : null,
|
|
813
813
|
...l && { band: l }
|
|
814
814
|
};
|
|
815
815
|
}
|
|
816
|
-
function
|
|
816
|
+
function tt({ x: e, y: t, gap: n, offset: r, width: i, height: a }) {
|
|
817
817
|
let o = e > i / 2;
|
|
818
818
|
return `translate(calc(${r + e + (o ? -n : n)}px - ${o ? 100 : 0}%), calc(${t}px - ${t > a / 2 ? 100 : 0}%))`;
|
|
819
819
|
}
|
|
820
820
|
//#endregion
|
|
821
821
|
//#region src/hooks/useAnchor.ts
|
|
822
|
-
var
|
|
823
|
-
function
|
|
824
|
-
let i = n == null ? null :
|
|
822
|
+
var nt = { title: "Anchor" };
|
|
823
|
+
function rt(e, t, n, r = nt) {
|
|
824
|
+
let i = n == null ? null : W(n), a = O(() => i === null ? null : K(t.rows, i), [t, i]), o = a === null ? null : t.rows[a]?.close ?? null;
|
|
825
825
|
return D(() => {
|
|
826
826
|
if (!e || o === null || r === !1) return;
|
|
827
827
|
let { series: t } = e, n = t.createPriceLine({
|
|
828
|
-
...
|
|
828
|
+
...nt,
|
|
829
829
|
...r,
|
|
830
830
|
price: o
|
|
831
831
|
});
|
|
@@ -838,8 +838,8 @@ function ot(e, t, n, r = at) {
|
|
|
838
838
|
}
|
|
839
839
|
//#endregion
|
|
840
840
|
//#region src/hooks/useChartEvents.ts
|
|
841
|
-
function
|
|
842
|
-
let o =
|
|
841
|
+
function it(e, t, n, r, i, a) {
|
|
842
|
+
let o = k(n), s = k(a), c = k(null), l = k(!1), [u, d] = A(null);
|
|
843
843
|
D(() => {
|
|
844
844
|
o.current = n, s.current = a;
|
|
845
845
|
});
|
|
@@ -894,8 +894,8 @@ function st(e, t, n, r, i, a) {
|
|
|
894
894
|
}
|
|
895
895
|
//#endregion
|
|
896
896
|
//#region src/hooks/useKeyboardNav.ts
|
|
897
|
-
function
|
|
898
|
-
let a =
|
|
897
|
+
function at(e, t, n, r, i) {
|
|
898
|
+
let a = k(i);
|
|
899
899
|
D(() => {
|
|
900
900
|
a.current = i;
|
|
901
901
|
}), D(() => {
|
|
@@ -904,7 +904,7 @@ function ct(e, t, n, r, i) {
|
|
|
904
904
|
let { chart: o, series: s } = e, c = n.data.length - 1, l = !1, u = (e) => {
|
|
905
905
|
let t = o.timeScale(), n = t.getVisibleLogicalRange();
|
|
906
906
|
if (!n) return;
|
|
907
|
-
let r = e - .5 < n.from ? e -
|
|
907
|
+
let r = e - .5 < n.from ? e - xe - n.from : e + .5 > n.to ? e + xe - n.to : 0;
|
|
908
908
|
r !== 0 && t.setVisibleLogicalRange({
|
|
909
909
|
from: n.from + r,
|
|
910
910
|
to: n.to + r
|
|
@@ -958,7 +958,7 @@ function ct(e, t, n, r, i) {
|
|
|
958
958
|
}
|
|
959
959
|
//#endregion
|
|
960
960
|
//#region src/hooks/useCrosshairBand.ts
|
|
961
|
-
function
|
|
961
|
+
function ot(e, t, n) {
|
|
962
962
|
let r = E((r) => {
|
|
963
963
|
let i = t.current;
|
|
964
964
|
if (!e || !i || !n) return;
|
|
@@ -988,22 +988,22 @@ function lt(e, t, n) {
|
|
|
988
988
|
}
|
|
989
989
|
//#endregion
|
|
990
990
|
//#region src/hooks/useInteractions.ts
|
|
991
|
-
var
|
|
992
|
-
function
|
|
991
|
+
var st = "ArrowLeft ArrowRight Home End Enter Escape Space", ct = 8;
|
|
992
|
+
function lt({ chart: e, series: t }, n, r) {
|
|
993
993
|
let i = n.data[r], a = n.rows[r];
|
|
994
994
|
if (!i || !a) return null;
|
|
995
995
|
let o = e.timeScale(), s = o.timeToCoordinate(i.time), c = t.priceToCoordinate(a.high);
|
|
996
|
-
return s === null || c === null ? null :
|
|
996
|
+
return s === null || c === null ? null : tt({
|
|
997
997
|
x: s,
|
|
998
998
|
y: c,
|
|
999
|
-
gap: o.options().barSpacing / 2 +
|
|
999
|
+
gap: o.options().barSpacing / 2 + ct,
|
|
1000
1000
|
offset: e.priceScale("left").width(),
|
|
1001
1001
|
...e.paneSize()
|
|
1002
1002
|
});
|
|
1003
1003
|
}
|
|
1004
|
-
function
|
|
1005
|
-
let { anchor: a, anchorLine: o, magnet: s, pinOnClick: c, keyboard: l } = i, { legend: u, tooltip: d, handlers: f, bandOf: p } = i, [m, h] =
|
|
1006
|
-
let i =
|
|
1004
|
+
function ut(e, t, n, r, i) {
|
|
1005
|
+
let { anchor: a, anchorLine: o, magnet: s, pinOnClick: c, keyboard: l } = i, { legend: u, tooltip: d, handlers: f, bandOf: p } = i, [m, h] = A(null), g = c ? m : null, _ = O(() => g === null ? null : K(r.data, g), [r, g]), v = rt(e, r, a === void 0 ? g : a, o), y = it(e, r, f, E((e, t, n) => {
|
|
1006
|
+
let i = et(r, e, v, p);
|
|
1007
1007
|
return i && {
|
|
1008
1008
|
...i,
|
|
1009
1009
|
price: n,
|
|
@@ -1013,8 +1013,8 @@ function pt(e, t, n, r, i) {
|
|
|
1013
1013
|
r,
|
|
1014
1014
|
v,
|
|
1015
1015
|
p
|
|
1016
|
-
]), u || d, c ? (e) => h(e === _ ? null : r.data[e]?.time ?? null) : void 0), b =
|
|
1017
|
-
|
|
1016
|
+
]), u || d, c ? (e) => h(e === _ ? null : r.data[e]?.time ?? null) : void 0), b = ot(e, n, s);
|
|
1017
|
+
at(e, t, r, l, {
|
|
1018
1018
|
current: () => y.hovered.current ?? _,
|
|
1019
1019
|
move: (e) => {
|
|
1020
1020
|
b(e === null ? null : r.data[e]?.time ?? null), y.activate(e, e === null ? null : y.eventAt(e));
|
|
@@ -1022,12 +1022,12 @@ function pt(e, t, n, r, i) {
|
|
|
1022
1022
|
select: (e) => y.select(y.eventAt(e)),
|
|
1023
1023
|
clear: () => h(null)
|
|
1024
1024
|
});
|
|
1025
|
-
let { active: x } = y, S = u ?
|
|
1025
|
+
let { active: x } = y, S = u ? et(r, x ?? _ ?? r.data.length - 1, v, p) : null, C = d && x !== null ? et(r, x, v, p) : null, w = C !== null && e && x !== null ? lt(e, r, x) : null;
|
|
1026
1026
|
return {
|
|
1027
1027
|
container: l ? {
|
|
1028
1028
|
role: "application",
|
|
1029
1029
|
tabIndex: 0,
|
|
1030
|
-
"aria-keyshortcuts":
|
|
1030
|
+
"aria-keyshortcuts": st
|
|
1031
1031
|
} : { role: "img" },
|
|
1032
1032
|
legend: S === null ? null : {
|
|
1033
1033
|
summary: S,
|
|
@@ -1041,14 +1041,14 @@ function pt(e, t, n, r, i) {
|
|
|
1041
1041
|
}
|
|
1042
1042
|
//#endregion
|
|
1043
1043
|
//#region src/hooks/useVisibleStats.ts
|
|
1044
|
-
function
|
|
1045
|
-
let r =
|
|
1044
|
+
function dt(e, t, n) {
|
|
1045
|
+
let r = k(n), i = n !== void 0;
|
|
1046
1046
|
r.current = n, D(() => {
|
|
1047
1047
|
if (!e || !i) return;
|
|
1048
1048
|
let n = e.chart.timeScale(), a = 0, o = () => {
|
|
1049
1049
|
a = 0;
|
|
1050
1050
|
let e = n.getVisibleLogicalRange();
|
|
1051
|
-
r.current?.(e ?
|
|
1051
|
+
r.current?.(e ? Ze(t.rows, e.from, e.to) : null);
|
|
1052
1052
|
}, s = () => {
|
|
1053
1053
|
a ||= requestAnimationFrame(o);
|
|
1054
1054
|
};
|
|
@@ -1063,25 +1063,25 @@ function mt(e, t, n) {
|
|
|
1063
1063
|
}
|
|
1064
1064
|
//#endregion
|
|
1065
1065
|
//#region src/components/BandLegend/index.tsx
|
|
1066
|
-
function
|
|
1066
|
+
function ft({ entries: e, render: n, theme: r, className: i, style: a }) {
|
|
1067
1067
|
if (n === null || e.length === 0) return null;
|
|
1068
|
-
if (n) return /* @__PURE__ */
|
|
1068
|
+
if (n) return /* @__PURE__ */ M(j, { children: n([...e]) });
|
|
1069
1069
|
let o = r ? `1px solid ${r.palette.border}` : "1px solid";
|
|
1070
|
-
return /* @__PURE__ */
|
|
1070
|
+
return /* @__PURE__ */ M("ul", {
|
|
1071
1071
|
"data-part": "band-legend",
|
|
1072
1072
|
className: i,
|
|
1073
1073
|
style: {
|
|
1074
|
-
...
|
|
1074
|
+
...B,
|
|
1075
1075
|
...t(r?.typography.label),
|
|
1076
1076
|
...a
|
|
1077
1077
|
},
|
|
1078
|
-
children: e.map(({ key: e, label: t, fill: n, legendColor: r }) => /* @__PURE__ */
|
|
1078
|
+
children: e.map(({ key: e, label: t, fill: n, legendColor: r }) => /* @__PURE__ */ N("li", {
|
|
1079
1079
|
"data-part": "band-legend-item",
|
|
1080
|
-
style:
|
|
1081
|
-
children: [/* @__PURE__ */
|
|
1080
|
+
style: V,
|
|
1081
|
+
children: [/* @__PURE__ */ M("span", {
|
|
1082
1082
|
"aria-hidden": "true",
|
|
1083
1083
|
style: {
|
|
1084
|
-
...
|
|
1084
|
+
...H,
|
|
1085
1085
|
background: r ?? n,
|
|
1086
1086
|
border: r ? "none" : o
|
|
1087
1087
|
}
|
|
@@ -1091,18 +1091,18 @@ function ht({ entries: e, render: n, theme: r, className: i, style: a }) {
|
|
|
1091
1091
|
}
|
|
1092
1092
|
//#endregion
|
|
1093
1093
|
//#region src/components/InteractionSlots/index.tsx
|
|
1094
|
-
var
|
|
1094
|
+
var pt = {
|
|
1095
1095
|
position: "absolute",
|
|
1096
1096
|
inset: 0,
|
|
1097
1097
|
pointerEvents: "none"
|
|
1098
1098
|
};
|
|
1099
|
-
function
|
|
1100
|
-
return /* @__PURE__ */
|
|
1101
|
-
style:
|
|
1099
|
+
function mt({ interactions: { legend: e, tooltip: t }, renderLegend: n, renderTooltip: r }) {
|
|
1100
|
+
return /* @__PURE__ */ N(j, { children: [e && n && /* @__PURE__ */ M("div", {
|
|
1101
|
+
style: pt,
|
|
1102
1102
|
"aria-live": "polite",
|
|
1103
1103
|
"aria-atomic": "true",
|
|
1104
1104
|
children: n(e)
|
|
1105
|
-
}), t && r && /* @__PURE__ */
|
|
1105
|
+
}), t && r && /* @__PURE__ */ M("div", {
|
|
1106
1106
|
style: {
|
|
1107
1107
|
...d,
|
|
1108
1108
|
transform: t.transform
|
|
@@ -1115,22 +1115,22 @@ function _t({ interactions: { legend: e, tooltip: t }, renderLegend: n, renderTo
|
|
|
1115
1115
|
}
|
|
1116
1116
|
//#endregion
|
|
1117
1117
|
//#region src/charts/SeriesChart/index.tsx
|
|
1118
|
-
function
|
|
1119
|
-
let
|
|
1120
|
-
theme:
|
|
1121
|
-
unstyled:
|
|
1122
|
-
}), { options:
|
|
1118
|
+
function ht({ data: e, definition: t, normalize: r, aggregate: i, magnetMode: a = y.MagnetOHLC, chartOptions: o, seriesOptions: s, className: c, ariaLabel: l = "Chart", liveButtonClassName: u, liveButtonLabel: d = "Jump to live", magnet: f = !0, flashLastPrice: m = !0, followLive: h = !0, ctrlWheelZoom: g = !0, renderLegend: _, renderTooltip: v, pinOnClick: b = !1, keyboard: x = !1, range: S, anchor: C, anchorLine: w, autoBucket: T, onVisibleStatsChange: E, onPointClick: D, onPointHover: O, onPointLeave: A, overlays: j, priceLines: P, bands: F, bandStyles: I, renderBandLegend: B, classNames: V = {}, styles: H = {}, rangeSelect: U = !0, doubleClickReset: ae = !0, onRangeSelect: se, onReset: W, theme: ce, unstyled: le }, ue) {
|
|
1119
|
+
let G = k(null), de = k(null), K = k(null), fe = k(null), q = p({
|
|
1120
|
+
theme: ce,
|
|
1121
|
+
unstyled: le
|
|
1122
|
+
}), { options: pe, themedAnchorLine: me, themedOverlays: he } = We(q, {
|
|
1123
1123
|
magnet: f,
|
|
1124
1124
|
magnetMode: a,
|
|
1125
1125
|
ctrlWheelZoom: g,
|
|
1126
1126
|
chartOptions: o,
|
|
1127
1127
|
anchorLine: w,
|
|
1128
|
-
overlays:
|
|
1129
|
-
}),
|
|
1130
|
-
|
|
1131
|
-
let
|
|
1128
|
+
overlays: j
|
|
1129
|
+
}), J = oe(G, t, pe, s), Y = Pe(J, e, r, i, T), ge = ve(J, he), { entries: X, bandOf: ye } = _e(J, Y, F, I, q);
|
|
1130
|
+
Ue(J, P), Je(J, Y, S), dt(J, Y, E);
|
|
1131
|
+
let be = ut(J, G, de, Y, {
|
|
1132
1132
|
anchor: C,
|
|
1133
|
-
anchorLine:
|
|
1133
|
+
anchorLine: me,
|
|
1134
1134
|
magnet: f,
|
|
1135
1135
|
pinOnClick: b,
|
|
1136
1136
|
keyboard: x,
|
|
@@ -1138,96 +1138,96 @@ function vt({ data: e, definition: t, normalize: r, aggregate: i, magnetMode: a
|
|
|
1138
1138
|
tooltip: v !== void 0,
|
|
1139
1139
|
handlers: {
|
|
1140
1140
|
onPointClick: D,
|
|
1141
|
-
onPointHover:
|
|
1142
|
-
onPointLeave:
|
|
1141
|
+
onPointHover: O,
|
|
1142
|
+
onPointLeave: A
|
|
1143
1143
|
},
|
|
1144
|
-
bandOf:
|
|
1144
|
+
bandOf: ye
|
|
1145
1145
|
});
|
|
1146
|
-
|
|
1147
|
-
let
|
|
1148
|
-
enabled:
|
|
1149
|
-
reset:
|
|
1150
|
-
onRangeSelect:
|
|
1151
|
-
onReset:
|
|
1146
|
+
Ve(J, Y, K, m);
|
|
1147
|
+
let xe = $e(J, G, fe, Y, {
|
|
1148
|
+
enabled: U,
|
|
1149
|
+
reset: ae,
|
|
1150
|
+
onRangeSelect: se,
|
|
1151
|
+
onReset: W
|
|
1152
1152
|
});
|
|
1153
|
-
|
|
1154
|
-
let { away:
|
|
1155
|
-
return
|
|
1156
|
-
chart:
|
|
1157
|
-
series:
|
|
1153
|
+
De(J, G, g);
|
|
1154
|
+
let { away: Se, jumpToLive: Ce } = Re(J, G, Y.rows.length - 1, h);
|
|
1155
|
+
return ee(ue, () => J ? {
|
|
1156
|
+
chart: J.chart,
|
|
1157
|
+
series: J.series,
|
|
1158
1158
|
get overlays() {
|
|
1159
|
-
return
|
|
1159
|
+
return ge.current.map((e) => e.series);
|
|
1160
1160
|
}
|
|
1161
|
-
} : null, [
|
|
1161
|
+
} : null, [J, ge]), /* @__PURE__ */ N("div", {
|
|
1162
1162
|
className: c,
|
|
1163
|
-
style:
|
|
1163
|
+
style: te,
|
|
1164
1164
|
children: [
|
|
1165
|
-
/* @__PURE__ */
|
|
1166
|
-
ref:
|
|
1167
|
-
style:
|
|
1165
|
+
/* @__PURE__ */ M("div", {
|
|
1166
|
+
ref: G,
|
|
1167
|
+
style: ne,
|
|
1168
1168
|
"aria-label": l,
|
|
1169
|
-
...
|
|
1169
|
+
...be.container
|
|
1170
1170
|
}),
|
|
1171
|
-
/* @__PURE__ */
|
|
1172
|
-
ref:
|
|
1173
|
-
style:
|
|
1171
|
+
/* @__PURE__ */ M("div", {
|
|
1172
|
+
ref: de,
|
|
1173
|
+
style: re,
|
|
1174
1174
|
"aria-hidden": "true"
|
|
1175
1175
|
}),
|
|
1176
|
-
/* @__PURE__ */
|
|
1177
|
-
entries:
|
|
1178
|
-
render:
|
|
1179
|
-
theme:
|
|
1180
|
-
className:
|
|
1181
|
-
style:
|
|
1176
|
+
/* @__PURE__ */ M(ft, {
|
|
1177
|
+
entries: X,
|
|
1178
|
+
render: B,
|
|
1179
|
+
theme: q,
|
|
1180
|
+
className: V.bandLegend,
|
|
1181
|
+
style: H.bandLegend
|
|
1182
1182
|
}),
|
|
1183
|
-
/* @__PURE__ */
|
|
1184
|
-
interactions:
|
|
1183
|
+
/* @__PURE__ */ M(mt, {
|
|
1184
|
+
interactions: be,
|
|
1185
1185
|
renderLegend: _,
|
|
1186
1186
|
renderTooltip: v
|
|
1187
1187
|
}),
|
|
1188
|
-
/* @__PURE__ */
|
|
1189
|
-
ref:
|
|
1190
|
-
style:
|
|
1188
|
+
/* @__PURE__ */ M("div", {
|
|
1189
|
+
ref: K,
|
|
1190
|
+
style: L,
|
|
1191
1191
|
"aria-hidden": "true"
|
|
1192
1192
|
}),
|
|
1193
|
-
|
|
1194
|
-
ref:
|
|
1193
|
+
xe && /* @__PURE__ */ M("div", {
|
|
1194
|
+
ref: fe,
|
|
1195
1195
|
"data-part": "range-select",
|
|
1196
|
-
className:
|
|
1196
|
+
className: V.rangeSelect,
|
|
1197
1197
|
style: {
|
|
1198
|
-
...
|
|
1199
|
-
background: n(
|
|
1200
|
-
...
|
|
1198
|
+
...ie,
|
|
1199
|
+
background: n(q?.palette.crosshair, .1),
|
|
1200
|
+
...H.rangeSelect
|
|
1201
1201
|
},
|
|
1202
1202
|
"aria-hidden": "true"
|
|
1203
1203
|
}),
|
|
1204
|
-
|
|
1204
|
+
Se && /* @__PURE__ */ M("button", {
|
|
1205
1205
|
type: "button",
|
|
1206
1206
|
className: u,
|
|
1207
|
-
style: u ||
|
|
1208
|
-
onClick:
|
|
1207
|
+
style: u || le ? R : z,
|
|
1208
|
+
onClick: Ce,
|
|
1209
1209
|
children: d
|
|
1210
1210
|
})
|
|
1211
1211
|
]
|
|
1212
1212
|
});
|
|
1213
1213
|
}
|
|
1214
|
-
var
|
|
1214
|
+
var Q = T(ht);
|
|
1215
1215
|
//#endregion
|
|
1216
1216
|
//#region src/utils/histogram.utils.ts
|
|
1217
|
-
function
|
|
1217
|
+
function gt(e, t, n, r) {
|
|
1218
1218
|
return t === "diverging" ? e < 0 ? r.negative : r.positive : t === "threshold" && n !== void 0 && e > n ? r.over : r.bar;
|
|
1219
1219
|
}
|
|
1220
|
-
function
|
|
1220
|
+
function _t(e, t, n, r) {
|
|
1221
1221
|
return e.map((e) => {
|
|
1222
1222
|
if (e.color !== void 0) return e;
|
|
1223
|
-
let i =
|
|
1223
|
+
let i = gt(e.value, t, n, r);
|
|
1224
1224
|
return i === void 0 ? e : {
|
|
1225
1225
|
...e,
|
|
1226
1226
|
color: i
|
|
1227
1227
|
};
|
|
1228
1228
|
});
|
|
1229
1229
|
}
|
|
1230
|
-
var
|
|
1230
|
+
var vt = (e) => e(), yt = (e) => {
|
|
1231
1231
|
let t = e();
|
|
1232
1232
|
if (!t?.priceRange) return t;
|
|
1233
1233
|
let { minValue: n, maxValue: r } = t.priceRange, i = Math.max(Math.abs(n), Math.abs(r));
|
|
@@ -1239,10 +1239,10 @@ var xt = (e) => e(), St = (e) => {
|
|
|
1239
1239
|
}
|
|
1240
1240
|
};
|
|
1241
1241
|
};
|
|
1242
|
-
function
|
|
1243
|
-
return s({ autoscaleInfoProvider: e === "diverging" ?
|
|
1242
|
+
function bt(e, t) {
|
|
1243
|
+
return s({ autoscaleInfoProvider: e === "diverging" ? yt : vt }, t);
|
|
1244
1244
|
}
|
|
1245
|
-
function
|
|
1245
|
+
function xt(e, t, n, r) {
|
|
1246
1246
|
let i = [];
|
|
1247
1247
|
return e === "threshold" && t !== void 0 && n !== !1 && i.push({
|
|
1248
1248
|
...n,
|
|
@@ -1255,20 +1255,20 @@ function wt(e, t, n, r) {
|
|
|
1255
1255
|
}
|
|
1256
1256
|
//#endregion
|
|
1257
1257
|
//#region src/utils/line.utils.ts
|
|
1258
|
-
function
|
|
1259
|
-
return
|
|
1258
|
+
function St(e, t) {
|
|
1259
|
+
return ke(e, t).map((e) => ({
|
|
1260
1260
|
...e[e.length - 1],
|
|
1261
1261
|
time: e[0].time
|
|
1262
1262
|
}));
|
|
1263
1263
|
}
|
|
1264
|
-
function
|
|
1264
|
+
function Ct(e) {
|
|
1265
1265
|
return e.map((e) => ({
|
|
1266
1266
|
time: e.time,
|
|
1267
1267
|
value: e.close,
|
|
1268
1268
|
...e.color !== void 0 && { color: e.color }
|
|
1269
1269
|
}));
|
|
1270
1270
|
}
|
|
1271
|
-
function
|
|
1271
|
+
function wt(e, t, n) {
|
|
1272
1272
|
return e.data.map(({ color: r, ...i }, a) => {
|
|
1273
1273
|
let o = { ...e.points[a] }, s = { ...i };
|
|
1274
1274
|
return r !== void 0 && t.forEach((e) => s[e] = r), n.forEach((e) => {
|
|
@@ -1278,8 +1278,8 @@ function Et(e, t, n) {
|
|
|
1278
1278
|
}
|
|
1279
1279
|
//#endregion
|
|
1280
1280
|
//#region src/charts/BarChart/index.tsx
|
|
1281
|
-
var
|
|
1282
|
-
let i = p(n), { upColor: a, downColor: o, options: s } =
|
|
1281
|
+
var Tt = T(function({ seriesOptions: e, ariaLabel: t = "Bar chart", ...n }, r) {
|
|
1282
|
+
let i = p(n), { upColor: a, downColor: o, options: s } = O(() => {
|
|
1283
1283
|
let { upColor: t = i?.palette.up, downColor: n = i?.palette.down, ...r } = e ?? {};
|
|
1284
1284
|
return {
|
|
1285
1285
|
upColor: t,
|
|
@@ -1287,10 +1287,10 @@ var Dt = T(function({ seriesOptions: e, ariaLabel: t = "Bar chart", ...n }, r) {
|
|
|
1287
1287
|
options: r
|
|
1288
1288
|
};
|
|
1289
1289
|
}, [i, e]), { base: c = 0, color: l } = s, u = E((e) => {
|
|
1290
|
-
let t =
|
|
1290
|
+
let t = G(e);
|
|
1291
1291
|
return l !== void 0 || !a || !o ? t : {
|
|
1292
1292
|
...t,
|
|
1293
|
-
data:
|
|
1293
|
+
data: _t(t.data, "threshold", c, {
|
|
1294
1294
|
over: a,
|
|
1295
1295
|
bar: o
|
|
1296
1296
|
})
|
|
@@ -1301,17 +1301,17 @@ var Dt = T(function({ seriesOptions: e, ariaLabel: t = "Bar chart", ...n }, r) {
|
|
|
1301
1301
|
o,
|
|
1302
1302
|
l
|
|
1303
1303
|
]);
|
|
1304
|
-
return /* @__PURE__ */
|
|
1304
|
+
return /* @__PURE__ */ M(Q, {
|
|
1305
1305
|
...n,
|
|
1306
1306
|
ref: r,
|
|
1307
1307
|
ariaLabel: t,
|
|
1308
1308
|
seriesOptions: s,
|
|
1309
1309
|
definition: b,
|
|
1310
1310
|
normalize: u,
|
|
1311
|
-
aggregate:
|
|
1311
|
+
aggregate: St,
|
|
1312
1312
|
magnetMode: y.Magnet
|
|
1313
1313
|
});
|
|
1314
|
-
}),
|
|
1314
|
+
}), Et = {
|
|
1315
1315
|
line: {
|
|
1316
1316
|
definition: x,
|
|
1317
1317
|
label: "Line chart",
|
|
@@ -1341,8 +1341,8 @@ var Dt = T(function({ seriesOptions: e, ariaLabel: t = "Bar chart", ...n }, r) {
|
|
|
1341
1341
|
"bottomFillColor2"
|
|
1342
1342
|
]
|
|
1343
1343
|
}
|
|
1344
|
-
},
|
|
1345
|
-
let c = p(i), l =
|
|
1344
|
+
}, Dt = T(function({ variant: e = "line", seriesOptions: t, baseValue: n, ariaLabel: r = Et[e].label, ...i }, a) {
|
|
1345
|
+
let c = p(i), l = O(() => s(o(c, e), n !== void 0 && { baseValue: {
|
|
1346
1346
|
type: "price",
|
|
1347
1347
|
price: n
|
|
1348
1348
|
} }, t), [
|
|
@@ -1351,50 +1351,50 @@ var Dt = T(function({ seriesOptions: e, ariaLabel: t = "Bar chart", ...n }, r) {
|
|
|
1351
1351
|
n,
|
|
1352
1352
|
t
|
|
1353
1353
|
]), u = E((t) => {
|
|
1354
|
-
let n =
|
|
1354
|
+
let n = G(t), { colorKeys: r, styleKeys: i } = Et[e];
|
|
1355
1355
|
return {
|
|
1356
1356
|
...n,
|
|
1357
|
-
data:
|
|
1357
|
+
data: wt(n, r, i)
|
|
1358
1358
|
};
|
|
1359
1359
|
}, [e]);
|
|
1360
|
-
return /* @__PURE__ */
|
|
1360
|
+
return /* @__PURE__ */ M(Q, {
|
|
1361
1361
|
...i,
|
|
1362
1362
|
ref: a,
|
|
1363
1363
|
ariaLabel: r,
|
|
1364
1364
|
seriesOptions: l,
|
|
1365
|
-
definition:
|
|
1365
|
+
definition: Et[e].definition,
|
|
1366
1366
|
magnetMode: y.Magnet,
|
|
1367
1367
|
normalize: u,
|
|
1368
|
-
aggregate:
|
|
1368
|
+
aggregate: St
|
|
1369
1369
|
});
|
|
1370
1370
|
});
|
|
1371
1371
|
//#endregion
|
|
1372
1372
|
//#region src/utils/candlestick.utils.ts
|
|
1373
|
-
function
|
|
1373
|
+
function Ot(e) {
|
|
1374
1374
|
return e.close >= e.open;
|
|
1375
1375
|
}
|
|
1376
|
-
function
|
|
1377
|
-
return
|
|
1376
|
+
function kt(e, t) {
|
|
1377
|
+
return ke(e, t).map((e) => ({
|
|
1378
1378
|
time: e[0].time,
|
|
1379
1379
|
open: e[0].open,
|
|
1380
|
-
|
|
1380
|
+
...Xe(e),
|
|
1381
1381
|
close: e[e.length - 1].close
|
|
1382
1382
|
}));
|
|
1383
1383
|
}
|
|
1384
1384
|
//#endregion
|
|
1385
1385
|
//#region src/charts/HistogramChart/index.tsx
|
|
1386
|
-
var
|
|
1387
|
-
let m =
|
|
1386
|
+
var At = T(function({ mode: t = "plain", threshold: n, thresholdLine: r, zeroLine: i, colors: a, seriesOptions: o, ariaLabel: l = "Histogram chart", ...d }, f) {
|
|
1387
|
+
let m = O(() => bt(t, o), [t, o]), h = p(d), g = O(() => xt(t, n, u(c(h, h?.histogram.threshold, "dashed"), r), u(c(h, h?.histogram.zero, "solid"), i)), [
|
|
1388
1388
|
h,
|
|
1389
1389
|
t,
|
|
1390
1390
|
n,
|
|
1391
1391
|
r,
|
|
1392
1392
|
i
|
|
1393
|
-
]), { bar: _, over: v, positive: x, negative: S } =
|
|
1394
|
-
let r =
|
|
1393
|
+
]), { bar: _, over: v, positive: x, negative: S } = O(() => s(e(h), a), [h, a]), C = E((e) => {
|
|
1394
|
+
let r = G(e);
|
|
1395
1395
|
return {
|
|
1396
1396
|
...r,
|
|
1397
|
-
data:
|
|
1397
|
+
data: _t(r.data, t, n, {
|
|
1398
1398
|
bar: _,
|
|
1399
1399
|
over: v,
|
|
1400
1400
|
positive: x,
|
|
@@ -1409,7 +1409,7 @@ var Mt = T(function({ mode: t = "plain", threshold: n, thresholdLine: r, zeroLin
|
|
|
1409
1409
|
x,
|
|
1410
1410
|
S
|
|
1411
1411
|
]);
|
|
1412
|
-
return /* @__PURE__ */
|
|
1412
|
+
return /* @__PURE__ */ M(Q, {
|
|
1413
1413
|
...d,
|
|
1414
1414
|
ref: f,
|
|
1415
1415
|
ariaLabel: l,
|
|
@@ -1417,21 +1417,21 @@ var Mt = T(function({ mode: t = "plain", threshold: n, thresholdLine: r, zeroLin
|
|
|
1417
1417
|
priceLines: g,
|
|
1418
1418
|
definition: b,
|
|
1419
1419
|
normalize: C,
|
|
1420
|
-
aggregate:
|
|
1420
|
+
aggregate: St,
|
|
1421
1421
|
magnetMode: y.Magnet
|
|
1422
1422
|
});
|
|
1423
|
-
}),
|
|
1424
|
-
let i = p(n), a =
|
|
1425
|
-
return /* @__PURE__ */
|
|
1423
|
+
}), jt = T(function({ ariaLabel: e = "Candlestick chart", seriesOptions: t, ...n }, r) {
|
|
1424
|
+
let i = p(n), a = O(() => s(l(i), t), [i, t]);
|
|
1425
|
+
return /* @__PURE__ */ M(Q, {
|
|
1426
1426
|
...n,
|
|
1427
1427
|
ref: r,
|
|
1428
1428
|
ariaLabel: e,
|
|
1429
1429
|
seriesOptions: a,
|
|
1430
1430
|
definition: _,
|
|
1431
|
-
normalize:
|
|
1432
|
-
aggregate:
|
|
1431
|
+
normalize: ue,
|
|
1432
|
+
aggregate: kt
|
|
1433
1433
|
});
|
|
1434
|
-
}),
|
|
1434
|
+
}), Mt = class {
|
|
1435
1435
|
points = [];
|
|
1436
1436
|
color = "#000000";
|
|
1437
1437
|
opacity = .16;
|
|
@@ -1469,7 +1469,7 @@ var Mt = T(function({ mode: t = "plain", threshold: n, thresholdLine: r, zeroLin
|
|
|
1469
1469
|
let t = this.chart, r = this.series;
|
|
1470
1470
|
if (!t || !r || this.points.length < 2) return;
|
|
1471
1471
|
let i = t.timeScale(), a = this.points.flatMap((e) => {
|
|
1472
|
-
let t =
|
|
1472
|
+
let t = F(i, e.time), n = r.priceToCoordinate(e.upper), a = r.priceToCoordinate(e.lower);
|
|
1473
1473
|
return t === null || n === null || a === null ? [] : [{
|
|
1474
1474
|
x: t,
|
|
1475
1475
|
upper: n,
|
|
@@ -1486,20 +1486,20 @@ var Mt = T(function({ mode: t = "plain", threshold: n, thresholdLine: r, zeroLin
|
|
|
1486
1486
|
e.closePath(), e.fillStyle = n(this.color, this.opacity) ?? this.color, e.fill();
|
|
1487
1487
|
});
|
|
1488
1488
|
}
|
|
1489
|
-
},
|
|
1490
|
-
function
|
|
1489
|
+
}, Nt = /* @__PURE__ */ new Set(), Pt = !1, $;
|
|
1490
|
+
function Ft(e) {
|
|
1491
1491
|
let t = globalThis.CanvasRenderingContext2D?.prototype;
|
|
1492
|
-
return t?.roundRect ? (
|
|
1493
|
-
for (let i of
|
|
1494
|
-
return
|
|
1492
|
+
return t?.roundRect ? (Nt.add(e), Pt ||= ($ = t.roundRect, t.roundRect = function(e, t, n, r, i) {
|
|
1493
|
+
for (let i of Nt) if (i.contains(this.canvas)) return $.call(this, e, t, n, r, 0);
|
|
1494
|
+
return $.call(this, e, t, n, r, i);
|
|
1495
1495
|
}, !0), () => {
|
|
1496
|
-
|
|
1496
|
+
Nt.delete(e), Nt.size === 0 && Pt && $ && (t.roundRect = $, Pt = !1, $ = void 0);
|
|
1497
1497
|
}) : () => {};
|
|
1498
1498
|
}
|
|
1499
1499
|
//#endregion
|
|
1500
1500
|
//#region src/utils/editorial.utils.ts
|
|
1501
|
-
var
|
|
1502
|
-
function
|
|
1501
|
+
var It = "ui-sans-serif, system-ui, sans-serif";
|
|
1502
|
+
function Lt(e, { height: t = 340, timeVisible: n = !1, rightOffset: r = 2, leftPriceScale: i = !1, rightPriceScale: a = !0, tickMarkFormatter: o, timeFormatter: s } = {}) {
|
|
1503
1503
|
let { palette: c, typography: l } = e, u = {
|
|
1504
1504
|
borderColor: c.border,
|
|
1505
1505
|
scaleMargins: {
|
|
@@ -1520,7 +1520,7 @@ function Rt(e, { height: t = 340, timeVisible: n = !1, rightOffset: r = 2, leftP
|
|
|
1520
1520
|
color: "transparent"
|
|
1521
1521
|
},
|
|
1522
1522
|
textColor: c.text,
|
|
1523
|
-
fontFamily: l.axis.family ||
|
|
1523
|
+
fontFamily: l.axis.family || It,
|
|
1524
1524
|
fontSize: l.axis.size ?? 11,
|
|
1525
1525
|
attributionLogo: !1
|
|
1526
1526
|
},
|
|
@@ -1565,8 +1565,8 @@ function Rt(e, { height: t = 340, timeVisible: n = !1, rightOffset: r = 2, leftP
|
|
|
1565
1565
|
}
|
|
1566
1566
|
//#endregion
|
|
1567
1567
|
//#region src/utils/ordinal.utils.ts
|
|
1568
|
-
var
|
|
1569
|
-
function
|
|
1568
|
+
var Rt = 86400;
|
|
1569
|
+
function zt(e, t) {
|
|
1570
1570
|
if (typeof e == "number" && Number.isInteger(e)) return e >= 0 && e < t.length ? e : null;
|
|
1571
1571
|
if (typeof e == "string") {
|
|
1572
1572
|
let n = t.indexOf(e);
|
|
@@ -1574,24 +1574,24 @@ function Bt(e, t) {
|
|
|
1574
1574
|
}
|
|
1575
1575
|
return null;
|
|
1576
1576
|
}
|
|
1577
|
-
function
|
|
1578
|
-
let n =
|
|
1579
|
-
return n === null ? null : n *
|
|
1577
|
+
function Bt(e, t) {
|
|
1578
|
+
let n = zt(e, t);
|
|
1579
|
+
return n === null ? null : n * Rt;
|
|
1580
1580
|
}
|
|
1581
|
-
function
|
|
1581
|
+
function Vt(e, t) {
|
|
1582
1582
|
return t[Math.round(e / 86400)] ?? "";
|
|
1583
1583
|
}
|
|
1584
1584
|
//#endregion
|
|
1585
1585
|
//#region src/utils/timeSeries.utils.ts
|
|
1586
|
-
function
|
|
1587
|
-
if (t) return
|
|
1588
|
-
let n =
|
|
1586
|
+
function Ht(e, t) {
|
|
1587
|
+
if (t) return Bt(e, t);
|
|
1588
|
+
let n = W(e);
|
|
1589
1589
|
return n === null ? null : n;
|
|
1590
1590
|
}
|
|
1591
1591
|
function Ut(e, t) {
|
|
1592
1592
|
let n = [];
|
|
1593
1593
|
for (let r of e) {
|
|
1594
|
-
let e =
|
|
1594
|
+
let e = Ht(r.time, t);
|
|
1595
1595
|
if (e === null || !Number.isFinite(r.value)) continue;
|
|
1596
1596
|
let i = n[n.length - 1];
|
|
1597
1597
|
i && i.time === e ? n[n.length - 1] = {
|
|
@@ -1613,12 +1613,12 @@ function Ut(e, t) {
|
|
|
1613
1613
|
function Wt(e, t, n) {
|
|
1614
1614
|
let r = /* @__PURE__ */ new Map();
|
|
1615
1615
|
for (let e of t) {
|
|
1616
|
-
let t =
|
|
1616
|
+
let t = Ht(e.time, n);
|
|
1617
1617
|
t !== null && Number.isFinite(e.value) && r.set(t, e.value);
|
|
1618
1618
|
}
|
|
1619
1619
|
let i = [];
|
|
1620
1620
|
for (let t of e) {
|
|
1621
|
-
let e =
|
|
1621
|
+
let e = Ht(t.time, n), a = e === null ? void 0 : r.get(e);
|
|
1622
1622
|
e !== null && a !== void 0 && Number.isFinite(t.value) && i.push({
|
|
1623
1623
|
time: e,
|
|
1624
1624
|
upper: t.value,
|
|
@@ -1628,7 +1628,7 @@ function Wt(e, t, n) {
|
|
|
1628
1628
|
return i.sort((e, t) => e.time - t.time), i;
|
|
1629
1629
|
}
|
|
1630
1630
|
function Gt(e) {
|
|
1631
|
-
let t =
|
|
1631
|
+
let t = W(e);
|
|
1632
1632
|
return t === null ? String(e) : (/* @__PURE__ */ new Date(t * 1e3)).toISOString().slice(0, 10);
|
|
1633
1633
|
}
|
|
1634
1634
|
//#endregion
|
|
@@ -1641,7 +1641,7 @@ var Kt = {
|
|
|
1641
1641
|
line: x,
|
|
1642
1642
|
area: h,
|
|
1643
1643
|
histogram: b
|
|
1644
|
-
}, Jt = [], Yt = [], Xt = [], Zt = {
|
|
1644
|
+
}, Jt = [], Yt = [], Xt = [], Zt = [], Qt = [], $t = {
|
|
1645
1645
|
...d,
|
|
1646
1646
|
minWidth: 140,
|
|
1647
1647
|
padding: "8px 10px",
|
|
@@ -1649,185 +1649,250 @@ var Kt = {
|
|
|
1649
1649
|
fontSize: 12,
|
|
1650
1650
|
lineHeight: 1.4
|
|
1651
1651
|
};
|
|
1652
|
-
function
|
|
1652
|
+
function en(e) {
|
|
1653
1653
|
return e.priceScale ?? "right";
|
|
1654
1654
|
}
|
|
1655
|
-
function
|
|
1655
|
+
function tn(e, t, n) {
|
|
1656
1656
|
return e.color ?? n[t % Math.max(1, n.length)] ?? "#191919";
|
|
1657
1657
|
}
|
|
1658
|
-
function
|
|
1659
|
-
let
|
|
1660
|
-
theme:
|
|
1661
|
-
unstyled:
|
|
1662
|
-
}), [
|
|
1663
|
-
formatTime:
|
|
1664
|
-
formatValue:
|
|
1665
|
-
extraTooltipRows:
|
|
1666
|
-
renderTooltip:
|
|
1658
|
+
function nn({ series: e, ribbons: t = Yt, ranges: r = Xt, guides: o = Zt, markers: c = Qt, onPointClick: l, height: u = 340, className: d, ariaLabel: m = "Time series chart", profile: h = "editorial", axis: g = "time", categories: _, timeVisible: v = !1, formatTime: b, formatValue: x, extraTooltipRows: T, renderTooltip: E, chartOptions: ee, theme: O, unstyled: j }) {
|
|
1659
|
+
let P = k(null), F = p({
|
|
1660
|
+
theme: O,
|
|
1661
|
+
unstyled: j
|
|
1662
|
+
}), [I, re] = A(null), [L, R] = A(null), z = k({
|
|
1663
|
+
formatTime: b,
|
|
1664
|
+
formatValue: x,
|
|
1665
|
+
extraTooltipRows: T,
|
|
1666
|
+
renderTooltip: E,
|
|
1667
|
+
onPointClick: l
|
|
1667
1668
|
});
|
|
1668
|
-
|
|
1669
|
-
formatTime:
|
|
1670
|
-
formatValue:
|
|
1671
|
-
extraTooltipRows:
|
|
1672
|
-
renderTooltip:
|
|
1669
|
+
z.current = {
|
|
1670
|
+
formatTime: b,
|
|
1671
|
+
formatValue: x,
|
|
1672
|
+
extraTooltipRows: T,
|
|
1673
|
+
renderTooltip: E,
|
|
1674
|
+
onPointClick: l
|
|
1673
1675
|
};
|
|
1674
|
-
let
|
|
1676
|
+
let B = h === "editorial", V = g === "ordinal" ? _ ?? Jt : null, H = F ?? i;
|
|
1675
1677
|
D(() => {
|
|
1676
|
-
let e =
|
|
1677
|
-
if (e &&
|
|
1678
|
-
}, [
|
|
1679
|
-
let i =
|
|
1678
|
+
let e = P.current;
|
|
1679
|
+
if (e && B) return Ft(e);
|
|
1680
|
+
}, [B]), D(() => {
|
|
1681
|
+
let i = P.current;
|
|
1680
1682
|
if (!i) return;
|
|
1681
|
-
let
|
|
1682
|
-
let t = typeof e == "number" ? e :
|
|
1683
|
-
return t === null ? "" :
|
|
1684
|
-
},
|
|
1685
|
-
height:
|
|
1686
|
-
timeVisible:
|
|
1687
|
-
leftPriceScale:
|
|
1688
|
-
rightPriceScale:
|
|
1689
|
-
tickMarkFormatter:
|
|
1690
|
-
timeFormatter:
|
|
1691
|
-
}) : s(a(
|
|
1692
|
-
height:
|
|
1683
|
+
let l = H.palette, d = l.categorical, f = e.some((e) => en(e) === "left") || t.some((e) => e.priceScale === "left"), p = e.length === 0 || e.some((e) => en(e) === "right") || t.some((e) => (e.priceScale ?? "right") === "right"), m = (e) => {
|
|
1684
|
+
let t = typeof e == "number" ? e : W(e);
|
|
1685
|
+
return t === null ? "" : V ? Vt(t, V) : z.current.formatTime?.(t) ?? Gt(t);
|
|
1686
|
+
}, h = B ? Lt(H, {
|
|
1687
|
+
height: u,
|
|
1688
|
+
timeVisible: v,
|
|
1689
|
+
leftPriceScale: f,
|
|
1690
|
+
rightPriceScale: p,
|
|
1691
|
+
tickMarkFormatter: m,
|
|
1692
|
+
timeFormatter: m
|
|
1693
|
+
}) : s(a(H), {
|
|
1694
|
+
height: u,
|
|
1693
1695
|
crosshair: { mode: y.Magnet },
|
|
1694
1696
|
handleScale: { mouseWheel: !1 },
|
|
1695
1697
|
handleScroll: { mouseWheel: !1 },
|
|
1696
|
-
leftPriceScale: { visible:
|
|
1697
|
-
rightPriceScale: { visible:
|
|
1698
|
+
leftPriceScale: { visible: f },
|
|
1699
|
+
rightPriceScale: { visible: p },
|
|
1698
1700
|
timeScale: {
|
|
1699
|
-
timeVisible:
|
|
1700
|
-
tickMarkFormatter:
|
|
1701
|
+
timeVisible: v,
|
|
1702
|
+
tickMarkFormatter: m
|
|
1701
1703
|
},
|
|
1702
|
-
localization: { timeFormatter:
|
|
1703
|
-
}),
|
|
1704
|
-
let
|
|
1705
|
-
priceScaleId:
|
|
1704
|
+
localization: { timeFormatter: m }
|
|
1705
|
+
}), g = C(i, s({ autoSize: !0 }, h, ee)), _ = /* @__PURE__ */ new Map(), b = e.map((e, t) => {
|
|
1706
|
+
let r = tn(e, t, d), i = e.kind ?? "line", a = e.lineWidth ?? (i === "line" ? 2 : 1), o = {
|
|
1707
|
+
priceScaleId: en(e),
|
|
1706
1708
|
priceLineVisible: !1,
|
|
1707
1709
|
lastValueVisible: e.lastValueVisible ?? !1
|
|
1708
|
-
},
|
|
1709
|
-
...
|
|
1710
|
-
lineColor:
|
|
1711
|
-
lineWidth:
|
|
1710
|
+
}, s = i === "area" ? {
|
|
1711
|
+
...o,
|
|
1712
|
+
lineColor: r,
|
|
1713
|
+
lineWidth: a,
|
|
1712
1714
|
lineStyle: Kt[e.lineStyle ?? "solid"],
|
|
1713
|
-
topColor: n(
|
|
1714
|
-
bottomColor: n(
|
|
1715
|
-
} :
|
|
1716
|
-
...
|
|
1717
|
-
color:
|
|
1715
|
+
topColor: n(r, .2) ?? r,
|
|
1716
|
+
bottomColor: n(r, 0) ?? r
|
|
1717
|
+
} : i === "histogram" ? {
|
|
1718
|
+
...o,
|
|
1719
|
+
color: r
|
|
1718
1720
|
} : {
|
|
1719
|
-
...
|
|
1720
|
-
color:
|
|
1721
|
-
lineWidth:
|
|
1721
|
+
...o,
|
|
1722
|
+
color: r,
|
|
1723
|
+
lineWidth: a,
|
|
1722
1724
|
lineStyle: Kt[e.lineStyle ?? "solid"],
|
|
1723
1725
|
crosshairMarkerVisible: !0
|
|
1724
|
-
},
|
|
1725
|
-
|
|
1726
|
-
let f =
|
|
1726
|
+
}, l = g.addSeries(qt[i], s), u = Ut(e.data, V);
|
|
1727
|
+
l.setData(u), _.set(en(e), l);
|
|
1728
|
+
let f = c.flatMap((t) => {
|
|
1727
1729
|
if (t.seriesId !== e.id) return [];
|
|
1728
|
-
let n =
|
|
1730
|
+
let n = Ht(t.time, V);
|
|
1729
1731
|
return n === null ? [] : [{
|
|
1730
1732
|
time: n,
|
|
1731
1733
|
position: t.position ?? "inBar",
|
|
1732
1734
|
shape: t.shape ?? "circle",
|
|
1733
|
-
color: t.color ??
|
|
1735
|
+
color: t.color ?? r,
|
|
1734
1736
|
text: t.text
|
|
1735
1737
|
}];
|
|
1736
1738
|
});
|
|
1737
|
-
return f.length > 0 && w(
|
|
1739
|
+
return f.length > 0 && w(l, f), {
|
|
1738
1740
|
spec: e,
|
|
1739
|
-
color:
|
|
1740
|
-
rows:
|
|
1741
|
-
apiSeries:
|
|
1741
|
+
color: r,
|
|
1742
|
+
rows: u,
|
|
1743
|
+
apiSeries: l
|
|
1742
1744
|
};
|
|
1743
1745
|
});
|
|
1744
1746
|
for (let e of t) {
|
|
1745
|
-
let t = e.priceScale ?? "right", n =
|
|
1747
|
+
let t = e.priceScale ?? "right", n = _.get(t) ?? b[0]?.apiSeries;
|
|
1746
1748
|
if (!n) continue;
|
|
1747
|
-
let r = e.color ??
|
|
1748
|
-
n.attachPrimitive(new
|
|
1749
|
-
points: Wt(e.upper, e.lower,
|
|
1749
|
+
let r = e.color ?? d[0] ?? l.down;
|
|
1750
|
+
n.attachPrimitive(new Mt({
|
|
1751
|
+
points: Wt(e.upper, e.lower, V),
|
|
1750
1752
|
color: r,
|
|
1751
1753
|
opacity: e.opacity
|
|
1752
1754
|
}));
|
|
1753
1755
|
}
|
|
1754
|
-
let
|
|
1756
|
+
let x = b[0]?.apiSeries;
|
|
1757
|
+
x && r.length > 0 && x.attachPrimitive(new X({
|
|
1758
|
+
items: r.map((e) => ({
|
|
1759
|
+
from: e.from,
|
|
1760
|
+
to: e.to,
|
|
1761
|
+
key: e.id,
|
|
1762
|
+
label: e.label,
|
|
1763
|
+
color: e.fill
|
|
1764
|
+
})),
|
|
1765
|
+
style: (e) => {
|
|
1766
|
+
let t = r.find((t) => t.id === e), n = t?.hatch;
|
|
1767
|
+
return {
|
|
1768
|
+
fill: t?.fill,
|
|
1769
|
+
hatch: n !== !1 && {
|
|
1770
|
+
color: n ?? t?.fill ?? l.down,
|
|
1771
|
+
spacing: 8,
|
|
1772
|
+
width: 1,
|
|
1773
|
+
opacity: .45
|
|
1774
|
+
}
|
|
1775
|
+
};
|
|
1776
|
+
}
|
|
1777
|
+
}));
|
|
1778
|
+
let T = /* @__PURE__ */ new Map();
|
|
1779
|
+
for (let e of o) {
|
|
1780
|
+
let t = _.get(e.scale ?? "right") ?? b[0]?.apiSeries;
|
|
1781
|
+
if (!t || (t.createPriceLine({
|
|
1782
|
+
price: e.value,
|
|
1783
|
+
color: e.color ?? l.down,
|
|
1784
|
+
lineWidth: 1,
|
|
1785
|
+
lineStyle: S.Dashed,
|
|
1786
|
+
axisLabelVisible: !!e.label,
|
|
1787
|
+
title: e.label ?? ""
|
|
1788
|
+
}), !Number.isFinite(e.value))) continue;
|
|
1789
|
+
let n = T.get(t) ?? [];
|
|
1790
|
+
n.push(e.value), T.set(t, n);
|
|
1791
|
+
}
|
|
1792
|
+
for (let [e, t] of T) e.applyOptions({ autoscaleInfoProvider: ((e) => {
|
|
1793
|
+
let n = e();
|
|
1794
|
+
return n?.priceRange ? {
|
|
1795
|
+
...n,
|
|
1796
|
+
priceRange: {
|
|
1797
|
+
minValue: Math.min(n.priceRange.minValue, ...t),
|
|
1798
|
+
maxValue: Math.max(n.priceRange.maxValue, ...t)
|
|
1799
|
+
}
|
|
1800
|
+
} : n;
|
|
1801
|
+
}) });
|
|
1802
|
+
g.timeScale().fitContent();
|
|
1803
|
+
let E = (e) => {
|
|
1755
1804
|
let t = typeof e.time == "number" ? e.time : null, n = e.point;
|
|
1756
1805
|
if (t === null || !n) {
|
|
1757
|
-
|
|
1806
|
+
R(null);
|
|
1758
1807
|
return;
|
|
1759
1808
|
}
|
|
1760
|
-
let r =
|
|
1809
|
+
let r = b.flatMap(({ spec: e, color: n, rows: r }) => {
|
|
1761
1810
|
if (e.includeInTooltip === !1) return [];
|
|
1762
1811
|
let i = r.find((e) => e.time === t);
|
|
1763
1812
|
return i ? [{
|
|
1764
1813
|
label: e.name,
|
|
1765
|
-
value:
|
|
1814
|
+
value: z.current.formatValue?.(e.id, i.value) ?? String(i.value),
|
|
1766
1815
|
color: n,
|
|
1767
1816
|
swatch: e.kind === "histogram" ? "bar" : "line"
|
|
1768
1817
|
}] : [];
|
|
1769
|
-
}), i =
|
|
1770
|
-
|
|
1818
|
+
}), i = z.current.extraTooltipRows?.(t) ?? [], a = V ? Vt(t, V) : z.current.formatTime?.(t) ?? Gt(t);
|
|
1819
|
+
R({
|
|
1771
1820
|
label: a,
|
|
1772
1821
|
rows: [...r, ...i],
|
|
1773
1822
|
x: n.x,
|
|
1774
1823
|
y: n.y,
|
|
1775
1824
|
time: t
|
|
1776
1825
|
});
|
|
1826
|
+
}, D = (e) => {
|
|
1827
|
+
let t = z.current.onPointClick, n = typeof e.time == "number" ? e.time : null;
|
|
1828
|
+
if (!t || n === null) return;
|
|
1829
|
+
let r = b.flatMap(({ spec: e, rows: t }) => {
|
|
1830
|
+
let r = t.find((e) => e.time === n);
|
|
1831
|
+
return r ? [{
|
|
1832
|
+
seriesId: e.id,
|
|
1833
|
+
value: r.value
|
|
1834
|
+
}] : [];
|
|
1835
|
+
});
|
|
1836
|
+
r.length > 0 && t({
|
|
1837
|
+
time: n,
|
|
1838
|
+
points: r
|
|
1839
|
+
});
|
|
1777
1840
|
};
|
|
1778
|
-
return
|
|
1779
|
-
|
|
1841
|
+
return g.subscribeCrosshairMove(E), g.subscribeClick(D), re(g), () => {
|
|
1842
|
+
re(null), R(null), g.unsubscribeCrosshairMove(E), g.unsubscribeClick(D), g.remove();
|
|
1780
1843
|
};
|
|
1781
1844
|
}, [
|
|
1782
1845
|
e,
|
|
1783
1846
|
t,
|
|
1784
1847
|
r,
|
|
1785
|
-
O,
|
|
1786
1848
|
o,
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1849
|
+
c,
|
|
1850
|
+
F,
|
|
1851
|
+
u,
|
|
1852
|
+
B,
|
|
1853
|
+
V,
|
|
1854
|
+
v,
|
|
1855
|
+
ee,
|
|
1856
|
+
H
|
|
1857
|
+
]), De(I ? {
|
|
1858
|
+
chart: I,
|
|
1794
1859
|
series: null
|
|
1795
|
-
} : null,
|
|
1796
|
-
let
|
|
1797
|
-
return /* @__PURE__ */
|
|
1798
|
-
className:
|
|
1799
|
-
"data-profile":
|
|
1800
|
-
"data-axis":
|
|
1860
|
+
} : null, P, !B);
|
|
1861
|
+
let ie = P.current?.getBoundingClientRect(), U = L ? f([L.x, L.y], 12, [180, 56], [ie?.width || u, ie?.height || u]) : null;
|
|
1862
|
+
return /* @__PURE__ */ N("div", {
|
|
1863
|
+
className: d,
|
|
1864
|
+
"data-profile": h,
|
|
1865
|
+
"data-axis": g,
|
|
1801
1866
|
style: {
|
|
1802
|
-
...
|
|
1803
|
-
height:
|
|
1867
|
+
...te,
|
|
1868
|
+
height: u
|
|
1804
1869
|
},
|
|
1805
|
-
children: [/* @__PURE__ */
|
|
1806
|
-
ref:
|
|
1807
|
-
style:
|
|
1870
|
+
children: [/* @__PURE__ */ M("div", {
|
|
1871
|
+
ref: P,
|
|
1872
|
+
style: ne,
|
|
1808
1873
|
role: "img",
|
|
1809
|
-
"aria-label":
|
|
1810
|
-
}),
|
|
1874
|
+
"aria-label": m
|
|
1875
|
+
}), L && U && /* @__PURE__ */ N("div", {
|
|
1811
1876
|
"data-part": "tooltip",
|
|
1812
1877
|
style: {
|
|
1813
|
-
|
|
1814
|
-
left:
|
|
1815
|
-
top:
|
|
1816
|
-
background:
|
|
1817
|
-
color:
|
|
1818
|
-
border: `1px solid ${
|
|
1878
|
+
...$t,
|
|
1879
|
+
left: U[0],
|
|
1880
|
+
top: U[1],
|
|
1881
|
+
background: F?.palette.background ?? "#fff",
|
|
1882
|
+
color: F?.palette.text ?? "#191919",
|
|
1883
|
+
border: `1px solid ${F?.palette.border ?? "#2B2B43"}`
|
|
1819
1884
|
},
|
|
1820
|
-
children: [/* @__PURE__ */
|
|
1885
|
+
children: [/* @__PURE__ */ M("div", {
|
|
1821
1886
|
"data-part": "tooltip-time",
|
|
1822
|
-
children:
|
|
1823
|
-
}),
|
|
1824
|
-
time:
|
|
1825
|
-
x:
|
|
1826
|
-
y:
|
|
1827
|
-
}) :
|
|
1887
|
+
children: L.label
|
|
1888
|
+
}), z.current.renderTooltip ? z.current.renderTooltip(L.rows, {
|
|
1889
|
+
time: L.time,
|
|
1890
|
+
x: L.x,
|
|
1891
|
+
y: L.y
|
|
1892
|
+
}) : L.rows.map((e) => /* @__PURE__ */ N("div", {
|
|
1828
1893
|
"data-part": "tooltip-row",
|
|
1829
1894
|
children: [
|
|
1830
|
-
/* @__PURE__ */
|
|
1895
|
+
/* @__PURE__ */ M("span", {
|
|
1831
1896
|
"data-part": "swatch",
|
|
1832
1897
|
"data-swatch": e.swatch,
|
|
1833
1898
|
style: {
|
|
@@ -1838,15 +1903,15 @@ function en({ series: e, ribbons: t = Yt, markers: r = Xt, height: o = 340, clas
|
|
|
1838
1903
|
background: e.color
|
|
1839
1904
|
}
|
|
1840
1905
|
}),
|
|
1841
|
-
/* @__PURE__ */
|
|
1906
|
+
/* @__PURE__ */ M("span", { children: e.label }),
|
|
1842
1907
|
" ",
|
|
1843
|
-
/* @__PURE__ */
|
|
1908
|
+
/* @__PURE__ */ M("span", { children: e.value })
|
|
1844
1909
|
]
|
|
1845
1910
|
}, `${e.label}:${e.value}`))]
|
|
1846
1911
|
})]
|
|
1847
1912
|
});
|
|
1848
1913
|
}
|
|
1849
1914
|
//#endregion
|
|
1850
|
-
export {
|
|
1915
|
+
export { oe as C, W as S, De as _, jt as a, me as b, Ot as c, St as d, Ct as f, Q as g, xt as h, Mt as i, Dt as l, bt as m, Lt as n, At as o, _t as p, Ft as r, kt as s, nn as t, Tt as u, X as v, F as w, G as x, he as y };
|
|
1851
1916
|
|
|
1852
|
-
//# sourceMappingURL=TimeSeriesChart-
|
|
1917
|
+
//# sourceMappingURL=TimeSeriesChart-BIwJxgnD.js.map
|