forked from klinecharts/KLineChart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
1036 lines (1012 loc) · 31.8 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export type DeepPartial<T> = {
[P in keyof T]?: T[P] extends Array<infer U> ? Array<DeepPartial<U>> : T[P] extends ReadonlyArray<infer X> ? ReadonlyArray<DeepPartial<X>> : DeepPartial<T[P]>;
};
/**
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export type Nullable<T> = T | null;
/**
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export interface KLineData {
timestamp: number;
open: number;
high: number;
low: number;
close: number;
volume?: number;
turnover?: number;
}
/**
* line type
*/
export declare enum LineType {
Dashed = "dashed",
Solid = "solid"
}
export interface LineStyle {
style: LineType;
size: number;
color: string;
dashedValue: number[];
}
export interface SmoothLineStyle extends LineStyle {
smooth: boolean;
}
export interface StateLineStyle extends LineStyle {
show: boolean;
}
export declare enum PolygonType {
Stroke = "stroke",
Fill = "fill",
StrokeFill = "stroke_fill"
}
export interface PolygonStyle {
style: PolygonType;
color: string | CanvasGradient;
borderColor: string;
borderSize: number;
borderStyle: LineType;
borderDashedValue: number[];
}
export interface RectStyle extends PolygonStyle {
borderRadius: number;
}
export interface TextStyle {
color: string;
size: number;
family: string;
weight: number | string;
}
export interface StateTextStyle extends TextStyle {
show: boolean;
}
export interface RectTextStyle extends TextStyle {
style: PolygonType;
paddingLeft: number;
paddingTop: number;
paddingRight: number;
paddingBottom: number;
borderStyle: LineType;
borderDashedValue: number[];
borderSize: number;
borderColor: string;
borderRadius: number;
backgroundColor: string;
}
export interface StateRectTextStyle extends RectTextStyle {
show: boolean;
}
export interface MarginTextStyle extends StateTextStyle {
marginLeft: number;
marginTop: number;
marginRight: number;
marginBottom: number;
}
export type LastValueMarkTextStyle = Omit<StateRectTextStyle, "backgroundColor" | "borderColor">;
export declare enum TooltipShowRule {
Always = "always",
FollowCross = "follow_cross",
None = "none"
}
export declare enum TooltipShowType {
Standard = "standard",
Rect = "rect"
}
export interface ChangeColor {
upColor: string;
downColor: string;
noChangeColor: string;
}
export interface GradientColor {
offset: number;
color: string;
}
export interface GridStyle {
show: boolean;
horizontal: StateLineStyle;
vertical: StateLineStyle;
}
export type TooltipTextStyle = Omit<MarginTextStyle, "show">;
export interface TooltipDataChild {
text: string;
color: string;
}
export interface TooltipData {
title: string | TooltipDataChild;
value: string | TooltipDataChild;
}
export declare enum TooltipIconPosition {
Left = "left",
Middle = "middle",
Right = "right"
}
export interface TooltipIconStyle {
id: string;
position: TooltipIconPosition;
marginLeft: number;
marginTop: number;
marginRight: number;
marginBottom: number;
paddingLeft: number;
paddingTop: number;
paddingRight: number;
paddingBottom: number;
color: string;
activeColor: string;
size: number;
fontFamily: string;
icon: string;
backgroundColor: string;
activeBackgroundColor: string;
}
export interface TooltipStyle {
showRule: TooltipShowRule;
showType: TooltipShowType;
defaultValue: string;
text: TooltipTextStyle;
icons: TooltipIconStyle[];
}
export interface CandleAreaStyle {
lineSize: number;
lineColor: string;
value: string;
backgroundColor: string | GradientColor[];
}
export interface CandleHighLowPriceMarkStyle {
show: boolean;
color: string;
textOffset: number;
textSize: number;
textFamily: string;
textWeight: string;
}
export type CandleLastPriceMarkLineStyle = Omit<StateLineStyle, "color">;
export interface CandleLastPriceMarkStyle extends ChangeColor {
show: boolean;
line: CandleLastPriceMarkLineStyle;
text: LastValueMarkTextStyle;
}
export interface CandlePriceMarkStyle {
show: boolean;
high: CandleHighLowPriceMarkStyle;
low: CandleHighLowPriceMarkStyle;
last: CandleLastPriceMarkStyle;
}
export interface CandleTooltipRectStyle extends Omit<RectStyle, "style" | "borderDashedValue" | "borderStyle"> {
paddingLeft: number;
paddingRight: number;
paddingTop: number;
paddingBottom: number;
offsetLeft: number;
offsetTop: number;
offsetRight: number;
}
export interface CandleTooltipCustomCallbackData {
prev: Nullable<KLineData>;
current: KLineData;
next: Nullable<KLineData>;
}
export type CandleTooltipCustomCallback = (data: CandleTooltipCustomCallbackData, styles: CandleStyle) => TooltipData[];
export interface CandleTooltipStyle extends TooltipStyle {
custom: Nullable<CandleTooltipCustomCallback>;
rect: CandleTooltipRectStyle;
}
export declare enum CandleType {
CandleSolid = "candle_solid",
CandleStroke = "candle_stroke",
CandleUpStroke = "candle_up_stroke",
CandleDownStroke = "candle_down_stroke",
Ohlc = "ohlc",
Area = "area"
}
export interface CandleStyle {
type: CandleType;
bar: ChangeColor;
area: CandleAreaStyle;
priceMark: CandlePriceMarkStyle;
tooltip: CandleTooltipStyle;
}
export type IndicatorPolygonStyle = Omit<PolygonStyle, "color" | "borderColor"> & ChangeColor;
export interface IndicatorLastValueMarkStyle {
show: boolean;
text: LastValueMarkTextStyle;
}
export interface IndicatorTooltipStyle extends TooltipStyle {
showName: boolean;
showParams: boolean;
}
export interface IndicatorStyle {
ohlc: ChangeColor;
bars: IndicatorPolygonStyle[];
lines: SmoothLineStyle[];
circles: IndicatorPolygonStyle[];
lastValueMark: IndicatorLastValueMarkStyle;
tooltip: IndicatorTooltipStyle;
}
export type AxisLineStyle = Omit<StateLineStyle, "style" | "dashedValue">;
export interface AxisTickLineStyle extends AxisLineStyle {
length: number;
}
export interface AxisTickTextStyle extends StateTextStyle {
marginStart: number;
marginEnd: number;
}
export interface AxisStyle {
show: boolean;
size: number | "auto";
axisLine: AxisLineStyle;
tickLine: AxisTickLineStyle;
tickText: AxisTickTextStyle;
}
export type XAxisStyle = AxisStyle;
export declare enum YAxisPosition {
Left = "left",
Right = "right"
}
export declare enum YAxisType {
Normal = "normal",
Percentage = "percentage",
Log = "log"
}
export interface YAxisStyle extends AxisStyle {
type: YAxisType;
position: YAxisPosition;
inside: boolean;
reverse: boolean;
}
export interface CrosshairDirectionStyle {
show: boolean;
line: StateLineStyle;
text: StateRectTextStyle;
}
export interface CrosshairStyle {
show: boolean;
horizontal: CrosshairDirectionStyle;
vertical: CrosshairDirectionStyle;
}
export interface OverlayPointStyle {
color: string;
borderColor: string;
borderSize: number;
radius: number;
activeColor: string;
activeBorderColor: string;
activeBorderSize: number;
activeRadius: number;
}
export interface OverlayStyle {
point: OverlayPointStyle;
line: SmoothLineStyle;
rect: RectStyle;
polygon: PolygonStyle;
circle: PolygonStyle;
arc: LineStyle;
text: TextStyle;
rectText: RectTextStyle;
}
export interface SeparatorStyle {
size: number;
color: string;
fill: boolean;
activeBackgroundColor: string;
}
export interface Styles {
grid: GridStyle;
candle: CandleStyle;
indicator: IndicatorStyle;
xAxis: XAxisStyle;
yAxis: YAxisStyle;
separator: SeparatorStyle;
crosshair: CrosshairStyle;
overlay: OverlayStyle;
}
export declare enum FormatDateType {
Tooltip = 0,
Crosshair = 1,
XAxis = 2
}
export type FormatDate = (dateTimeFormat: Intl.DateTimeFormat, timestamp: number, format: string, type: FormatDateType) => string;
export type FormatBigNumber = (value: string | number) => string;
export interface CustomApi {
formatDate: FormatDate;
formatBigNumber: FormatBigNumber;
}
export interface Locales {
time: string;
open: string;
high: string;
low: string;
close: string;
volume: string;
}
export interface Options {
locale?: string;
timezone?: string;
styles?: string | DeepPartial<Styles>;
customApi?: Partial<CustomApi>;
}
/**
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export interface Bounding {
width: number;
height: number;
left: number;
right: number;
top: number;
bottom: number;
}
/**
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export interface Coordinate {
x: number;
y: number;
}
/**
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export interface Point {
dataIndex: number;
timestamp: number;
value: number;
}
export interface Crosshair extends Partial<Coordinate> {
paneId?: string;
realX?: number;
kLineData?: KLineData;
dataIndex?: number;
realDataIndex?: number;
}
/**
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export type ActionCallback = (data?: any) => void;
export declare enum ActionType {
OnZoom = "onZoom",
OnScroll = "onScroll",
OnVisibleRangeChange = "onVisibleRangeChange",
OnTooltipIconClick = "onTooltipIconClick",
OnCrosshairChange = "onCrosshairChange",
OnCandleBarClick = "onCandleBarClick",
OnPaneDrag = "onPaneDrag"
}
export type LoadMoreCallback = (timestamp: Nullable<number>) => void;
/**
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export interface Precision {
price: number;
volume: number;
}
/**
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export interface VisibleRange {
from: number;
to: number;
}
/**
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export interface BarSpace {
bar: number;
halfBar: number;
gapBar: number;
halfGapBar: number;
}
/**
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export type ExcludePickPartial<T, K extends keyof T> = Partial<Omit<T, K>> & Pick<T, K>;
export interface MouseTouchEvent extends Coordinate {
pageX: number;
pageY: number;
isTouch?: boolean;
preventDefault?: () => void;
}
export interface YAxis extends Axis {
isFromZero: () => boolean;
}
export interface PaneGap {
top?: number;
bottom?: number;
}
export interface PaneOptions {
id?: string;
height?: number;
minHeight?: number;
dragEnabled?: boolean;
gap?: PaneGap;
}
export interface Axis {
convertToPixel: (value: number) => number;
convertFromPixel: (px: number) => number;
}
export type XAxis = Axis;
export declare enum IndicatorSeries {
Normal = "normal",
Price = "price",
Volume = "volume"
}
export interface IndicatorFigureStyle {
style?: LineType[keyof LineType] | PolygonType[keyof PolygonType];
color?: string;
}
export interface IndicatorFigureStylesCallbackDataChild<D> {
kLineData?: KLineData;
indicatorData?: D;
}
export interface IndicatorFigureStylesCallbackData<D> {
prev: IndicatorFigureStylesCallbackDataChild<D>;
current: IndicatorFigureStylesCallbackDataChild<D>;
next: IndicatorFigureStylesCallbackDataChild<D>;
}
export type IndicatorFigureStylesCallback<D> = (data: IndicatorFigureStylesCallbackData<D>, indicator: Indicator<D>, defaultStyles: IndicatorStyle) => IndicatorFigureStyle;
export interface IndicatorFigure<D = any> {
key: string;
title?: string;
type?: string;
baseValue?: number;
styles?: IndicatorFigureStylesCallback<D>;
}
export type IndicatorRegenerateFiguresCallback<D = any> = (calcParms: any[]) => Array<IndicatorFigure<D>>;
export interface IndicatorTooltipData {
name: string;
calcParamsText: string;
icons: TooltipIconStyle[];
values: TooltipData[];
}
export interface IndicatorCreateTooltipDataSourceParams<D = any> {
kLineDataList: KLineData[];
indicator: Indicator<D>;
visibleRange: VisibleRange;
bounding: Bounding;
crosshair: Crosshair;
defaultStyles: IndicatorStyle;
xAxis: XAxis;
yAxis: YAxis;
}
export type IndicatorCreateTooltipDataSourceCallback<D = any> = (params: IndicatorCreateTooltipDataSourceParams<D>) => IndicatorTooltipData;
export interface IndicatorDrawParams<D = any> {
ctx: CanvasRenderingContext2D;
kLineDataList: KLineData[];
indicator: Indicator<D>;
visibleRange: VisibleRange;
bounding: Bounding;
barSpace: BarSpace;
defaultStyles: IndicatorStyle;
xAxis: XAxis;
yAxis: YAxis;
}
export type IndicatorDrawCallback<D = any> = (params: IndicatorDrawParams<D>) => boolean;
export type IndicatorCalcCallback<D> = (dataList: KLineData[], indicator: Indicator<D>) => Promise<D[]> | D[];
export interface Indicator<D = any> {
/**
* Indicator name
*/
name: string;
/**
* Short name, for display
*/
shortName: string;
/**
* Precision
*/
precision: number;
/**
* Calculation parameters
*/
calcParams: any[];
/**
* Whether ohlc column is required
*/
shouldOhlc: boolean;
/**
* Whether large data values need to be formatted, starting from 1000, for example, whether 100000 needs to be formatted with 100K
*/
shouldFormatBigNumber: boolean;
/**
* Whether the indicator is visible
*/
visible: boolean;
/**
* Extend data
*/
extendData: any;
/**
* Indicator series
*/
series: IndicatorSeries;
/**
* Figure configuration information
*/
figures: Array<IndicatorFigure<D>>;
/**
* Specified minimum value
*/
minValue: Nullable<number>;
/**
* Specified maximum value
*/
maxValue: Nullable<number>;
/**
* Style configuration
*/
styles: Nullable<Partial<IndicatorStyle>>;
/**
* Indicator calculation
*/
calc: IndicatorCalcCallback<D>;
/**
* Regenerate figure configuration
*/
regenerateFigures: Nullable<IndicatorRegenerateFiguresCallback<D>>;
/**
* Create custom tooltip text
*/
createTooltipDataSource: Nullable<IndicatorCreateTooltipDataSourceCallback>;
/**
* Custom draw
*/
draw: Nullable<IndicatorDrawCallback<D>>;
/**
* Calculation result
*/
result: D[];
}
export type IndicatorTemplate<D = any> = ExcludePickPartial<Omit<Indicator<D>, "reult">, "name" | "calc">;
export type IndicatorCreate<D = any> = ExcludePickPartial<Omit<Indicator<D>, "reult">, "name">;
export declare enum OverlayMode {
Normal = "normal",
WeakMagnet = "weak_magnet",
StrongMagnet = "strong_magnet"
}
export interface OverlayPerformEventParams {
currentStep: number;
mode: OverlayMode;
points: Array<Partial<Point>>;
performPointIndex: number;
performPoint: Partial<Point>;
}
export interface OverlayFigure {
key?: string;
type: string;
attrs: any | any[];
styles?: any;
ignoreEvent?: boolean;
}
export interface OverlayCreateFiguresCallbackParams {
overlay: Overlay;
coordinates: Coordinate[];
bounding: Bounding;
barSpace: BarSpace;
precision: Precision;
dateTimeFormat: Intl.DateTimeFormat;
defaultStyles: OverlayStyle;
xAxis: Nullable<XAxis>;
yAxis: Nullable<YAxis>;
}
export interface OverlayEvent extends Partial<MouseTouchEvent> {
overlay: Overlay;
}
export type OverlayEventCallback = (event: OverlayEvent) => boolean;
export type OverlayCreateFiguresCallback = (params: OverlayCreateFiguresCallbackParams) => OverlayFigure | OverlayFigure[];
export interface Overlay {
/**
* Unique identification
*/
id: string;
/**
* Group id
*/
groupId: string;
/**
* Name
*/
name: string;
/**
* Total number of steps required to complete mouse operation
*/
totalStep: number;
/**
* Current step
*/
currentStep: number;
/**
* Whether it is locked. When it is true, it will not respond to events
*/
lock: boolean;
/**
* Whether the overlay is visible
*/
visible: boolean;
/**
* Whether the default figure corresponding to the point is required
*/
needDefaultPointFigure: boolean;
/**
* Whether the default figure on the Y axis is required
*/
needDefaultXAxisFigure: boolean;
/**
* Whether the default figure on the X axis is required
*/
needDefaultYAxisFigure: boolean;
/**
* Mode
*/
mode: OverlayMode;
/**
* Time and value information
*/
points: Array<Partial<Point>>;
/**
* Extended Data
*/
extendData: any;
/**
* The style information and format are consistent with the overlay in the unified configuration
*/
styles: Nullable<DeepPartial<OverlayStyle>>;
/**
* Create figures corresponding to points
*/
createPointFigures: Nullable<OverlayCreateFiguresCallback>;
/**
* Create figures on the Y axis
*/
createXAxisFigures: Nullable<OverlayCreateFiguresCallback>;
/**
* Create figures on the X axis
*/
createYAxisFigures: Nullable<OverlayCreateFiguresCallback>;
/**
* Special handling callbacks when pressing events
*/
performEventPressedMove: Nullable<(params: OverlayPerformEventParams) => void>;
/**
* In drawing, special handling callback when moving events
*/
performEventMoveForDrawing: Nullable<(params: OverlayPerformEventParams) => void>;
/**
* Start drawing event
*/
onDrawStart: Nullable<OverlayEventCallback>;
/**
* In drawing event
*/
onDrawing: Nullable<OverlayEventCallback>;
/**
* Draw End Event
*/
onDrawEnd: Nullable<OverlayEventCallback>;
/**
* Click event
*/
onClick: Nullable<OverlayEventCallback>;
/**
* Right click event
*/
onRightClick: Nullable<OverlayEventCallback>;
/**
* Pressed move start event
*/
onPressedMoveStart: Nullable<OverlayEventCallback>;
/**
* Pressed moving event
*/
onPressedMoving: Nullable<OverlayEventCallback>;
/**
* Pressed move end event
*/
onPressedMoveEnd: Nullable<OverlayEventCallback>;
/**
* Mouse enter event
*/
onMouseEnter: Nullable<OverlayEventCallback>;
/**
* Mouse leave event
*/
onMouseLeave: Nullable<OverlayEventCallback>;
/**
* Removed event
*/
onRemoved: Nullable<OverlayEventCallback>;
/**
* Selected event
*/
onSelected: Nullable<OverlayEventCallback>;
/**
* Deselected event
*/
onDeselected: Nullable<OverlayEventCallback>;
}
export type OverlayTemplate = ExcludePickPartial<Omit<Overlay, "id" | "groupId" | "points" | "currentStep">, "name">;
export type OverlayCreate = ExcludePickPartial<Omit<Overlay, "currentStep" | "totalStep" | "createPointFigures" | "createXAxisFigures" | "createYAxisFigures" | "performEventPressedMove" | "performEventMoveForDrawing">, "name">;
export type OverlayRemove = Partial<Pick<Overlay, "id" | "groupId" | "name">>;
export declare enum DomPosition {
Root = "root",
Main = "main",
YAxis = "yAxis"
}
export interface ConvertFinder {
paneId?: string;
absolute?: boolean;
}
export interface Chart {
getDom: (paneId?: string, position?: DomPosition) => Nullable<HTMLElement>;
getSize: (paneId?: string, position?: DomPosition) => Nullable<Bounding>;
setLocale: (locale: string) => void;
getLocale: () => string;
setStyles: (styles: string | DeepPartial<Styles>) => void;
getStyles: () => Styles;
setCustomApi: (customApi: Partial<CustomApi>) => void;
setPriceVolumePrecision: (pricePrecision: number, volumePrecision: number) => void;
getPriceVolumePrecision: () => Precision;
setTimezone: (timezone: string) => void;
getTimezone: () => string;
setOffsetRightDistance: (space: number) => void;
setLeftMinVisibleBarCount: (barCount: number) => void;
setRightMinVisibleBarCount: (barCount: number) => void;
setBarSpace: (space: number) => void;
getBarSpace: () => number;
getVisibleRange: () => VisibleRange;
clearData: () => void;
getDataList: () => KLineData[];
applyNewData: (dataList: KLineData[], more?: boolean) => void;
applyMoreData: (dataList: KLineData[], more?: boolean) => void;
updateData: (data: KLineData) => void;
loadMore: (cb: LoadMoreCallback) => void;
createIndicator: (value: string | IndicatorCreate, isStack?: boolean, paneOptions?: PaneOptions, callback?: () => void) => Nullable<string>;
overrideIndicator: (override: IndicatorCreate, paneId?: string, callback?: () => void) => void;
getIndicatorByPaneId: (paneId?: string, name?: string) => Nullable<Indicator> | Nullable<Map<string, Indicator>> | Map<string, Map<string, Indicator>>;
removeIndicator: (paneId: string, name?: string) => void;
createOverlay: (value: string | OverlayCreate, paneId?: string) => Nullable<string>;
getOverlayById: (id: string) => Nullable<Overlay>;
overrideOverlay: (override: Partial<OverlayCreate>) => void;
removeOverlay: (remove?: string | OverlayRemove) => void;
setPaneOptions: (options: PaneOptions) => void;
setZoomEnabled: (enabled: boolean) => void;
isZoomEnabled: () => boolean;
setScrollEnabled: (enabled: boolean) => void;
isScrollEnabled: () => boolean;
scrollByDistance: (distance: number, animationDuration?: number) => void;
scrollToRealTime: (animationDuration?: number) => void;
scrollToDataIndex: (dataIndex: number, animationDuration?: number) => void;
scrollToTimestamp: (timestamp: number, animationDuration?: number) => void;
zoomAtCoordinate: (scale: number, coordinate?: Coordinate, animationDuration?: number) => void;
zoomAtDataIndex: (scale: number, dataIndex: number, animationDuration?: number) => void;
zoomAtTimestamp: (scale: number, timestamp: number, animationDuration?: number) => void;
convertToPixel: (points: Partial<Point> | Array<Partial<Point>>, finder: ConvertFinder) => Partial<Coordinate> | Array<Partial<Coordinate>>;
convertFromPixel: (coordinates: Array<Partial<Coordinate>>, finder: ConvertFinder) => Partial<Point> | Array<Partial<Point>>;
subscribeAction: (type: ActionType, callback: ActionCallback) => void;
unsubscribeAction: (type: ActionType, callback?: ActionCallback) => void;
getConvertPictureUrl: (includeOverlay?: boolean, type?: string, backgroundColor?: string) => string;
resize: () => void;
destroy: () => void;
}
export interface Figure<A = any, S = any> {
name: string;
attrs: A;
styles: S;
draw: (ctx: CanvasRenderingContext2D, attrs: A, styles: S) => void;
checkEventOn: (coordinate: Coordinate, attrs: A, styles: S) => boolean;
}
export type FigureTemplate<A = any, S = any> = Pick<Figure<A, S>, "name" | "draw" | "checkEventOn">;
export type FigureCreate<A = any, S = any> = Pick<Figure<A, S>, "name" | "attrs" | "styles">;
export type FigureConstructor<A = any, S = any> = new (figure: FigureCreate<A, S>) => ({
draw: (ctx: CanvasRenderingContext2D) => void;
});
declare function checkCoordinateOnArc(coordinate: Coordinate, arc: ArcAttrs): boolean;
declare function drawArc(ctx: CanvasRenderingContext2D, attrs: ArcAttrs, styles: Partial<LineStyle>): void;
export interface ArcAttrs {
x: number;
y: number;
r: number;
startAngle: number;
endAngle: number;
}
declare function checkCoordinateOnCircle(coordinate: Coordinate, circle: CircleAttrs): boolean;
declare function drawCircle(ctx: CanvasRenderingContext2D, attrs: CircleAttrs, styles: Partial<PolygonStyle>): void;
export interface CircleAttrs {
x: number;
y: number;
r: number;
}
declare function checkCoordinateOnLine(coordinate: Coordinate, line: LineAttrs): boolean;
declare function getLinearYFromSlopeIntercept(kb: Nullable<number[]>, coordinate: Coordinate): number;
declare function getLinearYFromCoordinates(coordinate1: Coordinate, coordinate2: Coordinate, targetCoordinate: Coordinate): number;
declare function getLinearSlopeIntercept(coordinate1: Coordinate, coordinate2: Coordinate): Nullable<number[]>;
declare function drawLine(ctx: CanvasRenderingContext2D, attrs: LineAttrs, styles: Partial<SmoothLineStyle>): void;
export interface LineAttrs {
coordinates: Coordinate[];
}
declare function checkCoordinateOnPolygon(coordinate: Coordinate, polygon: PolygonAttrs): boolean;
declare function drawPolygon(ctx: CanvasRenderingContext2D, attrs: PolygonAttrs, styles: Partial<PolygonStyle>): void;
export interface PolygonAttrs {
coordinates: Coordinate[];
}
declare function checkCoordinateOnRect(coordinate: Coordinate, rect: RectAttrs): boolean;
declare function drawRect(ctx: CanvasRenderingContext2D, attrs: RectAttrs, styles: Partial<RectStyle>): void;
export interface RectAttrs {
x: number;
y: number;
width: number;
height: number;
}
declare function checkCoordinateOnText(coordinate: Coordinate, attrs: TextAttrs, styles: Partial<RectTextStyle>): boolean;
declare function drawText(ctx: CanvasRenderingContext2D, attrs: TextAttrs, styles: Partial<TextStyle>): void;
export interface TextAttrs {
x: number;
y: number;
text: string;
align?: CanvasTextAlign;
baseline?: CanvasTextBaseline;
}
declare function drawRectText(ctx: CanvasRenderingContext2D, attrs: TextAttrs, styles: Partial<RectTextStyle>): void;
export declare function getSupportedFigures(): string[];
export declare function registerFigure<A = any, S = any>(figure: FigureTemplate<A, S>): void;
export declare function getFigureClass<A = any, S = any>(name: string): Nullable<FigureConstructor<A, S>>;
export declare function registerIndicator<D>(indicator: IndicatorTemplate<D>): void;
export declare function getSupportedIndicators(): string[];
export declare function registerLocale(locale: string, ls: Locales): void;
export declare function getSupportedLocales(): string[];
export declare function registerOverlay(template: OverlayTemplate): void;
export declare function getSupportedOverlays(): string[];
export declare function registerStyles(name: string, ss: DeepPartial<Styles>): void;
declare function merge(target: any, source: any): void;
declare function clone(target: any): any;
declare function isArray(value: any): boolean;
declare function isFunction(value: any): boolean;
declare function isObject(value: any): boolean;
declare function isNumber(value: any): boolean;
declare function isValid(value: any | null): boolean;
declare function isBoolean(value: any): boolean;
declare function isString(value: any): boolean;
declare function formatValue(data: unknown, key: string, defaultValue?: unknown): unknown;
declare function formatDate(dateTimeFormat: Intl.DateTimeFormat, timestamp: number, format: string): string;
declare function formatPrecision(value: string | number, precision?: number): string;
declare function formatBigNumber(value: string | number): string;
/**
* Chart version
* @return {string}
*/
export declare function version(): string;
/**
* Init chart instance
* @param ds
* @param options
* @returns {Chart}
*/
export declare function init(ds: HTMLElement | string, options?: Options): Chart | null;
/**
* Destory chart instace
* @param dcs
*/