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