react-klinecharts-ui 0.1.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.
@@ -0,0 +1,911 @@
1
+ import { utils, registerOverlay } from 'react-klinecharts';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __export = (target, all) => {
5
+ for (var name in all)
6
+ __defProp(target, name, { get: all[name], enumerable: true });
7
+ };
8
+
9
+ // src/overlays/index.ts
10
+ var overlays_exports = {};
11
+ __export(overlays_exports, {
12
+ abcd: () => abcd_default,
13
+ anyWaves: () => anyWaves_default,
14
+ arrow: () => arrow_default,
15
+ circle: () => circle_default,
16
+ eightWaves: () => eightWaves_default,
17
+ fibonacciCircle: () => fibonacciCircle_default,
18
+ fibonacciExtension: () => fibonacciExtension_default,
19
+ fibonacciSegment: () => fibonacciSegment_default,
20
+ fibonacciSpeedResistanceFan: () => fibonacciSpeedResistanceFan_default,
21
+ fibonacciSpiral: () => fibonacciSpiral_default,
22
+ fiveWaves: () => fiveWaves_default,
23
+ gannBox: () => gannBox_default,
24
+ parallelogram: () => parallelogram_default,
25
+ rect: () => rect_default,
26
+ threeWaves: () => threeWaves_default,
27
+ triangle: () => triangle_default,
28
+ xabcd: () => xabcd_default
29
+ });
30
+ function getRotateCoordinate(coordinate, targetCoordinate, angle) {
31
+ const x = (coordinate.x - targetCoordinate.x) * Math.cos(angle) - (coordinate.y - targetCoordinate.y) * Math.sin(angle) + targetCoordinate.x;
32
+ const y = (coordinate.x - targetCoordinate.x) * Math.sin(angle) + (coordinate.y - targetCoordinate.y) * Math.cos(angle) + targetCoordinate.y;
33
+ return { x, y };
34
+ }
35
+ function getRayLine(coordinates, bounding) {
36
+ if (coordinates.length > 1) {
37
+ let coordinate;
38
+ if (coordinates[0].x === coordinates[1].x && coordinates[0].y !== coordinates[1].y) {
39
+ if (coordinates[0].y < coordinates[1].y) {
40
+ coordinate = { x: coordinates[0].x, y: bounding.height };
41
+ } else {
42
+ coordinate = { x: coordinates[0].x, y: 0 };
43
+ }
44
+ } else if (coordinates[0].x > coordinates[1].x) {
45
+ coordinate = {
46
+ x: 0,
47
+ y: utils.getLinearYFromCoordinates(coordinates[0], coordinates[1], {
48
+ x: 0,
49
+ y: coordinates[0].y
50
+ })
51
+ };
52
+ } else {
53
+ coordinate = {
54
+ x: bounding.width,
55
+ y: utils.getLinearYFromCoordinates(coordinates[0], coordinates[1], {
56
+ x: bounding.width,
57
+ y: coordinates[0].y
58
+ })
59
+ };
60
+ }
61
+ return { coordinates: [coordinates[0], coordinate] };
62
+ }
63
+ return [];
64
+ }
65
+ function getDistance(coordinate1, coordinate2) {
66
+ const xDis = Math.abs(coordinate1.x - coordinate2.x);
67
+ const yDis = Math.abs(coordinate1.y - coordinate2.y);
68
+ return Math.sqrt(xDis * xDis + yDis * yDis);
69
+ }
70
+
71
+ // src/overlays/arrow.ts
72
+ var arrow = {
73
+ name: "arrow",
74
+ totalStep: 3,
75
+ needDefaultPointFigure: true,
76
+ needDefaultXAxisFigure: true,
77
+ needDefaultYAxisFigure: true,
78
+ createPointFigures: ({ coordinates }) => {
79
+ if (coordinates.length > 1) {
80
+ const flag = coordinates[1].x > coordinates[0].x ? 0 : 1;
81
+ const kb = utils.getLinearSlopeIntercept(coordinates[0], coordinates[1]);
82
+ let offsetAngle;
83
+ if (kb) {
84
+ offsetAngle = Math.atan(kb[0]) + Math.PI * flag;
85
+ } else {
86
+ if (coordinates[1].y > coordinates[0].y) {
87
+ offsetAngle = Math.PI / 2;
88
+ } else {
89
+ offsetAngle = Math.PI / 2 * 3;
90
+ }
91
+ }
92
+ const rotateCoordinate1 = getRotateCoordinate(
93
+ { x: coordinates[1].x - 8, y: coordinates[1].y + 4 },
94
+ coordinates[1],
95
+ offsetAngle
96
+ );
97
+ const rotateCoordinate2 = getRotateCoordinate(
98
+ { x: coordinates[1].x - 8, y: coordinates[1].y - 4 },
99
+ coordinates[1],
100
+ offsetAngle
101
+ );
102
+ return [
103
+ { type: "line", attrs: { coordinates } },
104
+ {
105
+ type: "line",
106
+ ignoreEvent: true,
107
+ attrs: {
108
+ coordinates: [rotateCoordinate1, coordinates[1], rotateCoordinate2]
109
+ }
110
+ }
111
+ ];
112
+ }
113
+ return [];
114
+ }
115
+ };
116
+ var arrow_default = arrow;
117
+
118
+ // src/overlays/circle.ts
119
+ var circle = {
120
+ name: "circle",
121
+ totalStep: 3,
122
+ needDefaultPointFigure: true,
123
+ needDefaultXAxisFigure: true,
124
+ needDefaultYAxisFigure: true,
125
+ styles: { circle: { color: "rgba(22, 119, 255, 0.15)" } },
126
+ createPointFigures: ({ coordinates }) => {
127
+ if (coordinates.length > 1) {
128
+ const radius = getDistance(coordinates[0], coordinates[1]);
129
+ return {
130
+ type: "circle",
131
+ attrs: { ...coordinates[0], r: radius },
132
+ styles: { style: "stroke_fill" }
133
+ };
134
+ }
135
+ return [];
136
+ }
137
+ };
138
+ var circle_default = circle;
139
+
140
+ // src/overlays/rect.ts
141
+ var rect = {
142
+ name: "rect",
143
+ totalStep: 3,
144
+ needDefaultPointFigure: true,
145
+ needDefaultXAxisFigure: true,
146
+ needDefaultYAxisFigure: true,
147
+ styles: { polygon: { color: "rgba(22, 119, 255, 0.15)" } },
148
+ createPointFigures: ({ coordinates }) => {
149
+ if (coordinates.length > 1) {
150
+ return [
151
+ {
152
+ type: "polygon",
153
+ attrs: {
154
+ coordinates: [
155
+ coordinates[0],
156
+ { x: coordinates[1].x, y: coordinates[0].y },
157
+ coordinates[1],
158
+ { x: coordinates[0].x, y: coordinates[1].y }
159
+ ]
160
+ },
161
+ styles: { style: "stroke_fill" }
162
+ }
163
+ ];
164
+ }
165
+ return [];
166
+ }
167
+ };
168
+ var rect_default = rect;
169
+
170
+ // src/overlays/triangle.ts
171
+ var triangle = {
172
+ name: "triangle",
173
+ totalStep: 4,
174
+ needDefaultPointFigure: true,
175
+ needDefaultXAxisFigure: true,
176
+ needDefaultYAxisFigure: true,
177
+ styles: { polygon: { color: "rgba(22, 119, 255, 0.15)" } },
178
+ createPointFigures: ({ coordinates }) => {
179
+ return [
180
+ {
181
+ type: "polygon",
182
+ attrs: { coordinates },
183
+ styles: { style: "stroke_fill" }
184
+ }
185
+ ];
186
+ }
187
+ };
188
+ var triangle_default = triangle;
189
+
190
+ // src/overlays/parallelogram.ts
191
+ var parallelogram = {
192
+ name: "parallelogram",
193
+ totalStep: 4,
194
+ needDefaultPointFigure: true,
195
+ needDefaultXAxisFigure: true,
196
+ needDefaultYAxisFigure: true,
197
+ styles: { polygon: { color: "rgba(22, 119, 255, 0.15)" } },
198
+ createPointFigures: ({ coordinates }) => {
199
+ if (coordinates.length === 2) {
200
+ return [{ type: "line", ignoreEvent: true, attrs: { coordinates } }];
201
+ }
202
+ if (coordinates.length === 3) {
203
+ const coordinate = {
204
+ x: coordinates[0].x + (coordinates[2].x - coordinates[1].x),
205
+ y: coordinates[2].y - coordinates[1].y + coordinates[0].y
206
+ };
207
+ return [
208
+ {
209
+ type: "polygon",
210
+ attrs: {
211
+ coordinates: [
212
+ coordinates[0],
213
+ coordinates[1],
214
+ coordinates[2],
215
+ coordinate
216
+ ]
217
+ },
218
+ styles: { style: "stroke_fill" }
219
+ }
220
+ ];
221
+ }
222
+ return [];
223
+ },
224
+ performEventPressedMove: ({ points, performPointIndex, performPoint }) => {
225
+ if (performPointIndex < 2) {
226
+ if (points[0]) points[0].price = performPoint.price;
227
+ if (points[1]) points[1].price = performPoint.price;
228
+ }
229
+ },
230
+ performEventMoveForDrawing: ({ currentStep, points, performPoint }) => {
231
+ if (currentStep === 2) {
232
+ if (points[0]) points[0].price = performPoint.price;
233
+ }
234
+ }
235
+ };
236
+ var parallelogram_default = parallelogram;
237
+
238
+ // src/overlays/fibonacciCircle.ts
239
+ var fibonacciCircle = {
240
+ name: "fibonacciCircle",
241
+ totalStep: 3,
242
+ needDefaultPointFigure: true,
243
+ needDefaultXAxisFigure: true,
244
+ needDefaultYAxisFigure: true,
245
+ createPointFigures: ({ coordinates }) => {
246
+ if (coordinates.length > 1) {
247
+ const xDis = Math.abs(coordinates[0].x - coordinates[1].x);
248
+ const yDis = Math.abs(coordinates[0].y - coordinates[1].y);
249
+ const radius = Math.sqrt(xDis * xDis + yDis * yDis);
250
+ const percents = [0.236, 0.382, 0.5, 0.618, 0.786, 1];
251
+ const circles = [];
252
+ const texts = [];
253
+ percents.forEach((percent) => {
254
+ const r = radius * percent;
255
+ circles.push({ ...coordinates[0], r });
256
+ texts.push({
257
+ x: coordinates[0].x,
258
+ y: coordinates[0].y + r + 6,
259
+ text: `${(percent * 100).toFixed(1)}%`
260
+ });
261
+ });
262
+ return [
263
+ { type: "circle", attrs: circles, styles: { style: "stroke" } },
264
+ { type: "text", ignoreEvent: true, attrs: texts }
265
+ ];
266
+ }
267
+ return [];
268
+ }
269
+ };
270
+ var fibonacciCircle_default = fibonacciCircle;
271
+
272
+ // src/overlays/fibonacciSegment.ts
273
+ var fibonacciSegment = {
274
+ name: "fibonacciSegment",
275
+ totalStep: 3,
276
+ needDefaultPointFigure: true,
277
+ needDefaultXAxisFigure: true,
278
+ needDefaultYAxisFigure: true,
279
+ createPointFigures: ({ coordinates, overlay, chart }) => {
280
+ const precision = chart.getSymbol()?.pricePrecision ?? 2;
281
+ const lines = [];
282
+ const texts = [];
283
+ if (coordinates.length > 1) {
284
+ const textX = coordinates[1].x > coordinates[0].x ? coordinates[0].x : coordinates[1].x;
285
+ const percents = [1, 0.786, 0.618, 0.5, 0.382, 0.236, 0];
286
+ const yDif = coordinates[0].y - coordinates[1].y;
287
+ const points = overlay.points;
288
+ const valueDif = points[0].value - points[1].value;
289
+ percents.forEach((percent) => {
290
+ const y = coordinates[1].y + yDif * percent;
291
+ const price = (points[1].value + valueDif * percent).toFixed(precision);
292
+ lines.push({
293
+ coordinates: [
294
+ { x: coordinates[0].x, y },
295
+ { x: coordinates[1].x, y }
296
+ ]
297
+ });
298
+ texts.push({
299
+ x: textX,
300
+ y,
301
+ text: `${price} (${(percent * 100).toFixed(1)}%)`,
302
+ baseline: "bottom"
303
+ });
304
+ });
305
+ }
306
+ return [
307
+ { type: "line", attrs: lines },
308
+ { type: "text", ignoreEvent: true, attrs: texts }
309
+ ];
310
+ }
311
+ };
312
+ var fibonacciSegment_default = fibonacciSegment;
313
+ var fibonacciSpiral = {
314
+ name: "fibonacciSpiral",
315
+ totalStep: 3,
316
+ needDefaultPointFigure: true,
317
+ needDefaultXAxisFigure: true,
318
+ needDefaultYAxisFigure: true,
319
+ createPointFigures: ({ coordinates, bounding }) => {
320
+ if (coordinates.length > 1) {
321
+ const startRadius = getDistance(coordinates[0], coordinates[1]) / Math.sqrt(24);
322
+ const flag = coordinates[1].x > coordinates[0].x ? 0 : 1;
323
+ const kb = utils.getLinearSlopeIntercept(coordinates[0], coordinates[1]);
324
+ let offsetAngle;
325
+ if (kb) {
326
+ offsetAngle = Math.atan(kb[0]) + Math.PI * flag;
327
+ } else {
328
+ if (coordinates[1].y > coordinates[0].y) {
329
+ offsetAngle = Math.PI / 2;
330
+ } else {
331
+ offsetAngle = Math.PI / 2 * 3;
332
+ }
333
+ }
334
+ const rotateCoordinate1 = getRotateCoordinate(
335
+ { x: coordinates[0].x - startRadius, y: coordinates[0].y },
336
+ coordinates[0],
337
+ offsetAngle
338
+ );
339
+ const rotateCoordinate2 = getRotateCoordinate(
340
+ {
341
+ x: coordinates[0].x - startRadius,
342
+ y: coordinates[0].y - startRadius
343
+ },
344
+ coordinates[0],
345
+ offsetAngle
346
+ );
347
+ const arcs = [
348
+ {
349
+ ...rotateCoordinate1,
350
+ r: startRadius,
351
+ startAngle: offsetAngle,
352
+ endAngle: offsetAngle + Math.PI / 2
353
+ },
354
+ {
355
+ ...rotateCoordinate2,
356
+ r: startRadius * 2,
357
+ startAngle: offsetAngle + Math.PI / 2,
358
+ endAngle: offsetAngle + Math.PI
359
+ }
360
+ ];
361
+ let x = coordinates[0].x - startRadius;
362
+ let y = coordinates[0].y - startRadius;
363
+ for (let i = 2; i < 9; i++) {
364
+ const r = arcs[i - 2].r + arcs[i - 1].r;
365
+ let startAngle = 0;
366
+ switch (i % 4) {
367
+ case 0:
368
+ startAngle = offsetAngle;
369
+ x -= arcs[i - 2].r;
370
+ break;
371
+ case 1:
372
+ startAngle = offsetAngle + Math.PI / 2;
373
+ y -= arcs[i - 2].r;
374
+ break;
375
+ case 2:
376
+ startAngle = offsetAngle + Math.PI;
377
+ x += arcs[i - 2].r;
378
+ break;
379
+ case 3:
380
+ startAngle = offsetAngle + Math.PI / 2 * 3;
381
+ y += arcs[i - 2].r;
382
+ break;
383
+ }
384
+ const endAngle = startAngle + Math.PI / 2;
385
+ const rotateCoordinate = getRotateCoordinate(
386
+ { x, y },
387
+ coordinates[0],
388
+ offsetAngle
389
+ );
390
+ arcs.push({ ...rotateCoordinate, r, startAngle, endAngle });
391
+ }
392
+ return [
393
+ { type: "arc", attrs: arcs },
394
+ { type: "line", attrs: getRayLine(coordinates, bounding) }
395
+ ];
396
+ }
397
+ return [];
398
+ }
399
+ };
400
+ var fibonacciSpiral_default = fibonacciSpiral;
401
+
402
+ // src/overlays/fibonacciSpeedResistanceFan.ts
403
+ var fibonacciSpeedResistanceFan = {
404
+ name: "fibonacciSpeedResistanceFan",
405
+ totalStep: 3,
406
+ needDefaultPointFigure: true,
407
+ needDefaultXAxisFigure: true,
408
+ needDefaultYAxisFigure: true,
409
+ createPointFigures: ({ coordinates, bounding }) => {
410
+ const lines1 = [];
411
+ let lines2 = [];
412
+ const texts = [];
413
+ if (coordinates.length > 1) {
414
+ const xOffset = coordinates[1].x > coordinates[0].x ? -38 : 4;
415
+ const yOffset = coordinates[1].y > coordinates[0].y ? -2 : 20;
416
+ const xDistance = coordinates[1].x - coordinates[0].x;
417
+ const yDistance = coordinates[1].y - coordinates[0].y;
418
+ const percents = [1, 0.75, 0.618, 0.5, 0.382, 0.25, 0];
419
+ percents.forEach((percent) => {
420
+ const x = coordinates[1].x - xDistance * percent;
421
+ const y = coordinates[1].y - yDistance * percent;
422
+ lines1.push({
423
+ coordinates: [
424
+ { x, y: coordinates[0].y },
425
+ { x, y: coordinates[1].y }
426
+ ]
427
+ });
428
+ lines1.push({
429
+ coordinates: [
430
+ { x: coordinates[0].x, y },
431
+ { x: coordinates[1].x, y }
432
+ ]
433
+ });
434
+ lines2 = lines2.concat(
435
+ getRayLine(
436
+ [coordinates[0], { x, y: coordinates[1].y }],
437
+ bounding
438
+ )
439
+ );
440
+ lines2 = lines2.concat(
441
+ getRayLine(
442
+ [coordinates[0], { x: coordinates[1].x, y }],
443
+ bounding
444
+ )
445
+ );
446
+ texts.unshift({
447
+ x: coordinates[0].x + xOffset,
448
+ y: y + 10,
449
+ text: `${percent.toFixed(3)}`
450
+ });
451
+ texts.unshift({
452
+ x: x - 18,
453
+ y: coordinates[0].y + yOffset,
454
+ text: `${percent.toFixed(3)}`
455
+ });
456
+ });
457
+ }
458
+ return [
459
+ { type: "line", attrs: lines1 },
460
+ { type: "line", attrs: lines2 },
461
+ { type: "text", ignoreEvent: true, attrs: texts }
462
+ ];
463
+ }
464
+ };
465
+ var fibonacciSpeedResistanceFan_default = fibonacciSpeedResistanceFan;
466
+
467
+ // src/overlays/fibonacciExtension.ts
468
+ var fibonacciExtension = {
469
+ name: "fibonacciExtension",
470
+ totalStep: 4,
471
+ needDefaultPointFigure: true,
472
+ needDefaultXAxisFigure: true,
473
+ needDefaultYAxisFigure: true,
474
+ createPointFigures: ({ coordinates, overlay, chart }) => {
475
+ const precision = chart.getSymbol()?.pricePrecision ?? 2;
476
+ const fbLines = [];
477
+ const texts = [];
478
+ if (coordinates.length > 2) {
479
+ const points = overlay.points;
480
+ const valueDif = points[1].value - points[0].value;
481
+ const yDif = coordinates[1].y - coordinates[0].y;
482
+ const percents = [0, 0.236, 0.382, 0.5, 0.618, 0.786, 1];
483
+ const textX = coordinates[2].x > coordinates[1].x ? coordinates[1].x : coordinates[2].x;
484
+ percents.forEach((percent) => {
485
+ const y = coordinates[2].y + yDif * percent;
486
+ const price = (points[2].value + valueDif * percent).toFixed(precision);
487
+ fbLines.push({
488
+ coordinates: [
489
+ { x: coordinates[1].x, y },
490
+ { x: coordinates[2].x, y }
491
+ ]
492
+ });
493
+ texts.push({
494
+ x: textX,
495
+ y,
496
+ text: `${price} (${(percent * 100).toFixed(1)}%)`,
497
+ baseline: "bottom"
498
+ });
499
+ });
500
+ }
501
+ return [
502
+ {
503
+ type: "line",
504
+ attrs: { coordinates },
505
+ styles: { style: "dashed" }
506
+ },
507
+ { type: "line", attrs: fbLines },
508
+ { type: "text", ignoreEvent: true, attrs: texts }
509
+ ];
510
+ }
511
+ };
512
+ var fibonacciExtension_default = fibonacciExtension;
513
+
514
+ // src/overlays/gannBox.ts
515
+ var gannBox = {
516
+ name: "gannBox",
517
+ totalStep: 3,
518
+ needDefaultPointFigure: true,
519
+ needDefaultXAxisFigure: true,
520
+ needDefaultYAxisFigure: true,
521
+ styles: { polygon: { color: "rgba(22, 119, 255, 0.15)" } },
522
+ createPointFigures: ({ coordinates }) => {
523
+ if (coordinates.length > 1) {
524
+ const quarterYDis = (coordinates[1].y - coordinates[0].y) / 4;
525
+ const xDis = coordinates[1].x - coordinates[0].x;
526
+ const dashedLines = [
527
+ {
528
+ coordinates: [
529
+ coordinates[0],
530
+ { x: coordinates[1].x, y: coordinates[1].y - quarterYDis }
531
+ ]
532
+ },
533
+ {
534
+ coordinates: [
535
+ coordinates[0],
536
+ { x: coordinates[1].x, y: coordinates[1].y - quarterYDis * 2 }
537
+ ]
538
+ },
539
+ {
540
+ coordinates: [
541
+ { x: coordinates[0].x, y: coordinates[1].y },
542
+ { x: coordinates[1].x, y: coordinates[0].y + quarterYDis }
543
+ ]
544
+ },
545
+ {
546
+ coordinates: [
547
+ { x: coordinates[0].x, y: coordinates[1].y },
548
+ { x: coordinates[1].x, y: coordinates[0].y + quarterYDis * 2 }
549
+ ]
550
+ },
551
+ {
552
+ coordinates: [
553
+ { ...coordinates[0] },
554
+ { x: coordinates[0].x + xDis * 0.236, y: coordinates[1].y }
555
+ ]
556
+ },
557
+ {
558
+ coordinates: [
559
+ { ...coordinates[0] },
560
+ { x: coordinates[0].x + xDis * 0.5, y: coordinates[1].y }
561
+ ]
562
+ },
563
+ {
564
+ coordinates: [
565
+ { x: coordinates[0].x, y: coordinates[1].y },
566
+ { x: coordinates[0].x + xDis * 0.236, y: coordinates[0].y }
567
+ ]
568
+ },
569
+ {
570
+ coordinates: [
571
+ { x: coordinates[0].x, y: coordinates[1].y },
572
+ { x: coordinates[0].x + xDis * 0.5, y: coordinates[0].y }
573
+ ]
574
+ }
575
+ ];
576
+ const solidLines = [
577
+ { coordinates: [coordinates[0], coordinates[1]] },
578
+ {
579
+ coordinates: [
580
+ { x: coordinates[0].x, y: coordinates[1].y },
581
+ { x: coordinates[1].x, y: coordinates[0].y }
582
+ ]
583
+ }
584
+ ];
585
+ return [
586
+ {
587
+ type: "line",
588
+ attrs: [
589
+ {
590
+ coordinates: [
591
+ coordinates[0],
592
+ { x: coordinates[1].x, y: coordinates[0].y }
593
+ ]
594
+ },
595
+ {
596
+ coordinates: [
597
+ { x: coordinates[1].x, y: coordinates[0].y },
598
+ coordinates[1]
599
+ ]
600
+ },
601
+ {
602
+ coordinates: [
603
+ coordinates[1],
604
+ { x: coordinates[0].x, y: coordinates[1].y }
605
+ ]
606
+ },
607
+ {
608
+ coordinates: [
609
+ { x: coordinates[0].x, y: coordinates[1].y },
610
+ coordinates[0]
611
+ ]
612
+ }
613
+ ]
614
+ },
615
+ {
616
+ type: "polygon",
617
+ ignoreEvent: true,
618
+ attrs: {
619
+ coordinates: [
620
+ coordinates[0],
621
+ { x: coordinates[1].x, y: coordinates[0].y },
622
+ coordinates[1],
623
+ { x: coordinates[0].x, y: coordinates[1].y }
624
+ ]
625
+ },
626
+ styles: { style: "fill" }
627
+ },
628
+ { type: "line", attrs: dashedLines, styles: { style: "dashed" } },
629
+ { type: "line", attrs: solidLines }
630
+ ];
631
+ }
632
+ return [];
633
+ }
634
+ };
635
+ var gannBox_default = gannBox;
636
+
637
+ // src/overlays/threeWaves.ts
638
+ var threeWaves = {
639
+ name: "threeWaves",
640
+ totalStep: 5,
641
+ needDefaultPointFigure: true,
642
+ needDefaultXAxisFigure: true,
643
+ needDefaultYAxisFigure: true,
644
+ createPointFigures: ({ coordinates }) => {
645
+ const texts = coordinates.map((coordinate, i) => ({
646
+ ...coordinate,
647
+ text: `(${i})`,
648
+ baseline: "bottom"
649
+ }));
650
+ return [
651
+ { type: "line", attrs: { coordinates } },
652
+ { type: "text", ignoreEvent: true, attrs: texts }
653
+ ];
654
+ }
655
+ };
656
+ var threeWaves_default = threeWaves;
657
+
658
+ // src/overlays/fiveWaves.ts
659
+ var fiveWaves = {
660
+ name: "fiveWaves",
661
+ totalStep: 7,
662
+ needDefaultPointFigure: true,
663
+ needDefaultXAxisFigure: true,
664
+ needDefaultYAxisFigure: true,
665
+ createPointFigures: ({ coordinates }) => {
666
+ const texts = coordinates.map((coordinate, i) => ({
667
+ ...coordinate,
668
+ text: `(${i})`,
669
+ baseline: "bottom"
670
+ }));
671
+ return [
672
+ { type: "line", attrs: { coordinates } },
673
+ { type: "text", ignoreEvent: true, attrs: texts }
674
+ ];
675
+ }
676
+ };
677
+ var fiveWaves_default = fiveWaves;
678
+
679
+ // src/overlays/eightWaves.ts
680
+ var eightWaves = {
681
+ name: "eightWaves",
682
+ totalStep: 10,
683
+ needDefaultPointFigure: true,
684
+ needDefaultXAxisFigure: true,
685
+ needDefaultYAxisFigure: true,
686
+ createPointFigures: ({ coordinates }) => {
687
+ const texts = coordinates.map((coordinate, i) => ({
688
+ ...coordinate,
689
+ text: `(${i})`,
690
+ baseline: "bottom"
691
+ }));
692
+ return [
693
+ { type: "line", attrs: { coordinates } },
694
+ { type: "text", ignoreEvent: true, attrs: texts }
695
+ ];
696
+ }
697
+ };
698
+ var eightWaves_default = eightWaves;
699
+
700
+ // src/overlays/anyWaves.ts
701
+ var anyWaves = {
702
+ name: "anyWaves",
703
+ totalStep: Number.MAX_SAFE_INTEGER,
704
+ needDefaultPointFigure: true,
705
+ needDefaultXAxisFigure: true,
706
+ needDefaultYAxisFigure: true,
707
+ createPointFigures: ({ coordinates }) => {
708
+ const texts = coordinates.map((coordinate, i) => ({
709
+ ...coordinate,
710
+ text: `(${i})`,
711
+ baseline: "bottom"
712
+ }));
713
+ return [
714
+ { type: "line", attrs: { coordinates } },
715
+ { type: "text", ignoreEvent: true, attrs: texts }
716
+ ];
717
+ }
718
+ };
719
+ var anyWaves_default = anyWaves;
720
+
721
+ // src/overlays/abcd.ts
722
+ var abcd = {
723
+ name: "abcd",
724
+ totalStep: 5,
725
+ needDefaultPointFigure: true,
726
+ needDefaultXAxisFigure: true,
727
+ needDefaultYAxisFigure: true,
728
+ createPointFigures: ({ coordinates }) => {
729
+ let acLineCoordinates = [];
730
+ let bdLineCoordinates = [];
731
+ const tags = ["A", "B", "C", "D"];
732
+ const texts = coordinates.map((coordinate, i) => ({
733
+ ...coordinate,
734
+ baseline: "bottom",
735
+ text: `(${tags[i]})`
736
+ }));
737
+ if (coordinates.length > 2) {
738
+ acLineCoordinates = [coordinates[0], coordinates[2]];
739
+ if (coordinates.length > 3) {
740
+ bdLineCoordinates = [coordinates[1], coordinates[3]];
741
+ }
742
+ }
743
+ return [
744
+ { type: "line", attrs: { coordinates } },
745
+ {
746
+ type: "line",
747
+ attrs: [
748
+ { coordinates: acLineCoordinates },
749
+ { coordinates: bdLineCoordinates }
750
+ ],
751
+ styles: { style: "dashed" }
752
+ },
753
+ { type: "text", ignoreEvent: true, attrs: texts }
754
+ ];
755
+ }
756
+ };
757
+ var abcd_default = abcd;
758
+
759
+ // src/overlays/xabcd.ts
760
+ var xabcd = {
761
+ name: "xabcd",
762
+ totalStep: 6,
763
+ needDefaultPointFigure: true,
764
+ needDefaultXAxisFigure: true,
765
+ needDefaultYAxisFigure: true,
766
+ styles: { polygon: { color: "rgba(22, 119, 255, 0.15)" } },
767
+ createPointFigures: ({ coordinates }) => {
768
+ const dashedLines = [];
769
+ const polygons = [];
770
+ const tags = ["X", "A", "B", "C", "D"];
771
+ const texts = coordinates.map((coordinate, i) => ({
772
+ ...coordinate,
773
+ baseline: "bottom",
774
+ text: `(${tags[i]})`
775
+ }));
776
+ if (coordinates.length > 2) {
777
+ dashedLines.push({ coordinates: [coordinates[0], coordinates[2]] });
778
+ polygons.push({
779
+ coordinates: [coordinates[0], coordinates[1], coordinates[2]]
780
+ });
781
+ if (coordinates.length > 3) {
782
+ dashedLines.push({ coordinates: [coordinates[1], coordinates[3]] });
783
+ if (coordinates.length > 4) {
784
+ dashedLines.push({ coordinates: [coordinates[2], coordinates[4]] });
785
+ polygons.push({
786
+ coordinates: [coordinates[2], coordinates[3], coordinates[4]]
787
+ });
788
+ }
789
+ }
790
+ }
791
+ return [
792
+ { type: "line", attrs: { coordinates } },
793
+ { type: "line", attrs: dashedLines, styles: { style: "dashed" } },
794
+ { type: "polygon", ignoreEvent: true, attrs: polygons },
795
+ { type: "text", ignoreEvent: true, attrs: texts }
796
+ ];
797
+ }
798
+ };
799
+ var xabcd_default = xabcd;
800
+
801
+ // src/extensions/overlays/orderLine.ts
802
+ var DEFAULT_FONT_FAMILY = "Helvetica Neue, Arial, sans-serif";
803
+ var orderLine = {
804
+ name: "orderLine",
805
+ totalStep: 2,
806
+ needDefaultPointFigure: false,
807
+ needDefaultXAxisFigure: false,
808
+ needDefaultYAxisFigure: false,
809
+ createYAxisFigures: ({ chart, overlay, coordinates }) => {
810
+ if (coordinates.length < 1) return [];
811
+ const y = coordinates[0].y;
812
+ const price = overlay.points[0]?.value;
813
+ if (price == null) return [];
814
+ const d = overlay.extendData ?? {};
815
+ const color = d.color ?? "rgba(255, 165, 0, 0.85)";
816
+ const m = d.mark;
817
+ const precision = chart.getSymbol()?.pricePrecision ?? 2;
818
+ return [
819
+ {
820
+ type: "text",
821
+ attrs: {
822
+ x: 0,
823
+ y,
824
+ text: price.toFixed(precision),
825
+ align: "left",
826
+ baseline: "middle"
827
+ },
828
+ styles: {
829
+ color: m?.color ?? "#ffffff",
830
+ size: m?.font?.size ?? 11,
831
+ family: m?.font?.family ?? DEFAULT_FONT_FAMILY,
832
+ weight: m?.font?.weight ?? "bold",
833
+ paddingLeft: m?.padding?.x ?? 4,
834
+ paddingRight: m?.padding?.x ?? 4,
835
+ paddingTop: m?.padding?.y ?? 4,
836
+ paddingBottom: m?.padding?.y ?? 4,
837
+ backgroundColor: m?.bg ?? color,
838
+ borderRadius: m?.borderRadius ?? 2
839
+ }
840
+ }
841
+ ];
842
+ },
843
+ createPointFigures: ({ coordinates, bounding, overlay }) => {
844
+ if (coordinates.length < 1) return [];
845
+ const y = coordinates[0].y;
846
+ const d = overlay.extendData ?? {};
847
+ const color = d.color ?? "rgba(255, 165, 0, 0.85)";
848
+ const ln = d.line;
849
+ const figures = [
850
+ {
851
+ type: "line",
852
+ attrs: {
853
+ coordinates: [
854
+ { x: 0, y },
855
+ { x: bounding.width, y }
856
+ ]
857
+ },
858
+ styles: {
859
+ style: ln?.style ?? "dashed",
860
+ color,
861
+ size: ln?.width ?? 1,
862
+ dashedValue: ln?.dashedValue ?? [4, 2]
863
+ }
864
+ }
865
+ ];
866
+ if (d.text) {
867
+ const lb = d.label;
868
+ figures.push({
869
+ type: "text",
870
+ ignoreEvent: true,
871
+ attrs: {
872
+ x: lb?.offset?.x ?? 8,
873
+ y: y - (lb?.offset?.y ?? 3),
874
+ text: d.text,
875
+ align: "left",
876
+ baseline: "bottom"
877
+ },
878
+ styles: {
879
+ color: lb?.color ?? color,
880
+ size: lb?.font?.size ?? 11,
881
+ family: lb?.font?.family ?? DEFAULT_FONT_FAMILY,
882
+ weight: lb?.font?.weight ?? "normal",
883
+ paddingLeft: lb?.padding?.x ?? 0,
884
+ paddingRight: lb?.padding?.x ?? 0,
885
+ paddingTop: lb?.padding?.y ?? 0,
886
+ paddingBottom: lb?.padding?.y ?? 0,
887
+ backgroundColor: lb?.bg ?? "transparent",
888
+ borderRadius: lb?.borderRadius ?? 0
889
+ }
890
+ });
891
+ }
892
+ return figures;
893
+ },
894
+ performEventPressedMove: ({ points, performPoint }) => {
895
+ points[0].value = performPoint.value;
896
+ }
897
+ };
898
+ var orderLine_default = orderLine;
899
+
900
+ // src/extensions/index.ts
901
+ var overlays = Object.values(overlays_exports);
902
+ var registered = false;
903
+ function registerExtensions() {
904
+ if (registered) return;
905
+ overlays.forEach((overlay) => registerOverlay(overlay));
906
+ registered = true;
907
+ }
908
+
909
+ export { abcd_default, anyWaves_default, arrow_default, circle_default, eightWaves_default, fibonacciCircle_default, fibonacciExtension_default, fibonacciSegment_default, fibonacciSpeedResistanceFan_default, fibonacciSpiral_default, fiveWaves_default, gannBox_default, orderLine_default, overlays, parallelogram_default, rect_default, registerExtensions, threeWaves_default, triangle_default, xabcd_default };
910
+ //# sourceMappingURL=chunk-PUULIBFN.js.map
911
+ //# sourceMappingURL=chunk-PUULIBFN.js.map