@pradeepjadhav/trading-reload-chart 1.1.0 → 1.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/dist/canvas/layers/ShapesLayer/ShapesLayer.d.ts +1 -0
- package/dist/canvas/layers/ShapesLayer/ShapesLayer.types.d.ts +1 -0
- package/dist/chart/ChartController.types.d.ts +11 -0
- package/dist/config/chartConfig.types.d.ts +4 -4
- package/dist/trading-reload-chart.js +154 -145
- package/package.json +1 -1
|
@@ -21,6 +21,7 @@ export declare class ShapesLayer {
|
|
|
21
21
|
private onShapeModified?;
|
|
22
22
|
private onShapeSelected?;
|
|
23
23
|
private onShapeDoubleClicked?;
|
|
24
|
+
private onShapeDeleteRequested?;
|
|
24
25
|
private onToolChange?;
|
|
25
26
|
constructor(options: ShapesLayerOptions);
|
|
26
27
|
setCandles(candles: Candle[]): void;
|
|
@@ -441,6 +441,7 @@ export type ShapesLayerOptions = {
|
|
|
441
441
|
onShapeModified?: (payload: ShapeModifiedPayload) => void;
|
|
442
442
|
onShapeSelected?: (payload: ShapeSelectedPayload | null) => void;
|
|
443
443
|
onShapeDoubleClicked?: (payload: ShapeSelectedPayload) => void;
|
|
444
|
+
onShapeDeleteRequested?: (shapeId: ShapeId) => void;
|
|
444
445
|
onToolChange?: (tool: ShapeToolType | null) => void;
|
|
445
446
|
};
|
|
446
447
|
export type InternalDragState = {
|
|
@@ -205,6 +205,17 @@ export type ChartControllerProps = {
|
|
|
205
205
|
* ```
|
|
206
206
|
*/
|
|
207
207
|
onShapeDoubleClicked?: (payload: ShapeSelectedPayload) => void;
|
|
208
|
+
/**
|
|
209
|
+
* Called when the user presses Delete (or Backspace) while a shape is selected.
|
|
210
|
+
*
|
|
211
|
+
* The parent owns the shape list and must remove the requested shape.
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```ts
|
|
215
|
+
* onShapeDeleteRequested: (shapeId) => removeShape(shapeId)
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
onShapeDeleteRequested?: (shapeId: string) => void;
|
|
208
219
|
/**
|
|
209
220
|
* Called when the chart wants the parent to change the active drawing tool.
|
|
210
221
|
*
|
|
@@ -381,8 +381,8 @@ export type TradeHandlesConfig = {
|
|
|
381
381
|
* ```ts
|
|
382
382
|
* const arrow: ClosedTradeIndicatorArrowConfig = {
|
|
383
383
|
* visible: true,
|
|
384
|
-
* width:
|
|
385
|
-
* height:
|
|
384
|
+
* width: 20,
|
|
385
|
+
* height: 10,
|
|
386
386
|
* headHeightRatio: 0.45,
|
|
387
387
|
* shaftWidthRatio: 6,
|
|
388
388
|
* buyColor: "#22c55e",
|
|
@@ -414,7 +414,7 @@ export type ClosedTradeIndicatorArrowConfig = {
|
|
|
414
414
|
* ```ts
|
|
415
415
|
* const closedTrades: ClosedTradeIndicatorsConfig = {
|
|
416
416
|
* visible: true,
|
|
417
|
-
* arrow: { visible: true, width:
|
|
417
|
+
* arrow: { visible: true, width: 20, height: 10, headHeightRatio: 0.45, shaftWidthRatio: 6, buyColor: "#22c55e", sellColor: "#ef4444", buyBorderColor: "#ffffff", sellBorderColor: "#ffffff", borderWidth: 1, opacity: 1 },
|
|
418
418
|
* connectorLine: { width: 1, color: "#ffffff", opacity: 0.65, style: "dotted", dash: [2, 4] },
|
|
419
419
|
* };
|
|
420
420
|
* ```
|
|
@@ -622,7 +622,7 @@ export type PreviousDayHighLowConfig = {
|
|
|
622
622
|
* volume: { visible: true, bullishColor: "#22c55e", bearishColor: "#ef4444", opacity: 0.35, height: 200, bottomOffset: 0, minBarHeight: 1 },
|
|
623
623
|
* crosshair: { color: "rgba(255,255,255,0.35)", thickness: 1, style: "dashed" },
|
|
624
624
|
* tradeHandles: {} as TradeHandlesConfig,
|
|
625
|
-
* closedTradeIndicators: { visible: true, arrow: { visible: true, width:
|
|
625
|
+
* closedTradeIndicators: { visible: true, arrow: { visible: true, width: 20, height: 10, headHeightRatio: 0.45, shaftWidthRatio: 6, buyColor: "#22c55e", sellColor: "#ef4444", buyBorderColor: "#ffffff", sellBorderColor: "#ffffff", borderWidth: 1, opacity: 1 }, connectorLine: { width: 1, color: "#ffffff", opacity: 0.65, style: "dotted", dash: [2, 4] } },
|
|
626
626
|
* colors: { bullish: "#22c55e", bearish: "#ef4444", background: "#0b1220" },
|
|
627
627
|
* axis: { axisX: { height: 30, backgroundColor: "#0b1220", borderColor: "#1f2937", borderWidth: 1, textColor: "#cbd5e1", font: "12px Arial", textAlign: "center", tickColor: "#334155", tickWidth: 1, tickLength: 4, labelOffsetY: 16, minLabelGap: 16, crosshairLabel: { backgroundColor: "#111827", borderColor: "#111827", borderWidth: 1, textColor: "#ffffff", font: "12px Arial", paddingX: 8, height: 26 } }, axisY: { width: 80, backgroundColor: "#0b1220", borderColor: "#1f2937", borderWidth: 1, textColor: "#cbd5e1", font: "12px Arial", textAlign: "left", tickCount: 12, tickColor: "#334155", tickWidth: 1, tickLength: 4, tickGap: 64, labelOffsetX: 8, crosshairLabel: { backgroundColor: "#111827", borderColor: "#111827", borderWidth: 1, textColor: "#ffffff", font: "12px Arial", paddingX: 8, height: 20 } } },
|
|
628
628
|
* shapes: { trendline: { lineColor: "#22c55e" } },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { forwardRef as
|
|
2
|
-
import { jsx as
|
|
1
|
+
import { forwardRef as Mt, useEffect as st, useImperativeHandle as Rt, useRef as _ } from "react";
|
|
2
|
+
import { jsx as Dt } from "react/jsx-runtime";
|
|
3
3
|
var h = {
|
|
4
4
|
primary: "#7959F7",
|
|
5
5
|
blue: "#2962FF",
|
|
@@ -39,7 +39,7 @@ var h = {
|
|
|
39
39
|
midLineOpacity: 0.9,
|
|
40
40
|
midLineWidth: 0.5,
|
|
41
41
|
midLineStyle: "solid"
|
|
42
|
-
},
|
|
42
|
+
}, At = {
|
|
43
43
|
trendline: {
|
|
44
44
|
lineWidth: 1,
|
|
45
45
|
lineColor: y.blue,
|
|
@@ -134,12 +134,12 @@ var h = {
|
|
|
134
134
|
opacity: 0.9,
|
|
135
135
|
style: "dashed",
|
|
136
136
|
dash: [4, 4]
|
|
137
|
-
},
|
|
137
|
+
}, G = {
|
|
138
138
|
width: 1,
|
|
139
139
|
opacity: 0.9,
|
|
140
140
|
style: "dotted",
|
|
141
141
|
dash: [2, 4]
|
|
142
|
-
},
|
|
142
|
+
}, U = {
|
|
143
143
|
height: 22,
|
|
144
144
|
widthVolume: 60,
|
|
145
145
|
widthPNL: 80,
|
|
@@ -299,7 +299,7 @@ var h = {
|
|
|
299
299
|
},
|
|
300
300
|
slHandle: {
|
|
301
301
|
handle: {
|
|
302
|
-
...
|
|
302
|
+
...U,
|
|
303
303
|
borderColor: h.red,
|
|
304
304
|
borderOpacity: 0.4,
|
|
305
305
|
backgroundColor: h.slBackground,
|
|
@@ -313,7 +313,7 @@ var h = {
|
|
|
313
313
|
},
|
|
314
314
|
tpHandle: {
|
|
315
315
|
handle: {
|
|
316
|
-
...
|
|
316
|
+
...U,
|
|
317
317
|
borderColor: h.green,
|
|
318
318
|
borderOpacity: 0.4,
|
|
319
319
|
backgroundColor: h.tpBackground,
|
|
@@ -326,7 +326,7 @@ var h = {
|
|
|
326
326
|
}
|
|
327
327
|
},
|
|
328
328
|
startPriceHandle: {
|
|
329
|
-
handle: { ...
|
|
329
|
+
handle: { ...U },
|
|
330
330
|
handleLine: {
|
|
331
331
|
width: 1,
|
|
332
332
|
color: h.blue,
|
|
@@ -362,11 +362,11 @@ var h = {
|
|
|
362
362
|
textColor: h.green
|
|
363
363
|
},
|
|
364
364
|
temporarySlLine: {
|
|
365
|
-
...
|
|
365
|
+
...G,
|
|
366
366
|
color: h.red
|
|
367
367
|
},
|
|
368
368
|
temporaryTpLine: {
|
|
369
|
-
...
|
|
369
|
+
...G,
|
|
370
370
|
color: h.green
|
|
371
371
|
}
|
|
372
372
|
}
|
|
@@ -375,8 +375,8 @@ var h = {
|
|
|
375
375
|
visible: !0,
|
|
376
376
|
arrow: {
|
|
377
377
|
visible: !0,
|
|
378
|
-
width:
|
|
379
|
-
height:
|
|
378
|
+
width: 20,
|
|
379
|
+
height: 10,
|
|
380
380
|
headHeightRatio: 0.45,
|
|
381
381
|
shaftWidthRatio: 6,
|
|
382
382
|
buyColor: h.green,
|
|
@@ -387,7 +387,7 @@ var h = {
|
|
|
387
387
|
opacity: 1
|
|
388
388
|
},
|
|
389
389
|
connectorLine: {
|
|
390
|
-
...
|
|
390
|
+
...G,
|
|
391
391
|
color: h.white,
|
|
392
392
|
opacity: 0.65
|
|
393
393
|
}
|
|
@@ -397,7 +397,7 @@ var h = {
|
|
|
397
397
|
bearish: h.red,
|
|
398
398
|
background: h.background
|
|
399
399
|
},
|
|
400
|
-
shapes:
|
|
400
|
+
shapes: At
|
|
401
401
|
}, lt = [
|
|
402
402
|
300 * 1e3,
|
|
403
403
|
900 * 1e3,
|
|
@@ -408,27 +408,27 @@ var h = {
|
|
|
408
408
|
360 * 60 * 1e3,
|
|
409
409
|
720 * 60 * 1e3,
|
|
410
410
|
1440 * 60 * 1e3
|
|
411
|
-
],
|
|
411
|
+
], Xt = (t) => {
|
|
412
412
|
if (t.length < 2) return 900 * 1e3;
|
|
413
413
|
const e = [];
|
|
414
414
|
for (let i = 1; i < Math.min(t.length, 10); i++) e.push(t[i].time - t[i - 1].time);
|
|
415
415
|
return e.sort((i, s) => i - s), e[Math.floor(e.length / 2)];
|
|
416
|
-
},
|
|
416
|
+
}, It = ({ candleSpacing: t, candleTimeframeMs: e, labelWidth: i, minLabelGap: s }) => {
|
|
417
417
|
if (t <= 0 || e <= 0) return lt[0];
|
|
418
418
|
const r = i + s;
|
|
419
419
|
for (const a of lt) if (a / e * t >= r) return a;
|
|
420
420
|
const n = 1440 * 60 * 1e3, o = n / e * t;
|
|
421
421
|
return n * Math.ceil(r / o);
|
|
422
|
-
},
|
|
422
|
+
}, Bt = (t, e) => {
|
|
423
423
|
const i = new Date(t), s = (i.getHours() * 60 + i.getMinutes()) * 60 * 1e3 + i.getSeconds() * 1e3 + i.getMilliseconds();
|
|
424
424
|
return e >= 1440 * 60 * 1e3 ? s === 0 : s % e === 0;
|
|
425
|
-
},
|
|
425
|
+
}, Wt = (t) => {
|
|
426
426
|
const e = new Date(t), i = e.getHours(), s = e.getMinutes();
|
|
427
427
|
return i === 0 && s === 0 ? String(e.getDate()) : `${String(i).padStart(2, "0")}:${String(s).padStart(2, "0")}`;
|
|
428
|
-
},
|
|
428
|
+
}, Ft = (t) => {
|
|
429
429
|
const e = new Date(t), i = e.toLocaleDateString("en-US", { weekday: "short" }), s = e.toLocaleDateString("en-US", { month: "short" });
|
|
430
430
|
return `${i} ${e.getDate()} ${s} ${e.getHours().toString().padStart(2, "0")}.${e.getMinutes().toString().padStart(2, "0")}`;
|
|
431
|
-
},
|
|
431
|
+
}, Yt = class {
|
|
432
432
|
#t;
|
|
433
433
|
#e;
|
|
434
434
|
candles;
|
|
@@ -461,7 +461,7 @@ var h = {
|
|
|
461
461
|
}
|
|
462
462
|
drawCrosshairTimeLabel() {
|
|
463
463
|
if (!this.crosshair.visible || !this.crosshair.candle) return;
|
|
464
|
-
const t = this.#e, e = this.#t.width, i = this.#t.height, s = c.axis.axisX.crosshairLabel, r =
|
|
464
|
+
const t = this.#e, e = this.#t.width, i = this.#t.height, s = c.axis.axisX.crosshairLabel, r = Ft(this.crosshair.candle.time);
|
|
465
465
|
t.save(), t.font = s.font;
|
|
466
466
|
const n = t.measureText(r).width + s.paddingX * 2, o = s.height, a = this.getCrosshairLabelX(n, e), l = Math.max(0, (i - o) / 2);
|
|
467
467
|
t.fillStyle = s.backgroundColor, t.fillRect(a, l, n, o), t.strokeStyle = s.borderColor, t.lineWidth = s.borderWidth, t.strokeRect(a, l, n, o), t.fillStyle = s.textColor, t.textAlign = "center", t.textBaseline = "middle", t.fillText(r, a + n / 2, l + o / 2), t.restore();
|
|
@@ -479,9 +479,9 @@ var h = {
|
|
|
479
479
|
}
|
|
480
480
|
drawAxisLabels() {
|
|
481
481
|
if (!this.viewport) return;
|
|
482
|
-
const t = this.#e, e = c.axis.axisX, i = this.#t.width, s =
|
|
482
|
+
const t = this.#e, e = c.axis.axisX, i = this.#t.width, s = Xt(this.candles);
|
|
483
483
|
t.save(), t.font = e.font, t.fillStyle = e.textColor, t.textAlign = e.textAlign, t.textBaseline = "middle";
|
|
484
|
-
const r = t.measureText("00:00").width, n =
|
|
484
|
+
const r = t.measureText("00:00").width, n = It({
|
|
485
485
|
candleSpacing: this.viewport.candleSpacing,
|
|
486
486
|
candleTimeframeMs: s,
|
|
487
487
|
labelWidth: r,
|
|
@@ -489,9 +489,9 @@ var h = {
|
|
|
489
489
|
}), { startIndex: o, endIndex: a } = this.getVisibleCandleIndexRange(i);
|
|
490
490
|
for (let l = o; l <= a; l += 1) {
|
|
491
491
|
const d = this.getSlotTime(l, s);
|
|
492
|
-
if (d === null || !
|
|
493
|
-
const u = this.getCandleCenterX(l), g =
|
|
494
|
-
this.isLabelOutsideCanvas(u,
|
|
492
|
+
if (d === null || !Bt(d, n)) continue;
|
|
493
|
+
const u = this.getCandleCenterX(l), g = Wt(d), v = t.measureText(g).width;
|
|
494
|
+
this.isLabelOutsideCanvas(u, v, i) || (this.drawTick(u), this.drawLabel(g, u));
|
|
495
495
|
}
|
|
496
496
|
t.restore();
|
|
497
497
|
}
|
|
@@ -535,7 +535,7 @@ var h = {
|
|
|
535
535
|
getCrosshairLabelX(t, e) {
|
|
536
536
|
return Math.max(120, Math.min(e - t, this.crosshair.x - t / 2));
|
|
537
537
|
}
|
|
538
|
-
}, p = (t, e = 5) => Number(t.toFixed(e)),
|
|
538
|
+
}, p = (t, e = 5) => Number(t.toFixed(e)), E = ({ price: t, minPrice: e, priceRange: i, chartHeight: s }) => s - (t - e) / i * s, mt = ({ y: t, minPrice: e, priceRange: i, chartHeight: s }) => e + (1 - t / s) * i, Et = ({ priceRange: t, canvasHeight: e }) => {
|
|
539
539
|
const i = t / (e / c.axis.axisY.tickGap), s = 10 ** Math.floor(Math.log10(i));
|
|
540
540
|
for (const r of [
|
|
541
541
|
1,
|
|
@@ -547,7 +547,7 @@ var h = {
|
|
|
547
547
|
if (n >= i) return n;
|
|
548
548
|
}
|
|
549
549
|
return 10 * s;
|
|
550
|
-
},
|
|
550
|
+
}, Ot = class {
|
|
551
551
|
#t;
|
|
552
552
|
#e;
|
|
553
553
|
viewport = null;
|
|
@@ -614,7 +614,7 @@ var h = {
|
|
|
614
614
|
};
|
|
615
615
|
}
|
|
616
616
|
getPriceY(t, e) {
|
|
617
|
-
return this.viewport ?
|
|
617
|
+
return this.viewport ? E({
|
|
618
618
|
price: t,
|
|
619
619
|
minPrice: this.viewport.minPrice,
|
|
620
620
|
priceRange: this.viewport.priceRange,
|
|
@@ -635,7 +635,7 @@ var h = {
|
|
|
635
635
|
getCrosshairLabelY(t, e) {
|
|
636
636
|
return Math.max(0, Math.min(e - t, this.crosshair.y - t / 2));
|
|
637
637
|
}
|
|
638
|
-
},
|
|
638
|
+
}, zt = class {
|
|
639
639
|
#t;
|
|
640
640
|
#e;
|
|
641
641
|
mouseX = 0;
|
|
@@ -712,7 +712,7 @@ var h = {
|
|
|
712
712
|
drawLine({ ctx: t, fromX: e, fromY: i, toX: s, toY: r }) {
|
|
713
713
|
t.beginPath(), t.moveTo(e, i), t.lineTo(s, r), t.stroke();
|
|
714
714
|
}
|
|
715
|
-
}, F = 60 * 1e3, Ct = 60 * F,
|
|
715
|
+
}, F = 60 * 1e3, Ct = 60 * F, Vt = 24 * Ct, Nt = class {
|
|
716
716
|
#t;
|
|
717
717
|
#e;
|
|
718
718
|
candles;
|
|
@@ -930,7 +930,7 @@ var h = {
|
|
|
930
930
|
}
|
|
931
931
|
getInitialFallbackPercent() {
|
|
932
932
|
const t = this.detectCandleTimeframeMs();
|
|
933
|
-
return t <= F ? 25e-4 : t <= 5 * F ? 35e-4 : t <= 15 * F ? 5e-3 : t <= Ct ? 75e-4 : (t <
|
|
933
|
+
return t <= F ? 25e-4 : t <= 5 * F ? 35e-4 : t <= 15 * F ? 5e-3 : t <= Ct ? 75e-4 : (t < Vt, 0.01);
|
|
934
934
|
}
|
|
935
935
|
detectCandleTimeframeMs() {
|
|
936
936
|
if (this.candles.length < 2) return 15 * F;
|
|
@@ -979,7 +979,7 @@ var h = {
|
|
|
979
979
|
};
|
|
980
980
|
}
|
|
981
981
|
getPriceY(t, e) {
|
|
982
|
-
return
|
|
982
|
+
return E({
|
|
983
983
|
price: t,
|
|
984
984
|
minPrice: this.minPrice,
|
|
985
985
|
priceRange: this.priceRange,
|
|
@@ -992,7 +992,7 @@ var h = {
|
|
|
992
992
|
getAskPriceLineColor(t) {
|
|
993
993
|
return t.close >= t.open ? c.candles.liveAskPriceLine.bullishColor : c.candles.liveAskPriceLine.bearishColor;
|
|
994
994
|
}
|
|
995
|
-
},
|
|
995
|
+
}, _t = class {
|
|
996
996
|
#t;
|
|
997
997
|
#e;
|
|
998
998
|
#r = null;
|
|
@@ -1016,7 +1016,7 @@ var h = {
|
|
|
1016
1016
|
}
|
|
1017
1017
|
#u(t, e) {
|
|
1018
1018
|
if (!this.#r || !this.#e) return;
|
|
1019
|
-
const i = this.#t, s = i.canvas, r =
|
|
1019
|
+
const i = this.#t, s = i.canvas, r = E({
|
|
1020
1020
|
price: t,
|
|
1021
1021
|
minPrice: this.#r.minPrice,
|
|
1022
1022
|
priceRange: this.#r.priceRange,
|
|
@@ -1035,13 +1035,13 @@ var h = {
|
|
|
1035
1035
|
y: (e.clientY - i.top) * r
|
|
1036
1036
|
};
|
|
1037
1037
|
};
|
|
1038
|
-
var
|
|
1038
|
+
var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `shape-${Date.now()}-${Math.random().toString(16).slice(2)}`, q = (t, e) => vt(t, e), ht = (t, e) => ({
|
|
1039
1039
|
time: e.getNearestCandleTimeForX(t.x),
|
|
1040
1040
|
price: e.getPriceForY(t.y)
|
|
1041
1041
|
}), C = (t, e) => ({
|
|
1042
1042
|
x: e.getXForTime(t.time),
|
|
1043
1043
|
y: e.getYForPrice(t.price)
|
|
1044
|
-
}),
|
|
1044
|
+
}), Gt = (t, e) => {
|
|
1045
1045
|
const i = Math.min(t.x, e.x), s = Math.max(t.x, e.x), r = Math.min(t.y, e.y), n = Math.max(t.y, e.y);
|
|
1046
1046
|
return {
|
|
1047
1047
|
left: i,
|
|
@@ -1051,18 +1051,18 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1051
1051
|
width: s - i,
|
|
1052
1052
|
height: n - r
|
|
1053
1053
|
};
|
|
1054
|
-
},
|
|
1054
|
+
}, K = (t, e, i) => Gt(C(t, i), C(e, i)), J = (t, e) => {
|
|
1055
1055
|
const i = t.x - e.x, s = t.y - e.y;
|
|
1056
1056
|
return Math.sqrt(i * i + s * s);
|
|
1057
1057
|
}, yt = (t, e, i) => {
|
|
1058
1058
|
const s = i.x - e.x, r = i.y - e.y, n = s * s + r * r;
|
|
1059
|
-
if (n === 0) return
|
|
1059
|
+
if (n === 0) return J(t, e);
|
|
1060
1060
|
const o = Math.max(0, Math.min(1, ((t.x - e.x) * s + (t.y - e.y) * r) / n));
|
|
1061
|
-
return
|
|
1061
|
+
return J(t, {
|
|
1062
1062
|
x: e.x + o * s,
|
|
1063
1063
|
y: e.y + o * r
|
|
1064
1064
|
});
|
|
1065
|
-
}, wt = (t, e, i = 0) => t.x >= e.left - i && t.x <= e.right + i && t.y >= e.top - i && t.y <= e.bottom + i,
|
|
1065
|
+
}, wt = (t, e, i = 0) => t.x >= e.left - i && t.x <= e.right + i && t.y >= e.top - i && t.y <= e.bottom + i, Ut = (t, e, i = 8) => {
|
|
1066
1066
|
if (!wt(t, e, i)) return !1;
|
|
1067
1067
|
const s = Math.abs(t.x - e.left) <= i, r = Math.abs(t.x - e.right) <= i, n = Math.abs(t.y - e.top) <= i, o = Math.abs(t.y - e.bottom) <= i, a = t.x >= e.left - i && t.x <= e.right + i, l = t.y >= e.top - i && t.y <= e.bottom + i;
|
|
1068
1068
|
return (s || r) && l || (n || o) && a;
|
|
@@ -1074,11 +1074,11 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1074
1074
|
radius: s,
|
|
1075
1075
|
cursor: r,
|
|
1076
1076
|
index: n
|
|
1077
|
-
}), j = (t, e) =>
|
|
1078
|
-
t.strokeStyle =
|
|
1079
|
-
}, Pt = (t, e, i) => !e || i === void 0 || i <= 0 ? !1 : (t.fillStyle =
|
|
1077
|
+
}), j = (t, e) => J(t, e) <= e.radius + 2, V = (t, e = 1) => t === "dashed" ? [e * 6, e * 4] : t === "dotted" ? [e, e * 3] : [], tt = (t, e, i) => {
|
|
1078
|
+
t.strokeStyle = b(e.lineColor, e.lineOpacity), t.lineWidth = i ?? e.lineWidth, t.setLineDash(V(e.lineStyle, t.lineWidth));
|
|
1079
|
+
}, Pt = (t, e, i) => !e || i === void 0 || i <= 0 ? !1 : (t.fillStyle = b(e, i), !0), O = (t) => {
|
|
1080
1080
|
t.setLineDash([]);
|
|
1081
|
-
},
|
|
1081
|
+
}, $t = (t, e, i = {
|
|
1082
1082
|
fillColor: "#ffffff",
|
|
1083
1083
|
borderColor: "#2962ff",
|
|
1084
1084
|
borderThickness: 3
|
|
@@ -1086,15 +1086,15 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1086
1086
|
t.save(), t.beginPath(), t.arc(e.x, e.y, e.radius, 0, Math.PI * 2), t.fillStyle = i.fillColor, t.fill(), t.lineWidth = i.borderThickness, t.strokeStyle = i.borderColor, t.stroke(), t.restore();
|
|
1087
1087
|
}, z = (t, e, i) => {
|
|
1088
1088
|
e.forEach((s) => {
|
|
1089
|
-
|
|
1089
|
+
$t(t, s, i);
|
|
1090
1090
|
});
|
|
1091
|
-
},
|
|
1092
|
-
const i =
|
|
1093
|
-
return t.startsWith("rgba(") ? t : t.startsWith("rgb(") ? t.replace("rgb(", "rgba(").replace(")", `, ${i})`) : t.startsWith("#") ?
|
|
1094
|
-
},
|
|
1091
|
+
}, b = (t, e) => {
|
|
1092
|
+
const i = Kt(e, 0, 1);
|
|
1093
|
+
return t.startsWith("rgba(") ? t : t.startsWith("rgb(") ? t.replace("rgb(", "rgba(").replace(")", `, ${i})`) : t.startsWith("#") ? qt(t, i) : t;
|
|
1094
|
+
}, qt = (t, e) => {
|
|
1095
1095
|
const i = t.replace("#", ""), s = i.length === 3 ? i.split("").map((r) => `${r}${r}`).join("") : i;
|
|
1096
1096
|
return `rgba(${parseInt(s.slice(0, 2), 16)}, ${parseInt(s.slice(2, 4), 16)}, ${parseInt(s.slice(4, 6), 16)}, ${e})`;
|
|
1097
|
-
},
|
|
1097
|
+
}, Kt = (t, e, i) => Math.min(i, Math.max(e, t)), dt = (t, e, i) => e + (t - e) * i, Z = (t, e) => {
|
|
1098
1098
|
if (t.length === 0) return -1;
|
|
1099
1099
|
let i = 0, s = Math.abs(t[0].time - e);
|
|
1100
1100
|
for (let r = 1; r < t.length; r += 1) {
|
|
@@ -1102,7 +1102,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1102
1102
|
n < s && (s = n, i = r);
|
|
1103
1103
|
}
|
|
1104
1104
|
return i;
|
|
1105
|
-
},
|
|
1105
|
+
}, Q = (t) => {
|
|
1106
1106
|
if (t.length < 2) return 900 * 1e3;
|
|
1107
1107
|
const e = [];
|
|
1108
1108
|
for (let i = 1; i < t.length; i += 1) {
|
|
@@ -1110,9 +1110,9 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1110
1110
|
s > 0 && e.push(s);
|
|
1111
1111
|
}
|
|
1112
1112
|
return e.length === 0 ? 900 * 1e3 : e.reduce((i, s) => i + s, 0) / e.length;
|
|
1113
|
-
},
|
|
1113
|
+
}, Jt = (t, e, i) => {
|
|
1114
1114
|
const s = Z(t, e), r = s + i;
|
|
1115
|
-
return s >= 0 && r >= 0 && r < t.length ? t[r].time : e +
|
|
1115
|
+
return s >= 0 && r >= 0 && r < t.length ? t[r].time : e + Q(t) * i;
|
|
1116
1116
|
}, ct = (t) => t instanceof MouseEvent && t.type === "contextmenu" ? !1 : "button" in t && t.type === "pointerdown" ? t.button === 0 : !0, f = {
|
|
1117
1117
|
handleColor: h.background,
|
|
1118
1118
|
handleBorderColor: h.blue,
|
|
@@ -1166,13 +1166,13 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1166
1166
|
fillOpacity: 0.04
|
|
1167
1167
|
};
|
|
1168
1168
|
static draw({ ctx: e, shape: i, converter: s, config: r = I.defaultConfig, selected: n = !1, hovered: o = !1 }) {
|
|
1169
|
-
const [a, l] = i.vertices, d = C(a, s), u = C(l, s), g =
|
|
1169
|
+
const [a, l] = i.vertices, d = C(a, s), u = C(l, s), g = K(a, l, s), v = Math.min(d.x, u.x), w = Math.max(d.x, u.x);
|
|
1170
1170
|
e.save(), Pt(e, r.fillColor, r.fillOpacity) && e.fillRect(g.left, g.top, g.width, g.height);
|
|
1171
|
-
for (const
|
|
1172
|
-
const S = dt(a.price, l.price,
|
|
1173
|
-
e.beginPath(), e.strokeStyle =
|
|
1171
|
+
for (const m of r.levels) {
|
|
1172
|
+
const S = dt(a.price, l.price, m.level), T = s.getYForPrice(S), k = m.lineWidth;
|
|
1173
|
+
e.beginPath(), e.strokeStyle = b(m.color, m.opacity), e.lineWidth = k, e.setLineDash(V(m.lineStyle, k)), e.moveTo(v, T), e.lineTo(w, T), e.stroke(), m.label && (e.setLineDash([]), e.fillStyle = b(m.color, m.opacity), e.font = "11px sans-serif", e.textBaseline = "middle", e.fillText(Number(m.label).toFixed(2).toString(), w + 12, T));
|
|
1174
1174
|
}
|
|
1175
|
-
|
|
1175
|
+
O(e), (n || o) && z(e, I.getHandles(i, s), {
|
|
1176
1176
|
fillColor: f.handleColor,
|
|
1177
1177
|
borderColor: f.handleBorderColor,
|
|
1178
1178
|
borderThickness: f.handleBorderThickness
|
|
@@ -1210,9 +1210,9 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1210
1210
|
static hitTest({ point: e, shape: i, converter: s, tolerance: r = 8, config: n = I.defaultConfig }) {
|
|
1211
1211
|
const [o, a] = i.vertices, l = C(o, s), d = C(a, s), u = Math.min(l.x, d.x), g = Math.max(l.x, d.x);
|
|
1212
1212
|
if (e.x < u - r || e.x > g + r) return !1;
|
|
1213
|
-
for (const
|
|
1214
|
-
const
|
|
1215
|
-
if (Math.abs(e.y -
|
|
1213
|
+
for (const v of n.levels) {
|
|
1214
|
+
const w = dt(o.price, a.price, v.level), m = s.getYForPrice(w);
|
|
1215
|
+
if (Math.abs(e.y - m) <= r) return !0;
|
|
1216
1216
|
}
|
|
1217
1217
|
return !1;
|
|
1218
1218
|
}
|
|
@@ -1246,7 +1246,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1246
1246
|
};
|
|
1247
1247
|
static draw({ ctx: e, shape: i, converter: s, config: r = Y.defaultConfig, selected: n = !1, hovered: o = !1 }) {
|
|
1248
1248
|
const [a, l] = i.vertices, d = C(a, s), u = C(l, s);
|
|
1249
|
-
e.save(),
|
|
1249
|
+
e.save(), tt(e, r), e.beginPath(), e.moveTo(d.x, d.y), e.lineTo(u.x, u.y), e.stroke(), O(e), (n || o) && z(e, Y.getHandles(i, s), {
|
|
1250
1250
|
fillColor: f.handleColor,
|
|
1251
1251
|
borderColor: f.handleBorderColor,
|
|
1252
1252
|
borderThickness: f.handleBorderThickness
|
|
@@ -1318,9 +1318,9 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1318
1318
|
static draw({ ctx: e, shape: i, converter: s, config: r = B.defaultConfig, selected: n = !1, hovered: o = !1 }) {
|
|
1319
1319
|
const a = i.vertices.map((l) => C(l, s));
|
|
1320
1320
|
if (a.length !== 0) {
|
|
1321
|
-
e.save(),
|
|
1321
|
+
e.save(), tt(e, r), e.beginPath(), e.moveTo(a[0].x, a[0].y);
|
|
1322
1322
|
for (let l = 1; l < a.length; l += 1) e.lineTo(a[l].x, a[l].y);
|
|
1323
|
-
e.stroke(),
|
|
1323
|
+
e.stroke(), O(e), a.length >= 2 && B.drawEndArrow({
|
|
1324
1324
|
ctx: e,
|
|
1325
1325
|
previousPoint: a[a.length - 2],
|
|
1326
1326
|
endPoint: a[a.length - 1],
|
|
@@ -1384,7 +1384,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1384
1384
|
}
|
|
1385
1385
|
static drawEndArrow({ ctx: e, previousPoint: i, endPoint: s, color: r, opacity: n, lineWidth: o }) {
|
|
1386
1386
|
const a = Math.atan2(s.y - i.y, s.x - i.x), l = 12, d = Math.PI / 7;
|
|
1387
|
-
e.save(), e.beginPath(), e.strokeStyle =
|
|
1387
|
+
e.save(), e.beginPath(), e.strokeStyle = b(r, n), e.fillStyle = b(r, n), e.lineWidth = o, e.setLineDash([]), e.moveTo(s.x, s.y), e.lineTo(s.x - l * Math.cos(a - d), s.y - l * Math.sin(a - d)), e.lineTo(s.x - l * Math.cos(a + d), s.y - l * Math.sin(a + d)), e.closePath(), e.fill(), e.stroke(), e.restore();
|
|
1388
1388
|
}
|
|
1389
1389
|
}, D = class W {
|
|
1390
1390
|
static defaultConfig = {
|
|
@@ -1400,8 +1400,8 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1400
1400
|
textFontSize: 20
|
|
1401
1401
|
};
|
|
1402
1402
|
static draw({ ctx: e, shape: i, converter: s, config: r = W.defaultConfig, selected: n = !1, hovered: o = !1 }) {
|
|
1403
|
-
const [a, l] = i.vertices, d =
|
|
1404
|
-
e.save(), Pt(e, r.fillColor, r.fillOpacity) && e.fillRect(d.left, d.top, d.width, d.height),
|
|
1403
|
+
const [a, l] = i.vertices, d = K(a, l, s);
|
|
1404
|
+
e.save(), Pt(e, r.fillColor, r.fillOpacity) && e.fillRect(d.left, d.top, d.width, d.height), tt(e, r), e.strokeRect(d.left, d.top, d.width, d.height), O(e), W.drawText(e, d, i.text, r), (n || o) && z(e, W.getHandles(i, s), {
|
|
1405
1405
|
fillColor: f.handleColor,
|
|
1406
1406
|
borderColor: f.handleBorderColor,
|
|
1407
1407
|
borderThickness: f.handleBorderThickness
|
|
@@ -1438,7 +1438,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1438
1438
|
}
|
|
1439
1439
|
static hitTest({ point: e, shape: i, converter: s, tolerance: r = 8 }) {
|
|
1440
1440
|
const [n, o] = i.vertices;
|
|
1441
|
-
return
|
|
1441
|
+
return Ut(e, K(n, o, s), r);
|
|
1442
1442
|
}
|
|
1443
1443
|
static move(e, i) {
|
|
1444
1444
|
return {
|
|
@@ -1477,10 +1477,10 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1477
1477
|
"USOIL",
|
|
1478
1478
|
"UKOIL",
|
|
1479
1479
|
"XAGUSD"
|
|
1480
|
-
], Tt = (t) => bt.some((e) => t.includes(e.slice(3))) ? 0.01 : xt.includes(t) ? 1 : St.includes(t) ? 0.01 : 1e-4,
|
|
1481
|
-
const n = r.split(".")[0], o = Tt(n), a =
|
|
1480
|
+
], Tt = (t) => bt.some((e) => t.includes(e.slice(3))) ? 0.01 : xt.includes(t) ? 1 : St.includes(t) ? 0.01 : 1e-4, jt = (t, e) => bt.includes(t) ? e * 6.33806 : xt.includes(t) ? e * 1 : (St.includes(t), e * 10), ut = (t, e, i, s, r) => {
|
|
1481
|
+
const n = r.split(".")[0], o = Tt(n), a = jt(n, s);
|
|
1482
1482
|
return (t === "buy" ? i - e : e - i) / o * a;
|
|
1483
|
-
}, H = class
|
|
1483
|
+
}, H = class P {
|
|
1484
1484
|
static defaultLongConfig = {
|
|
1485
1485
|
defaultWidthCandles: 10,
|
|
1486
1486
|
defaultStopLossPercent: 0.25,
|
|
@@ -1498,24 +1498,24 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1498
1498
|
midLineWidth: 1,
|
|
1499
1499
|
midLineStyle: "dashed"
|
|
1500
1500
|
};
|
|
1501
|
-
static defaultShortConfig = { ...
|
|
1502
|
-
static draw({ ctx: e, activeSymbol: i, shape: s, converter: r, config: n = s.type === "longPosition" ?
|
|
1503
|
-
const l =
|
|
1504
|
-
e.save(), e.fillStyle =
|
|
1501
|
+
static defaultShortConfig = { ...P.defaultLongConfig };
|
|
1502
|
+
static draw({ ctx: e, activeSymbol: i, shape: s, converter: r, config: n = s.type === "longPosition" ? P.defaultLongConfig : P.defaultShortConfig, selected: o = !1, hovered: a = !1 }) {
|
|
1503
|
+
const l = P.getGeometry(s, r);
|
|
1504
|
+
e.save(), e.fillStyle = b(n.profitFillColor, n.profitFillOpacity), e.fillRect(l.profitBox.left, l.profitBox.top, l.profitBox.width, l.profitBox.height), e.fillStyle = b(n.lossFillColor, n.lossFillOpacity), e.fillRect(l.lossBox.left, l.lossBox.top, l.lossBox.width, l.lossBox.height);
|
|
1505
1505
|
const d = n.borderWidth;
|
|
1506
|
-
e.strokeStyle =
|
|
1506
|
+
e.strokeStyle = b(n.borderColor, n.borderOpacity), e.lineWidth = d, e.setLineDash(V(n.borderStyle, d)), e.strokeRect(l.box.left, l.box.top, l.box.width, l.box.height), e.beginPath(), e.strokeStyle = b(n.midLineColor, n.midLineOpacity), e.lineWidth = n.midLineWidth, e.setLineDash(V(n.midLineStyle, n.midLineWidth)), e.moveTo(l.box.left, l.entryY), e.lineTo(l.box.right, l.entryY), e.stroke(), O(e), P.drawLabels({
|
|
1507
1507
|
ctx: e,
|
|
1508
1508
|
activeSymbol: i,
|
|
1509
1509
|
shape: s,
|
|
1510
1510
|
geometry: l,
|
|
1511
1511
|
config: n
|
|
1512
|
-
}), (o || a) && z(e,
|
|
1512
|
+
}), (o || a) && z(e, P.getHandles(s, r), {
|
|
1513
1513
|
fillColor: f.handleColor,
|
|
1514
1514
|
borderColor: f.handleBorderColor,
|
|
1515
1515
|
borderThickness: f.handleBorderThickness
|
|
1516
1516
|
}), e.restore();
|
|
1517
1517
|
}
|
|
1518
|
-
static createFromVertex({ id: e, type: i, entry: s, converter: r, config: n = i === "longPosition" ?
|
|
1518
|
+
static createFromVertex({ id: e, type: i, entry: s, converter: r, config: n = i === "longPosition" ? P.defaultLongConfig : P.defaultShortConfig }) {
|
|
1519
1519
|
const o = r.getTimeForX(r.getXForTime(s.time) + r.getCandleWidth() * n.defaultWidthCandles), a = n.defaultStopLossPercent;
|
|
1520
1520
|
return {
|
|
1521
1521
|
id: e,
|
|
@@ -1527,13 +1527,13 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1527
1527
|
};
|
|
1528
1528
|
}
|
|
1529
1529
|
static getGeometry(e, i) {
|
|
1530
|
-
const s = C(e.entry, i), r = i.getXForTime(e.endTime), n = Math.min(s.x, r), o = Math.max(s.x, r), a = e.type === "longPosition", l = a ? e.takeProfitPercent : e.stopLossPercent, d = a ? e.stopLossPercent : e.takeProfitPercent, u = e.entry.price * (1 + l / 100), g = e.entry.price * (1 - d / 100),
|
|
1530
|
+
const s = C(e.entry, i), r = i.getXForTime(e.endTime), n = Math.min(s.x, r), o = Math.max(s.x, r), a = e.type === "longPosition", l = a ? e.takeProfitPercent : e.stopLossPercent, d = a ? e.stopLossPercent : e.takeProfitPercent, u = e.entry.price * (1 + l / 100), g = e.entry.price * (1 - d / 100), v = i.getYForPrice(u), w = i.getYForPrice(g), m = Math.min(v, w, s.y), S = Math.max(v, w, s.y), T = {
|
|
1531
1531
|
left: n,
|
|
1532
|
-
top:
|
|
1532
|
+
top: m,
|
|
1533
1533
|
right: o,
|
|
1534
1534
|
bottom: s.y,
|
|
1535
1535
|
width: o - n,
|
|
1536
|
-
height: Math.abs(s.y -
|
|
1536
|
+
height: Math.abs(s.y - m)
|
|
1537
1537
|
}, k = {
|
|
1538
1538
|
left: n,
|
|
1539
1539
|
top: s.y,
|
|
@@ -1550,18 +1550,18 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1550
1550
|
lowerPrice: g,
|
|
1551
1551
|
box: {
|
|
1552
1552
|
left: n,
|
|
1553
|
-
top:
|
|
1553
|
+
top: m,
|
|
1554
1554
|
right: o,
|
|
1555
1555
|
bottom: S,
|
|
1556
1556
|
width: o - n,
|
|
1557
|
-
height: S -
|
|
1557
|
+
height: S - m
|
|
1558
1558
|
},
|
|
1559
1559
|
profitBox: a ? T : k,
|
|
1560
1560
|
lossBox: a ? k : T
|
|
1561
1561
|
};
|
|
1562
1562
|
}
|
|
1563
1563
|
static getHandles(e, i) {
|
|
1564
|
-
const s =
|
|
1564
|
+
const s = P.getGeometry(e, i);
|
|
1565
1565
|
return [
|
|
1566
1566
|
x({
|
|
1567
1567
|
shapeId: e.id,
|
|
@@ -1606,7 +1606,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1606
1606
|
];
|
|
1607
1607
|
}
|
|
1608
1608
|
static hitTest({ point: e, shape: i, converter: s }) {
|
|
1609
|
-
return
|
|
1609
|
+
return P.getHandles(i, s).some((r) => j(e, r)) ? !0 : wt(e, P.getGeometry(i, s).box);
|
|
1610
1610
|
}
|
|
1611
1611
|
static move(e, i) {
|
|
1612
1612
|
return {
|
|
@@ -1628,7 +1628,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1628
1628
|
} : i === "end" ? {
|
|
1629
1629
|
...e,
|
|
1630
1630
|
endTime: s.time
|
|
1631
|
-
} : i === "upperHeight" ?
|
|
1631
|
+
} : i === "upperHeight" ? P.resizeUpperHeight(e, s.price) : i === "lowerHeight" ? P.resizeLowerHeight(e, s.price) : {
|
|
1632
1632
|
...e,
|
|
1633
1633
|
endTime: r.getTimeForX(r.getXForTime(e.endTime))
|
|
1634
1634
|
};
|
|
@@ -1656,13 +1656,13 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1656
1656
|
static drawLabels({ ctx: e, activeSymbol: i, shape: s, geometry: r, config: n }) {
|
|
1657
1657
|
e.save(), e.font = "11px sans-serif", e.textBaseline = "middle";
|
|
1658
1658
|
const o = s.type, a = Tt(i), l = s.entry.price * (s.takeProfitPercent / 100) / a, d = s.entry.price * (s.stopLossPercent / 100) / a, u = r.box.left + 6, g = l / d;
|
|
1659
|
-
e.fillStyle =
|
|
1660
|
-
const
|
|
1661
|
-
e.fillText(`${l.toFixed(2)} (${g.toFixed(2)})`, u,
|
|
1662
|
-
const
|
|
1663
|
-
e.fillText(d.toFixed(1), u,
|
|
1659
|
+
e.fillStyle = b(n.profitFillColor, 0.95);
|
|
1660
|
+
const v = o === "longPosition" ? r.profitBox.top + r.profitBox.height / 10 : r.profitBox.bottom - r.profitBox.height / 10;
|
|
1661
|
+
e.fillText(`${l.toFixed(2)} (${g.toFixed(2)})`, u, v), e.fillStyle = b(n.lossFillColor, 0.95);
|
|
1662
|
+
const w = o === "shortPosition" ? r.lossBox.top + r.lossBox.height / 10 : r.lossBox.bottom - r.lossBox.height / 10;
|
|
1663
|
+
e.fillText(d.toFixed(1), u, w);
|
|
1664
1664
|
}
|
|
1665
|
-
},
|
|
1665
|
+
}, Zt = class {
|
|
1666
1666
|
canvas;
|
|
1667
1667
|
ctx;
|
|
1668
1668
|
activeSymbol;
|
|
@@ -1682,12 +1682,13 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1682
1682
|
onShapeModified;
|
|
1683
1683
|
onShapeSelected;
|
|
1684
1684
|
onShapeDoubleClicked;
|
|
1685
|
+
onShapeDeleteRequested;
|
|
1685
1686
|
onToolChange;
|
|
1686
1687
|
constructor(t) {
|
|
1687
1688
|
this.canvas = t.canvas;
|
|
1688
1689
|
const e = this.canvas.getContext("2d");
|
|
1689
1690
|
if (!e) throw new Error("Failed to get 2d context for ShapesLayer");
|
|
1690
|
-
this.ctx = e, this.activeSymbol = t.activeSymbol, this.candles = t.candles, this.shapes = t.shapes, this.activeTool = t.activeTool ?? null, this.config = this.mergeConfig(t.config), this.onShapeAdded = t.onShapeAdded, this.onShapeModified = t.onShapeModified, this.onShapeSelected = t.onShapeSelected, this.onShapeDoubleClicked = t.onShapeDoubleClicked, this.onToolChange = t.onToolChange;
|
|
1691
|
+
this.ctx = e, this.activeSymbol = t.activeSymbol, this.candles = t.candles, this.shapes = t.shapes, this.activeTool = t.activeTool ?? null, this.config = this.mergeConfig(t.config), this.onShapeAdded = t.onShapeAdded, this.onShapeModified = t.onShapeModified, this.onShapeSelected = t.onShapeSelected, this.onShapeDoubleClicked = t.onShapeDoubleClicked, this.onShapeDeleteRequested = t.onShapeDeleteRequested, this.onToolChange = t.onToolChange;
|
|
1691
1692
|
}
|
|
1692
1693
|
setCandles(t) {
|
|
1693
1694
|
this.candles = t;
|
|
@@ -1728,6 +1729,8 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1728
1729
|
return this.draft = null, this.setActiveToolAndEmit(null), !0;
|
|
1729
1730
|
if (t.key === "Escape" && this.selectedShapeId)
|
|
1730
1731
|
return this.setSelectedShapeId(null), !0;
|
|
1732
|
+
if ((t.key === "Delete" || t.key === "Backspace") && this.selectedShapeId && !this.draft && this.onShapeDeleteRequested)
|
|
1733
|
+
return this.onShapeDeleteRequested(this.selectedShapeId), !0;
|
|
1731
1734
|
if (this.selectedShapeId && !this.draft && !this.activeTool && (t.key === "ArrowLeft" || t.key === "ArrowRight" || t.key === "ArrowUp" || t.key === "ArrowDown")) {
|
|
1732
1735
|
const e = this.shapes.find((i) => i.id === this.selectedShapeId);
|
|
1733
1736
|
if (e) {
|
|
@@ -1738,7 +1741,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1738
1741
|
return !1;
|
|
1739
1742
|
}
|
|
1740
1743
|
getArrowKeyDelta(t) {
|
|
1741
|
-
const e =
|
|
1744
|
+
const e = Q(this.candles);
|
|
1742
1745
|
if (t === "ArrowLeft") return {
|
|
1743
1746
|
time: -e,
|
|
1744
1747
|
price: 0
|
|
@@ -1757,7 +1760,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1757
1760
|
};
|
|
1758
1761
|
}
|
|
1759
1762
|
handlePointerDown(t) {
|
|
1760
|
-
const e =
|
|
1763
|
+
const e = q(this.canvas, t), i = ht(e, this.getConverter());
|
|
1761
1764
|
if (this.activeTool)
|
|
1762
1765
|
return ct(t) && this.handleToolPointerDown({
|
|
1763
1766
|
point: e,
|
|
@@ -1805,7 +1808,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1805
1808
|
return this.setSelectedShapeId(null), this.hoveredShapeId = null, this.canvas.style.cursor = "crosshair", !1;
|
|
1806
1809
|
}
|
|
1807
1810
|
handlePointerMove(t) {
|
|
1808
|
-
const e =
|
|
1811
|
+
const e = q(this.canvas, t), i = ht(e, this.getConverter());
|
|
1809
1812
|
if (this.draft)
|
|
1810
1813
|
return this.updateDraftPreview(i), !0;
|
|
1811
1814
|
if (this.dragState) {
|
|
@@ -1827,7 +1830,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1827
1830
|
}
|
|
1828
1831
|
handleDoubleClick(t) {
|
|
1829
1832
|
if (!this.onShapeDoubleClicked) return !1;
|
|
1830
|
-
const e =
|
|
1833
|
+
const e = q(this.canvas, t), i = this.findShapeAtPoint(e);
|
|
1831
1834
|
return i ? (this.onShapeDoubleClicked(this.createShapeSelectedPayload(i)), !0) : !1;
|
|
1832
1835
|
}
|
|
1833
1836
|
checkTouchDoubleTap(t, e) {
|
|
@@ -1863,7 +1866,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1863
1866
|
if (!this.draft || this.draft.type !== t) {
|
|
1864
1867
|
this.draft = {
|
|
1865
1868
|
type: t,
|
|
1866
|
-
id:
|
|
1869
|
+
id: $(),
|
|
1867
1870
|
vertices: [e, e]
|
|
1868
1871
|
};
|
|
1869
1872
|
return;
|
|
@@ -1879,7 +1882,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1879
1882
|
if (!this.draft || this.draft.type !== "path") {
|
|
1880
1883
|
this.draft = {
|
|
1881
1884
|
type: "path",
|
|
1882
|
-
id:
|
|
1885
|
+
id: $(),
|
|
1883
1886
|
vertices: [t],
|
|
1884
1887
|
previewVertex: null
|
|
1885
1888
|
};
|
|
@@ -1900,7 +1903,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
1900
1903
|
}
|
|
1901
1904
|
addPositionShape(t, e) {
|
|
1902
1905
|
const i = this.getConverter(), s = t === "longPosition" ? this.config.longPosition : this.config.shortPosition, r = H.createFromVertex({
|
|
1903
|
-
id:
|
|
1906
|
+
id: $(),
|
|
1904
1907
|
type: t,
|
|
1905
1908
|
entry: e,
|
|
1906
1909
|
converter: i,
|
|
@@ -2204,7 +2207,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
2204
2207
|
getXForTime(t) {
|
|
2205
2208
|
if (!this.viewport || this.candles.length === 0) return 0;
|
|
2206
2209
|
if (t > this.candles[this.candles.length - 1].time) {
|
|
2207
|
-
const i =
|
|
2210
|
+
const i = Q(this.candles);
|
|
2208
2211
|
return (t - this.candles[0].time) / i * this.viewport.candleSpacing + this.viewport.offsetX + this.viewport.candleWidth / 2;
|
|
2209
2212
|
}
|
|
2210
2213
|
const e = Z(this.candles, t);
|
|
@@ -2213,10 +2216,10 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
2213
2216
|
getTimeForX(t) {
|
|
2214
2217
|
if (!this.viewport) return Date.now();
|
|
2215
2218
|
const e = Math.round((t - this.viewport.offsetX - this.viewport.candleWidth / 2) / this.viewport.candleSpacing);
|
|
2216
|
-
return e >= 0 && e < this.candles.length ? this.candles[e].time : this.candles.length === 0 ? Date.now() :
|
|
2219
|
+
return e >= 0 && e < this.candles.length ? this.candles[e].time : this.candles.length === 0 ? Date.now() : Jt(this.candles, this.candles[0].time, e);
|
|
2217
2220
|
}
|
|
2218
2221
|
getYForPrice(t) {
|
|
2219
|
-
return this.viewport ?
|
|
2222
|
+
return this.viewport ? E({
|
|
2220
2223
|
price: t,
|
|
2221
2224
|
minPrice: this.viewport.minPrice,
|
|
2222
2225
|
priceRange: this.viewport.priceRange,
|
|
@@ -2263,7 +2266,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
2263
2266
|
}
|
|
2264
2267
|
};
|
|
2265
2268
|
}
|
|
2266
|
-
},
|
|
2269
|
+
}, Qt = class {
|
|
2267
2270
|
#t;
|
|
2268
2271
|
#e;
|
|
2269
2272
|
isDragging;
|
|
@@ -2313,7 +2316,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
2313
2316
|
this.drawTemporaryProtectionDrag();
|
|
2314
2317
|
}
|
|
2315
2318
|
createHitBox = ({ price: t, trade: e, type: i, x: s, y: r, width: n, height: o, viewport: a }) => {
|
|
2316
|
-
const { showCloseSection: l, widthClose: d } = this.getHandleStyleConfig(i).handle, u = l ? d : 0, g = n - u,
|
|
2319
|
+
const { showCloseSection: l, widthClose: d } = this.getHandleStyleConfig(i).handle, u = l ? d : 0, g = n - u, v = s + n - u;
|
|
2317
2320
|
return {
|
|
2318
2321
|
kind: "existingHandle",
|
|
2319
2322
|
price: p(t),
|
|
@@ -2331,7 +2334,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
2331
2334
|
height: o
|
|
2332
2335
|
},
|
|
2333
2336
|
closeButtonArea: {
|
|
2334
|
-
x:
|
|
2337
|
+
x: v,
|
|
2335
2338
|
y: r,
|
|
2336
2339
|
width: u,
|
|
2337
2340
|
height: o
|
|
@@ -2447,12 +2450,12 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
2447
2450
|
});
|
|
2448
2451
|
let g = e;
|
|
2449
2452
|
l.save(), l.font = d.font, l.textBaseline = "middle", l.globalAlpha = d.textOpacity;
|
|
2450
|
-
for (const
|
|
2451
|
-
|
|
2452
|
-
section:
|
|
2453
|
+
for (const v of u)
|
|
2454
|
+
v.visible && (this.drawHandleSectionLabel({
|
|
2455
|
+
section: v,
|
|
2453
2456
|
currentX: g,
|
|
2454
2457
|
y: a
|
|
2455
|
-
}), g +=
|
|
2458
|
+
}), g += v.width, g < e + s && this.drawHandleSectionDivider({
|
|
2456
2459
|
x: g,
|
|
2457
2460
|
y1: i + 4,
|
|
2458
2461
|
y2: i + r - 4,
|
|
@@ -2571,10 +2574,10 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
2571
2574
|
}
|
|
2572
2575
|
drawClosedTradeArrow({ x: t, y: e, type: i, width: s, height: r, config: n }) {
|
|
2573
2576
|
if (s <= 0 || r <= 0) return;
|
|
2574
|
-
const o = this.#e, a = i === "buy", l = a ? n.buyColor : n.sellColor, d = a ? n.buyBorderColor : n.sellBorderColor, u = a ? 1 : -1, g =
|
|
2575
|
-
o.beginPath(), o.moveTo(
|
|
2577
|
+
const o = this.#e, a = i === "buy", l = a ? n.buyColor : n.sellColor, d = a ? n.buyBorderColor : n.sellBorderColor, u = a ? 1 : -1, g = Math.max(1, s / n.shaftWidthRatio), v = g + n.borderWidth * 2, w = t, m = e + u * (v / 2), S = t, T = m + u * r, k = r * n.headHeightRatio, et = s / 2, Ht = w - et, kt = w + et, N = m + u * k, it = () => {
|
|
2578
|
+
o.beginPath(), o.moveTo(S, T), o.lineTo(w, N), o.moveTo(w, m), o.lineTo(Ht, N), o.moveTo(w, m), o.lineTo(kt, N), o.stroke();
|
|
2576
2579
|
};
|
|
2577
|
-
o.save(), o.globalAlpha = n.opacity, o.lineCap = "round", o.lineJoin = "round", o.strokeStyle = d, o.lineWidth =
|
|
2580
|
+
o.save(), o.globalAlpha = n.opacity, o.lineCap = "round", o.lineJoin = "round", o.strokeStyle = d, o.lineWidth = v, it(), o.strokeStyle = l, o.lineWidth = g, it(), o.restore();
|
|
2578
2581
|
}
|
|
2579
2582
|
getTimeX(t) {
|
|
2580
2583
|
if (!this.viewport || this.candles.length === 0 || !Number.isFinite(t)) return null;
|
|
@@ -2634,7 +2637,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
2634
2637
|
};
|
|
2635
2638
|
}
|
|
2636
2639
|
getPriceY(t, e) {
|
|
2637
|
-
return
|
|
2640
|
+
return E({
|
|
2638
2641
|
price: t,
|
|
2639
2642
|
minPrice: e.minPrice,
|
|
2640
2643
|
priceRange: e.priceRange,
|
|
@@ -2902,11 +2905,11 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
2902
2905
|
formatPnlLabel(t) {
|
|
2903
2906
|
return `${t >= 0 ? "+" : ""}${t.toFixed(2)}`;
|
|
2904
2907
|
}
|
|
2905
|
-
},
|
|
2908
|
+
}, te = [
|
|
2906
2909
|
"pointerdown",
|
|
2907
2910
|
"pointermove",
|
|
2908
2911
|
"pointerup"
|
|
2909
|
-
],
|
|
2912
|
+
], ee = class {
|
|
2910
2913
|
#t;
|
|
2911
2914
|
#e;
|
|
2912
2915
|
#r;
|
|
@@ -2938,7 +2941,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
2938
2941
|
return i ? this.handleHoveredHitbox(t, i, e) : (this.resetCursorIfIdle(), !1);
|
|
2939
2942
|
}
|
|
2940
2943
|
isSupportedEventType(t) {
|
|
2941
|
-
return
|
|
2944
|
+
return te.includes(t);
|
|
2942
2945
|
}
|
|
2943
2946
|
getCanvasMousePoint(t) {
|
|
2944
2947
|
const e = this.#t.getBoundingClientRect(), i = this.#t.width / e.width, s = this.#t.height / e.height;
|
|
@@ -3070,7 +3073,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
3070
3073
|
consumeEvent(t) {
|
|
3071
3074
|
t.stopPropagation(), t.preventDefault();
|
|
3072
3075
|
}
|
|
3073
|
-
},
|
|
3076
|
+
}, ie = class {
|
|
3074
3077
|
#t;
|
|
3075
3078
|
#e;
|
|
3076
3079
|
candles;
|
|
@@ -3159,7 +3162,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
3159
3162
|
}, A = (t) => {
|
|
3160
3163
|
const e = document.createElement("canvas");
|
|
3161
3164
|
return e.className = t, e;
|
|
3162
|
-
},
|
|
3165
|
+
}, se = (t, e) => {
|
|
3163
3166
|
const i = document.createElement("div");
|
|
3164
3167
|
i.className = "trading-reload-chart", i.style.backgroundColor = e, i.tabIndex = 0;
|
|
3165
3168
|
const s = document.createElement("div");
|
|
@@ -3198,7 +3201,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
3198
3201
|
}, ft = (t) => Lt(c, t ?? {}), pt = (t, e) => e === void 0 || t.time >= 1e12 ? t : {
|
|
3199
3202
|
...t,
|
|
3200
3203
|
time: t.time * 1e3 - e
|
|
3201
|
-
},
|
|
3204
|
+
}, re = 12, ne = class {
|
|
3202
3205
|
#t;
|
|
3203
3206
|
#e;
|
|
3204
3207
|
#r;
|
|
@@ -3222,7 +3225,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
3222
3225
|
#P = null;
|
|
3223
3226
|
#b = null;
|
|
3224
3227
|
constructor(t, e) {
|
|
3225
|
-
this.#t = t, this.#e = e, this.#r = ft(e.config), this.#i =
|
|
3228
|
+
this.#t = t, this.#e = e, this.#r = ft(e.config), this.#i = se(t, this.#r.colors.background), this.#h = new zt({
|
|
3226
3229
|
canvas: this.#i.overlayCanvas,
|
|
3227
3230
|
crosshairColor: this.#r.crosshair.color,
|
|
3228
3231
|
crosshairThickness: this.#r.crosshair.thickness,
|
|
@@ -3231,7 +3234,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
3231
3234
|
}
|
|
3232
3235
|
updateProps(t) {
|
|
3233
3236
|
const e = this.#e.activeShapeTool;
|
|
3234
|
-
this.#e = t, this.#r = ft(t.config), this.#i && (this.#i.root.style.backgroundColor = this.#r.colors.background, this.#i.layout.style.setProperty("--axis-x-height", `${this.#r.axis.axisX.height}px`)), !this.#m && t.candles.length > 0 && this.#I(t.candles), this.#s && (t.activeShapeTool !== e && this.#Y(t.activeShapeTool), this.#l?.setConfig(this.#r.shapes), this.#l?.setShapes(t.shapes), this.#l?.setActiveTool(t.activeShapeTool), this.#g?.setConfig(this.#r.shapes.previousDayHighLow ?? null), this.#g?.setPreviousDay(t.previousDay), this.#n?.setClosedTrades(t.closedTrades ?? []), this.#x(), this.#
|
|
3237
|
+
this.#e = t, this.#r = ft(t.config), this.#i && (this.#i.root.style.backgroundColor = this.#r.colors.background, this.#i.layout.style.setProperty("--axis-x-height", `${this.#r.axis.axisX.height}px`)), !this.#m && t.candles.length > 0 && this.#I(t.candles), this.#s && (t.activeShapeTool !== e && this.#Y(t.activeShapeTool), this.#l?.setConfig(this.#r.shapes), this.#l?.setShapes(t.shapes), this.#l?.setActiveTool(t.activeShapeTool), this.#g?.setConfig(this.#r.shapes.previousDayHighLow ?? null), this.#g?.setPreviousDay(t.previousDay), this.#n?.setClosedTrades(t.closedTrades ?? []), this.#x(), this.#O(), this.#c());
|
|
3235
3238
|
}
|
|
3236
3239
|
resetChartView() {
|
|
3237
3240
|
this.#s?.resetView(), this.#c();
|
|
@@ -3242,7 +3245,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
3242
3245
|
#I(t) {
|
|
3243
3246
|
if (!this.#i || this.#m) return;
|
|
3244
3247
|
const e = t.map((s) => pt(s, this.#e.brokerTimezoneOffsetMs));
|
|
3245
|
-
this.#u = new
|
|
3248
|
+
this.#u = new ie({
|
|
3246
3249
|
canvas: this.#i.volumeCanvas,
|
|
3247
3250
|
candles: e,
|
|
3248
3251
|
bullishColor: this.#r.volume.bullishColor,
|
|
@@ -3251,7 +3254,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
3251
3254
|
height: this.#r.volume.height,
|
|
3252
3255
|
bottomOffset: this.#r.volume.bottomOffset,
|
|
3253
3256
|
minBarHeight: this.#r.volume.minBarHeight
|
|
3254
|
-
}), this.#s = new
|
|
3257
|
+
}), this.#s = new Nt({
|
|
3255
3258
|
canvas: this.#i.candleCanvas,
|
|
3256
3259
|
candles: e,
|
|
3257
3260
|
baseCandleWidth: this.#r.candles.defaultWidth,
|
|
@@ -3261,7 +3264,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
3261
3264
|
autoFollowLatestCandle: this.#r.candles.autoFollowLatestCandle,
|
|
3262
3265
|
autoFollowThresholdCandles: this.#r.candles.autoFollowThresholdCandles,
|
|
3263
3266
|
rightOffsetCandles: this.#r.candles.rightOffsetCandles
|
|
3264
|
-
}), this.#l = new
|
|
3267
|
+
}), this.#l = new Zt({
|
|
3265
3268
|
canvas: this.#i.shapesCanvas,
|
|
3266
3269
|
activeSymbol: this.#e.activeSymbol,
|
|
3267
3270
|
candles: e,
|
|
@@ -3280,18 +3283,21 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
3280
3283
|
onShapeDoubleClicked: (s) => {
|
|
3281
3284
|
this.#e.onShapeDoubleClicked?.(s);
|
|
3282
3285
|
},
|
|
3286
|
+
onShapeDeleteRequested: (s) => {
|
|
3287
|
+
this.#e.onShapeDeleteRequested?.(s);
|
|
3288
|
+
},
|
|
3283
3289
|
onToolChange: (s) => {
|
|
3284
3290
|
this.#e.onActiveShapeToolChange?.(s);
|
|
3285
3291
|
}
|
|
3286
3292
|
});
|
|
3287
3293
|
const i = this.#i.shapesCanvas.getContext("2d");
|
|
3288
|
-
i && (this.#g = new
|
|
3294
|
+
i && (this.#g = new _t({
|
|
3289
3295
|
ctx: i,
|
|
3290
3296
|
config: this.#r.shapes.previousDayHighLow ?? null
|
|
3291
|
-
}), this.#g.setPreviousDay(this.#e.previousDay)), this.#n = new
|
|
3297
|
+
}), this.#g.setPreviousDay(this.#e.previousDay)), this.#n = new Qt({ canvas: this.#i.tradesCanvas }), this.#n.setCandles(e), this.#n.setClosedTrades(this.#e.closedTrades ?? []), this.#x(), this.#o = new Yt({
|
|
3292
3298
|
canvas: this.#i.axisXCanvas,
|
|
3293
3299
|
candles: e
|
|
3294
|
-
}), this.#d = new
|
|
3300
|
+
}), this.#d = new Ot({ canvas: this.#i.axisYCanvas }), this.#a = new ee({
|
|
3295
3301
|
canvas: this.#i.tradesCanvas,
|
|
3296
3302
|
getHandleHitboxes: () => this.#p() ? [] : this.#n?.handleHitboxes ?? [],
|
|
3297
3303
|
getCurrentPrice: () => this.#s?.liveCandle?.close ?? 0,
|
|
@@ -3307,7 +3313,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
3307
3313
|
if (!this.#i) return;
|
|
3308
3314
|
this.#b = new AbortController();
|
|
3309
3315
|
const { signal: t } = this.#b, e = this.#i.interactionTarget;
|
|
3310
|
-
e.addEventListener("pointerdown", (i) => this.#
|
|
3316
|
+
e.addEventListener("pointerdown", (i) => this.#q(i), { signal: t }), e.addEventListener("pointerup", (i) => this.#J(i), { signal: t }), e.addEventListener("pointermove", (i) => this.#K(i), { signal: t }), e.addEventListener("pointerenter", (i) => this.#j(i), { signal: t }), e.addEventListener("pointerleave", () => this.#Z(), { signal: t }), e.addEventListener("contextmenu", (i) => this.#Q(i), { signal: t }), e.addEventListener("dblclick", (i) => this.#tt(i), { signal: t }), e.addEventListener("wheel", (i) => this.#U(i), {
|
|
3311
3317
|
passive: !1,
|
|
3312
3318
|
signal: t
|
|
3313
3319
|
}), this.#i.axisXCanvas.addEventListener("pointerenter", (i) => this.#D(i), { signal: t }), this.#i.axisXCanvas.addEventListener("pointerdown", (i) => this.#A(i, "x"), { signal: t }), this.#i.axisXCanvas.addEventListener("pointermove", (i) => this.#X(i), { signal: t }), this.#i.axisXCanvas.addEventListener("pointerup", (i) => this.#S(i), { signal: t }), this.#i.axisXCanvas.addEventListener("pointercancel", (i) => this.#S(i), { signal: t }), this.#i.axisYCanvas.addEventListener("pointerenter", (i) => this.#D(i), { signal: t }), this.#i.axisYCanvas.addEventListener("pointerdown", (i) => this.#A(i, "y"), { signal: t }), this.#i.axisYCanvas.addEventListener("pointermove", (i) => this.#X(i), { signal: t }), this.#i.axisYCanvas.addEventListener("pointerup", (i) => this.#S(i), { signal: t }), this.#i.axisYCanvas.addEventListener("pointercancel", (i) => this.#S(i), { signal: t }), this.#i.axisYCanvas.addEventListener("wheel", (i) => this.#$(i), {
|
|
@@ -3353,7 +3359,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
3353
3359
|
#Y(t) {
|
|
3354
3360
|
t !== null && (this.#w = !1, this.#n?.setIsDragging(!1), this.#a?.cancelActiveInteraction()), this.#l?.setActiveTool(t);
|
|
3355
3361
|
}
|
|
3356
|
-
#
|
|
3362
|
+
#E() {
|
|
3357
3363
|
const t = this.#e.openTrades ?? [];
|
|
3358
3364
|
return this.#C ? t.map((e) => e.ticket !== this.#C?.ticket ? e : {
|
|
3359
3365
|
...e,
|
|
@@ -3362,9 +3368,9 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
3362
3368
|
}) : t;
|
|
3363
3369
|
}
|
|
3364
3370
|
#x() {
|
|
3365
|
-
this.#n?.setTrades(this.#
|
|
3371
|
+
this.#n?.setTrades(this.#E());
|
|
3366
3372
|
}
|
|
3367
|
-
#
|
|
3373
|
+
#O() {
|
|
3368
3374
|
const t = this.#e.liveCandle;
|
|
3369
3375
|
if (!t || !this.#s) return;
|
|
3370
3376
|
const e = pt(t, this.#e.brokerTimezoneOffsetMs);
|
|
@@ -3450,7 +3456,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
3450
3456
|
if (e.style.cursor = i === "x" ? "ew-resize" : "ns-resize", !this.#f || this.#f.pointerId !== t.pointerId || this.#f.axis !== i) return;
|
|
3451
3457
|
const s = i === "x" ? t.clientX : t.clientY, r = s - this.#f.lastClientPosition;
|
|
3452
3458
|
if (this.#f.lastClientPosition = s, !this.#s || r === 0) return;
|
|
3453
|
-
const n =
|
|
3459
|
+
const n = -r / re;
|
|
3454
3460
|
i === "x" ? this.#s.zoomHorizontally(n) : this.#s.zoomVertically(n), t.preventDefault(), this.#c();
|
|
3455
3461
|
}
|
|
3456
3462
|
#S(t) {
|
|
@@ -3458,7 +3464,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
3458
3464
|
const e = t.currentTarget;
|
|
3459
3465
|
e.hasPointerCapture(t.pointerId) && e.releasePointerCapture(t.pointerId), this.#f = null, t.preventDefault();
|
|
3460
3466
|
}
|
|
3461
|
-
#
|
|
3467
|
+
#q(t) {
|
|
3462
3468
|
if (!(!this.#p() && this.#a?.handlePointerEvent(t))) {
|
|
3463
3469
|
if (this.#l?.handlePointerEvent(t) ?? !1) {
|
|
3464
3470
|
this.#c();
|
|
@@ -3477,17 +3483,17 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
3477
3483
|
const i = t.clientX - this.#T, s = t.clientY - this.#L;
|
|
3478
3484
|
this.#T = t.clientX, this.#L = t.clientY, this.#s.panHorizontally(i), this.#s.panVertically(s), this.#c(), this.#k(t);
|
|
3479
3485
|
}
|
|
3480
|
-
#
|
|
3486
|
+
#J(t) {
|
|
3481
3487
|
if (this.#w = !1, this.#l?.handlePointerEvent(t) ?? !1) {
|
|
3482
3488
|
this.#c();
|
|
3483
3489
|
return;
|
|
3484
3490
|
}
|
|
3485
3491
|
this.#p() || this.#a?.handlePointerEvent(t);
|
|
3486
3492
|
}
|
|
3487
|
-
#
|
|
3493
|
+
#j(t) {
|
|
3488
3494
|
document.body.style.cursor = "crosshair", this.#l?.handlePointerEvent(t), this.#p() || this.#a?.handlePointerEvent(t);
|
|
3489
3495
|
}
|
|
3490
|
-
#
|
|
3496
|
+
#Z() {
|
|
3491
3497
|
this.#l?.clearHoverState(), document.body.style.cursor = "", this.#G();
|
|
3492
3498
|
}
|
|
3493
3499
|
#Q(t) {
|
|
@@ -3497,22 +3503,25 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
3497
3503
|
this.#l?.handlePointerEvent(t);
|
|
3498
3504
|
}
|
|
3499
3505
|
#et(t) {
|
|
3500
|
-
(this.#l?.handleKeyboardEvent(t) ?? !1) && (t.preventDefault(), this.#c());
|
|
3506
|
+
this.#it(t.target) || (this.#l?.handleKeyboardEvent(t) ?? !1) && (t.preventDefault(), this.#c());
|
|
3507
|
+
}
|
|
3508
|
+
#it(t) {
|
|
3509
|
+
return t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement || t instanceof HTMLSelectElement || t instanceof HTMLElement && t.isContentEditable;
|
|
3501
3510
|
}
|
|
3502
|
-
},
|
|
3503
|
-
const r =
|
|
3504
|
-
return o.current = i,
|
|
3511
|
+
}, le = Mt(({ className: t, style: e, ...i }, s) => {
|
|
3512
|
+
const r = _(null), n = _(null), o = _(i);
|
|
3513
|
+
return o.current = i, Rt(s, () => ({ resetChartView() {
|
|
3505
3514
|
n.current?.resetChartView();
|
|
3506
3515
|
} })), st(() => {
|
|
3507
3516
|
const a = r.current;
|
|
3508
3517
|
if (!a) return;
|
|
3509
|
-
const l = new
|
|
3518
|
+
const l = new ne(a, o.current);
|
|
3510
3519
|
return n.current = l, () => {
|
|
3511
3520
|
l.destroy(), n.current = null;
|
|
3512
3521
|
};
|
|
3513
3522
|
}, []), st(() => {
|
|
3514
3523
|
n.current?.updateProps(o.current);
|
|
3515
|
-
}, [i]), /* @__PURE__ */
|
|
3524
|
+
}, [i]), /* @__PURE__ */ Dt("div", {
|
|
3516
3525
|
ref: r,
|
|
3517
3526
|
className: t,
|
|
3518
3527
|
style: {
|
|
@@ -3524,5 +3533,5 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
3524
3533
|
});
|
|
3525
3534
|
export {
|
|
3526
3535
|
c as CHART_CONFIG,
|
|
3527
|
-
|
|
3536
|
+
le as TradingReload
|
|
3528
3537
|
};
|
package/package.json
CHANGED