1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | export type Nullable<T> = T | null;
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | export interface KLineData {
|
29 | timestamp: number;
|
30 | open: number;
|
31 | high: number;
|
32 | low: number;
|
33 | close: number;
|
34 | volume?: number;
|
35 | turnover?: number;
|
36 | [key: string]: any;
|
37 | }
|
38 | export interface Margin {
|
39 | marginLeft: number;
|
40 | marginTop: number;
|
41 | marginRight: number;
|
42 | marginBottom: number;
|
43 | }
|
44 | export interface Padding {
|
45 | paddingLeft: number;
|
46 | paddingTop: number;
|
47 | paddingRight: number;
|
48 | paddingBottom: number;
|
49 | }
|
50 | export interface Offset {
|
51 | offsetLeft: number;
|
52 | offsetTop: number;
|
53 | offsetRight: number;
|
54 | offsetBottom: number;
|
55 | }
|
56 |
|
57 |
|
58 |
|
59 | export declare enum LineType {
|
60 | Dashed = "dashed",
|
61 | Solid = "solid"
|
62 | }
|
63 | export interface LineStyle {
|
64 | style: LineType;
|
65 | size: number;
|
66 | color: string;
|
67 | dashedValue: number[];
|
68 | }
|
69 | export interface SmoothLineStyle extends LineStyle {
|
70 | smooth: boolean | number;
|
71 | }
|
72 | export interface StateLineStyle extends LineStyle {
|
73 | show: boolean;
|
74 | }
|
75 | export declare enum PolygonType {
|
76 | Stroke = "stroke",
|
77 | Fill = "fill",
|
78 | StrokeFill = "stroke_fill"
|
79 | }
|
80 | export interface PolygonStyle {
|
81 | style: PolygonType;
|
82 | color: string | CanvasGradient;
|
83 | borderColor: string;
|
84 | borderSize: number;
|
85 | borderStyle: LineType;
|
86 | borderDashedValue: number[];
|
87 | }
|
88 | export interface RectStyle extends PolygonStyle {
|
89 | borderRadius: number;
|
90 | }
|
91 | export interface TextStyle extends Padding {
|
92 | style: PolygonType;
|
93 | color: string;
|
94 | size: number;
|
95 | family: string;
|
96 | weight: number | string;
|
97 | borderStyle: LineType;
|
98 | borderDashedValue: number[];
|
99 | borderSize: number;
|
100 | borderColor: string;
|
101 | borderRadius: number;
|
102 | backgroundColor: string | CanvasGradient;
|
103 | }
|
104 | export interface StateTextStyle extends TextStyle {
|
105 | show: boolean;
|
106 | }
|
107 | export type LastValueMarkTextStyle = Omit<StateTextStyle, "backgroundColor">;
|
108 | export declare enum TooltipShowRule {
|
109 | Always = "always",
|
110 | FollowCross = "follow_cross",
|
111 | None = "none"
|
112 | }
|
113 | export declare enum TooltipShowType {
|
114 | Standard = "standard",
|
115 | Rect = "rect"
|
116 | }
|
117 | export interface ChangeColor {
|
118 | upColor: string;
|
119 | downColor: string;
|
120 | noChangeColor: string;
|
121 | }
|
122 | export interface GradientColor {
|
123 | offset: number;
|
124 | color: string;
|
125 | }
|
126 | export interface GridStyle {
|
127 | show: boolean;
|
128 | horizontal: StateLineStyle;
|
129 | vertical: StateLineStyle;
|
130 | }
|
131 | export type TooltipTextStyle = Pick<TextStyle, "color" | "size" | "family" | "weight"> & Margin;
|
132 | export interface TooltipLegendChild {
|
133 | text: string;
|
134 | color: string;
|
135 | }
|
136 | export interface TooltipLegend {
|
137 | title: string | TooltipLegendChild;
|
138 | value: string | TooltipLegendChild;
|
139 | }
|
140 | export declare enum TooltipIconPosition {
|
141 | Left = "left",
|
142 | Middle = "middle",
|
143 | Right = "right"
|
144 | }
|
145 | export interface TooltipIconStyle extends Padding, Margin {
|
146 | id: string;
|
147 | position: TooltipIconPosition;
|
148 | color: string;
|
149 | activeColor: string;
|
150 | size: number;
|
151 | fontFamily: string;
|
152 | icon: string;
|
153 | backgroundColor: string;
|
154 | activeBackgroundColor: string;
|
155 | }
|
156 | export interface TooltipStyle {
|
157 | showRule: TooltipShowRule;
|
158 | showType: TooltipShowType;
|
159 | defaultValue: string;
|
160 | text: TooltipTextStyle;
|
161 | icons: TooltipIconStyle[];
|
162 | }
|
163 | export interface CandleAreaPointStyle {
|
164 | show: boolean;
|
165 | color: string;
|
166 | radius: number;
|
167 | rippleColor: string;
|
168 | rippleRadius: number;
|
169 | animation: boolean;
|
170 | animationDuration: number;
|
171 | }
|
172 | export interface CandleAreaStyle {
|
173 | lineSize: number;
|
174 | lineColor: string;
|
175 | value: string;
|
176 | smooth: boolean;
|
177 | backgroundColor: string | GradientColor[];
|
178 | point: CandleAreaPointStyle;
|
179 | }
|
180 | export interface CandleHighLowPriceMarkStyle {
|
181 | show: boolean;
|
182 | color: string;
|
183 | textOffset: number;
|
184 | textSize: number;
|
185 | textFamily: string;
|
186 | textWeight: string;
|
187 | }
|
188 | export type CandleLastPriceMarkLineStyle = Omit<StateLineStyle, "color">;
|
189 | export interface CandleLastPriceMarkStyle extends ChangeColor {
|
190 | show: boolean;
|
191 | line: CandleLastPriceMarkLineStyle;
|
192 | text: LastValueMarkTextStyle;
|
193 | }
|
194 | export interface CandlePriceMarkStyle {
|
195 | show: boolean;
|
196 | high: CandleHighLowPriceMarkStyle;
|
197 | low: CandleHighLowPriceMarkStyle;
|
198 | last: CandleLastPriceMarkStyle;
|
199 | }
|
200 | declare enum CandleTooltipRectPosition {
|
201 | Fixed = "fixed",
|
202 | Pointer = "pointer"
|
203 | }
|
204 | export interface CandleTooltipRectStyle extends Omit<RectStyle, "style" | "borderDashedValue" | "borderStyle">, Padding, Offset {
|
205 | position: CandleTooltipRectPosition;
|
206 | }
|
207 | export interface CandleTooltipCustomCallbackData {
|
208 | prev: Nullable<KLineData>;
|
209 | current: KLineData;
|
210 | next: Nullable<KLineData>;
|
211 | }
|
212 | export type CandleTooltipCustomCallback = (data: CandleTooltipCustomCallbackData, styles: CandleStyle) => TooltipLegend[];
|
213 | export interface CandleTooltipStyle extends TooltipStyle, Offset {
|
214 | custom: CandleTooltipCustomCallback | TooltipLegend[];
|
215 | rect: CandleTooltipRectStyle;
|
216 | }
|
217 | export declare enum CandleType {
|
218 | CandleSolid = "candle_solid",
|
219 | CandleStroke = "candle_stroke",
|
220 | CandleUpStroke = "candle_up_stroke",
|
221 | CandleDownStroke = "candle_down_stroke",
|
222 | Ohlc = "ohlc",
|
223 | Area = "area"
|
224 | }
|
225 | export interface CandleBarColor extends ChangeColor {
|
226 | upBorderColor: string;
|
227 | downBorderColor: string;
|
228 | noChangeBorderColor: string;
|
229 | upWickColor: string;
|
230 | downWickColor: string;
|
231 | noChangeWickColor: string;
|
232 | }
|
233 | export interface CandleStyle {
|
234 | type: CandleType;
|
235 | bar: CandleBarColor;
|
236 | area: CandleAreaStyle;
|
237 | priceMark: CandlePriceMarkStyle;
|
238 | tooltip: CandleTooltipStyle;
|
239 | }
|
240 | export type IndicatorPolygonStyle = Omit<PolygonStyle, "color" | "borderColor"> & ChangeColor;
|
241 | export interface IndicatorLastValueMarkStyle {
|
242 | show: boolean;
|
243 | text: LastValueMarkTextStyle;
|
244 | }
|
245 | export interface IndicatorTooltipStyle extends TooltipStyle, Offset {
|
246 | showName: boolean;
|
247 | showParams: boolean;
|
248 | }
|
249 | export interface IndicatorStyle {
|
250 | ohlc: ChangeColor;
|
251 | bars: IndicatorPolygonStyle[];
|
252 | lines: SmoothLineStyle[];
|
253 | circles: IndicatorPolygonStyle[];
|
254 | lastValueMark: IndicatorLastValueMarkStyle;
|
255 | tooltip: IndicatorTooltipStyle;
|
256 | [key: string]: any;
|
257 | }
|
258 | export type AxisLineStyle = Omit<StateLineStyle, "style" | "dashedValue">;
|
259 | export interface AxisTickLineStyle extends AxisLineStyle {
|
260 | length: number;
|
261 | }
|
262 | export interface AxisTickTextStyle extends Pick<StateTextStyle, "show" | "color" | "weight" | "family" | "size"> {
|
263 | marginStart: number;
|
264 | marginEnd: number;
|
265 | }
|
266 | export interface AxisStyle {
|
267 | show: boolean;
|
268 | size: number | "auto";
|
269 | axisLine: AxisLineStyle;
|
270 | tickLine: AxisTickLineStyle;
|
271 | tickText: AxisTickTextStyle;
|
272 | }
|
273 | export type XAxisStyle = AxisStyle;
|
274 | export declare enum YAxisPosition {
|
275 | Left = "left",
|
276 | Right = "right"
|
277 | }
|
278 | export declare enum YAxisType {
|
279 | Normal = "normal",
|
280 | Percentage = "percentage",
|
281 | Log = "log"
|
282 | }
|
283 | export interface YAxisStyle extends AxisStyle {
|
284 | type: YAxisType;
|
285 | position: YAxisPosition;
|
286 | inside: boolean;
|
287 | reverse: boolean;
|
288 | }
|
289 | export interface CrosshairDirectionStyle {
|
290 | show: boolean;
|
291 | line: StateLineStyle;
|
292 | text: StateTextStyle;
|
293 | }
|
294 | export interface CrosshairStyle {
|
295 | show: boolean;
|
296 | horizontal: CrosshairDirectionStyle;
|
297 | vertical: CrosshairDirectionStyle;
|
298 | }
|
299 | export interface OverlayPointStyle {
|
300 | color: string;
|
301 | borderColor: string;
|
302 | borderSize: number;
|
303 | radius: number;
|
304 | activeColor: string;
|
305 | activeBorderColor: string;
|
306 | activeBorderSize: number;
|
307 | activeRadius: number;
|
308 | }
|
309 | export interface OverlayStyle {
|
310 | point: OverlayPointStyle;
|
311 | line: SmoothLineStyle;
|
312 | rect: RectStyle;
|
313 | polygon: PolygonStyle;
|
314 | circle: PolygonStyle;
|
315 | arc: LineStyle;
|
316 | text: TextStyle;
|
317 | |
318 |
|
319 |
|
320 |
|
321 | rectText: TextStyle;
|
322 | [key: string]: any;
|
323 | }
|
324 | export interface SeparatorStyle {
|
325 | size: number;
|
326 | color: string;
|
327 | fill: boolean;
|
328 | activeBackgroundColor: string;
|
329 | }
|
330 | export interface Styles {
|
331 | grid: GridStyle;
|
332 | candle: CandleStyle;
|
333 | indicator: IndicatorStyle;
|
334 | xAxis: XAxisStyle;
|
335 | yAxis: YAxisStyle;
|
336 | separator: SeparatorStyle;
|
337 | crosshair: CrosshairStyle;
|
338 | overlay: OverlayStyle;
|
339 | }
|
340 | declare function merge(target: any, source: any): void;
|
341 | declare function clone<T>(target: T): T;
|
342 | declare function isArray<T = any>(value: any): value is T[];
|
343 | declare function isFunction<T = (...args: any) => any>(value: any): value is T;
|
344 | declare function isObject(value: any): value is object;
|
345 | declare function isNumber(value: any): value is number;
|
346 | declare function isValid<T>(value: T | null | undefined): value is T;
|
347 | declare function isBoolean(value: any): value is boolean;
|
348 | declare function isString(value: any): value is string;
|
349 | declare function formatValue(data: unknown, key: string, defaultValue?: unknown): unknown;
|
350 | declare function formatDate(dateTimeFormat: Intl.DateTimeFormat, timestamp: number, format: string): string;
|
351 | declare function formatPrecision(value: string | number, precision?: number): string;
|
352 | declare function formatBigNumber(value: string | number): string;
|
353 | declare function formatThousands(value: string | number, sign: string): string;
|
354 | declare function formatFoldDecimal(value: string | number, threshold: number): string;
|
355 | declare function calcTextWidth(text: string, size?: number, weight?: string | number, family?: string): number;
|
356 |
|
357 |
|
358 |
|
359 |
|
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 | export type ActionCallback = (data?: any) => void;
|
370 | export declare enum ActionType {
|
371 | OnDataReady = "onDataReady",
|
372 | OnZoom = "onZoom",
|
373 | OnScroll = "onScroll",
|
374 | OnVisibleRangeChange = "onVisibleRangeChange",
|
375 | OnTooltipIconClick = "onTooltipIconClick",
|
376 | OnCrosshairChange = "onCrosshairChange",
|
377 | OnCandleBarClick = "onCandleBarClick",
|
378 | OnPaneDrag = "onPaneDrag"
|
379 | }
|
380 |
|
381 |
|
382 |
|
383 |
|
384 |
|
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 | export type ExcludePickPartial<T, K extends keyof T> = Partial<Omit<T, K>> & Pick<T, K>;
|
394 |
|
395 |
|
396 |
|
397 |
|
398 |
|
399 |
|
400 |
|
401 |
|
402 |
|
403 |
|
404 |
|
405 |
|
406 |
|
407 | export interface Bounding {
|
408 | width: number;
|
409 | height: number;
|
410 | left: number;
|
411 | right: number;
|
412 | top: number;
|
413 | bottom: number;
|
414 | }
|
415 |
|
416 |
|
417 |
|
418 |
|
419 |
|
420 |
|
421 |
|
422 |
|
423 |
|
424 |
|
425 |
|
426 |
|
427 |
|
428 | export interface VisibleRange {
|
429 | readonly from: number;
|
430 | readonly to: number;
|
431 | readonly realFrom: number;
|
432 | readonly realTo: number;
|
433 | }
|
434 |
|
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 |
|
441 |
|
442 |
|
443 |
|
444 |
|
445 |
|
446 |
|
447 | export interface BarSpace {
|
448 | bar: number;
|
449 | halfBar: number;
|
450 | gapBar: number;
|
451 | halfGapBar: number;
|
452 | }
|
453 |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 |
|
459 |
|
460 |
|
461 |
|
462 |
|
463 |
|
464 |
|
465 |
|
466 | export interface Coordinate {
|
467 | x: number;
|
468 | y: number;
|
469 | }
|
470 | export interface Crosshair extends Partial<Coordinate> {
|
471 | paneId?: string;
|
472 | realX?: number;
|
473 | kLineData?: KLineData;
|
474 | dataIndex?: number;
|
475 | realDataIndex?: number;
|
476 | }
|
477 | export interface MouseTouchEvent extends Coordinate {
|
478 | pageX: number;
|
479 | pageY: number;
|
480 | isTouch?: boolean;
|
481 | preventDefault?: () => void;
|
482 | }
|
483 |
|
484 |
|
485 |
|
486 |
|
487 |
|
488 |
|
489 |
|
490 |
|
491 |
|
492 |
|
493 |
|
494 |
|
495 |
|
496 | export type DeepPartial<T> = {
|
497 | [P in keyof T]?: T[P] extends Array<infer U> ? Array<DeepPartial<U>> : T[P] extends ReadonlyArray<infer X> ? ReadonlyArray<DeepPartial<X>> : T[P] extends object ? DeepPartial<T[P]> : T[P];
|
498 | };
|
499 |
|
500 |
|
501 |
|
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 |
|
508 |
|
509 |
|
510 |
|
511 |
|
512 | export interface Point {
|
513 | dataIndex: number;
|
514 | timestamp: number;
|
515 | value: number;
|
516 | }
|
517 |
|
518 |
|
519 |
|
520 |
|
521 | export type LoadMoreCallback = (timestamp: Nullable<number>) => void;
|
522 | declare enum LoadDataType {
|
523 | Init = "init",
|
524 | Forward = "forward",
|
525 | Backward = "backward"
|
526 | }
|
527 | export interface LoadDataParams {
|
528 | type: LoadDataType;
|
529 | data: Nullable<KLineData>;
|
530 | callback: (dataList: KLineData[], more?: boolean) => void;
|
531 | }
|
532 | export type LoadDataCallback = (params: LoadDataParams) => void;
|
533 |
|
534 |
|
535 |
|
536 |
|
537 |
|
538 |
|
539 |
|
540 |
|
541 |
|
542 |
|
543 |
|
544 |
|
545 |
|
546 | export interface Precision {
|
547 | price: number;
|
548 | volume: number;
|
549 | }
|
550 |
|
551 |
|
552 |
|
553 |
|
554 |
|
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 |
|
562 |
|
563 | export interface PaneGap {
|
564 | top?: number;
|
565 | bottom?: number;
|
566 | }
|
567 | export interface PaneAxisOptions {
|
568 | name?: string;
|
569 | scrollZoomEnabled?: boolean;
|
570 | }
|
571 | export declare const enum PanePosition {
|
572 | Top = "top",
|
573 | Bottom = "bottom"
|
574 | }
|
575 | export interface PaneOptions {
|
576 | id?: string;
|
577 | height?: number;
|
578 | minHeight?: number;
|
579 | dragEnabled?: boolean;
|
580 | position?: PanePosition;
|
581 | gap?: PaneGap;
|
582 | axisOptions?: PaneAxisOptions;
|
583 | }
|
584 | export declare enum FormatDateType {
|
585 | Tooltip = 0,
|
586 | Crosshair = 1,
|
587 | XAxis = 2
|
588 | }
|
589 | export type FormatDate = (dateTimeFormat: Intl.DateTimeFormat, timestamp: number, format: string, type: FormatDateType) => string;
|
590 | export type FormatBigNumber = (value: string | number) => string;
|
591 | export interface CustomApi {
|
592 | formatDate: FormatDate;
|
593 | formatBigNumber: FormatBigNumber;
|
594 | }
|
595 | export interface Locales {
|
596 | time: string;
|
597 | open: string;
|
598 | high: string;
|
599 | low: string;
|
600 | close: string;
|
601 | volume: string;
|
602 | change: string;
|
603 | turnover: string;
|
604 | [key: string]: string;
|
605 | }
|
606 | export declare const enum LayoutChildType {
|
607 | Candle = "candle",
|
608 | Indicator = "indicator",
|
609 | XAxis = "xAxis"
|
610 | }
|
611 | export interface LayoutChild {
|
612 | type: LayoutChildType;
|
613 | content?: Array<string | IndicatorCreate>;
|
614 | options?: PaneOptions;
|
615 | }
|
616 | export interface Options {
|
617 | layout?: LayoutChild[];
|
618 | locale?: string;
|
619 | timezone?: string;
|
620 | styles?: string | DeepPartial<Styles>;
|
621 | customApi?: Partial<CustomApi>;
|
622 | thousandsSeparator?: string;
|
623 | decimalFoldThreshold?: number;
|
624 | }
|
625 | export interface YAxis extends Axis {
|
626 | isFromZero: () => boolean;
|
627 | isInCandle: () => boolean;
|
628 | }
|
629 | export declare enum OverlayMode {
|
630 | Normal = "normal",
|
631 | WeakMagnet = "weak_magnet",
|
632 | StrongMagnet = "strong_magnet"
|
633 | }
|
634 | export interface OverlayPerformEventParams {
|
635 | currentStep: number;
|
636 | mode: OverlayMode;
|
637 | points: Array<Partial<Point>>;
|
638 | performPointIndex: number;
|
639 | performPoint: Partial<Point>;
|
640 | }
|
641 | export type OverlayFigureIgnoreEventType = "mouseClickEvent" | "mouseRightClickEvent" | "tapEvent" | "doubleTapEvent" | "mouseDownEvent" | "touchStartEvent" | "mouseMoveEvent" | "touchMoveEvent" | "mouseDoubleClickEvent";
|
642 | export interface OverlayFigure {
|
643 | key?: string;
|
644 | type: string;
|
645 | attrs: any;
|
646 | styles?: any;
|
647 | ignoreEvent?: boolean | OverlayFigureIgnoreEventType[];
|
648 | }
|
649 | export interface OverlayPrecision extends Precision {
|
650 | max: number;
|
651 | min: number;
|
652 | excludePriceVolumeMax: number;
|
653 | excludePriceVolumeMin: number;
|
654 | [key: string]: number;
|
655 | }
|
656 | export interface OverlayCreateFiguresCallbackParams {
|
657 | overlay: Overlay;
|
658 | coordinates: Coordinate[];
|
659 | bounding: Bounding;
|
660 | barSpace: BarSpace;
|
661 | precision: OverlayPrecision;
|
662 | thousandsSeparator: string;
|
663 | decimalFoldThreshold: number;
|
664 | dateTimeFormat: Intl.DateTimeFormat;
|
665 | defaultStyles: OverlayStyle;
|
666 | xAxis: Nullable<XAxis>;
|
667 | yAxis: Nullable<YAxis>;
|
668 | }
|
669 | export interface OverlayEvent extends Partial<MouseTouchEvent> {
|
670 | figureKey?: string;
|
671 | figureIndex?: number;
|
672 | overlay: Overlay;
|
673 | }
|
674 | export type OverlayEventCallback = (event: OverlayEvent) => boolean;
|
675 | export type OverlayCreateFiguresCallback = (params: OverlayCreateFiguresCallbackParams) => OverlayFigure | OverlayFigure[];
|
676 | export interface Overlay {
|
677 | |
678 |
|
679 |
|
680 | id: string;
|
681 | |
682 |
|
683 |
|
684 | groupId: string;
|
685 | |
686 |
|
687 |
|
688 | paneId: string;
|
689 | |
690 |
|
691 |
|
692 | name: string;
|
693 | |
694 |
|
695 |
|
696 | totalStep: number;
|
697 | |
698 |
|
699 |
|
700 | currentStep: number;
|
701 | |
702 |
|
703 |
|
704 | lock: boolean;
|
705 | |
706 |
|
707 |
|
708 | visible: boolean;
|
709 | |
710 |
|
711 |
|
712 | zLevel: number;
|
713 | |
714 |
|
715 |
|
716 | needDefaultPointFigure: boolean;
|
717 | |
718 |
|
719 |
|
720 | needDefaultXAxisFigure: boolean;
|
721 | |
722 |
|
723 |
|
724 | needDefaultYAxisFigure: boolean;
|
725 | |
726 |
|
727 |
|
728 | mode: OverlayMode;
|
729 | |
730 |
|
731 |
|
732 | modeSensitivity: number;
|
733 | |
734 |
|
735 |
|
736 | points: Array<Partial<Point>>;
|
737 | |
738 |
|
739 |
|
740 | extendData: any;
|
741 | |
742 |
|
743 |
|
744 | styles: Nullable<DeepPartial<OverlayStyle>>;
|
745 | |
746 |
|
747 |
|
748 | createPointFigures: Nullable<OverlayCreateFiguresCallback>;
|
749 | |
750 |
|
751 |
|
752 | createXAxisFigures: Nullable<OverlayCreateFiguresCallback>;
|
753 | |
754 |
|
755 |
|
756 | createYAxisFigures: Nullable<OverlayCreateFiguresCallback>;
|
757 | |
758 |
|
759 |
|
760 | performEventPressedMove: Nullable<(params: OverlayPerformEventParams) => void>;
|
761 | |
762 |
|
763 |
|
764 | performEventMoveForDrawing: Nullable<(params: OverlayPerformEventParams) => void>;
|
765 | |
766 |
|
767 |
|
768 | onDrawStart: Nullable<OverlayEventCallback>;
|
769 | |
770 |
|
771 |
|
772 | onDrawing: Nullable<OverlayEventCallback>;
|
773 | |
774 |
|
775 |
|
776 | onDrawEnd: Nullable<OverlayEventCallback>;
|
777 | |
778 |
|
779 |
|
780 | onClick: Nullable<OverlayEventCallback>;
|
781 | |
782 |
|
783 |
|
784 | onDoubleClick: Nullable<OverlayEventCallback>;
|
785 | |
786 |
|
787 |
|
788 | onRightClick: Nullable<OverlayEventCallback>;
|
789 | |
790 |
|
791 |
|
792 | onPressedMoveStart: Nullable<OverlayEventCallback>;
|
793 | |
794 |
|
795 |
|
796 | onPressedMoving: Nullable<OverlayEventCallback>;
|
797 | |
798 |
|
799 |
|
800 | onPressedMoveEnd: Nullable<OverlayEventCallback>;
|
801 | |
802 |
|
803 |
|
804 | onMouseEnter: Nullable<OverlayEventCallback>;
|
805 | |
806 |
|
807 |
|
808 | onMouseLeave: Nullable<OverlayEventCallback>;
|
809 | |
810 |
|
811 |
|
812 | onRemoved: Nullable<OverlayEventCallback>;
|
813 | |
814 |
|
815 |
|
816 | onSelected: Nullable<OverlayEventCallback>;
|
817 | |
818 |
|
819 |
|
820 | onDeselected: Nullable<OverlayEventCallback>;
|
821 | }
|
822 | export type OverlayTemplate = ExcludePickPartial<Omit<Overlay, "id" | "groupId" | "paneId" | "points" | "currentStep">, "name">;
|
823 | export type OverlayCreate = ExcludePickPartial<Omit<Overlay, "paneId" | "currentStep" | "totalStep" | "createPointFigures" | "createXAxisFigures" | "createYAxisFigures" | "performEventPressedMove" | "performEventMoveForDrawing">, "name">;
|
824 | export type OverlayRemove = Partial<Pick<Overlay, "id" | "groupId" | "name">>;
|
825 | export type OverlayConstructor = new () => Overlay;
|
826 | export declare enum DomPosition {
|
827 | Root = "root",
|
828 | Main = "main",
|
829 | YAxis = "yAxis"
|
830 | }
|
831 | export interface ConvertFinder {
|
832 | paneId?: string;
|
833 | absolute?: boolean;
|
834 | }
|
835 | export interface Chart {
|
836 | id: string;
|
837 | getDom: (paneId?: string, position?: DomPosition) => Nullable<HTMLElement>;
|
838 | getSize: (paneId?: string, position?: DomPosition) => Nullable<Bounding>;
|
839 | setLocale: (locale: string) => void;
|
840 | getLocale: () => string;
|
841 | setStyles: (styles: string | DeepPartial<Styles>) => void;
|
842 | getStyles: () => Styles;
|
843 | setCustomApi: (customApi: Partial<CustomApi>) => void;
|
844 | setPriceVolumePrecision: (pricePrecision: number, volumePrecision: number) => void;
|
845 | getPriceVolumePrecision: () => Precision;
|
846 | setTimezone: (timezone: string) => void;
|
847 | getTimezone: () => string;
|
848 | setOffsetRightDistance: (distance: number) => void;
|
849 | getOffsetRightDistance: () => number;
|
850 | setMaxOffsetLeftDistance: (distance: number) => void;
|
851 | setMaxOffsetRightDistance: (distance: number) => void;
|
852 | setLeftMinVisibleBarCount: (barCount: number) => void;
|
853 | setRightMinVisibleBarCount: (barCount: number) => void;
|
854 | setBarSpace: (space: number) => void;
|
855 | getBarSpace: () => number;
|
856 | getVisibleRange: () => VisibleRange;
|
857 | clearData: () => void;
|
858 | getDataList: () => KLineData[];
|
859 | applyNewData: (dataList: KLineData[], more?: boolean, callback?: () => void) => void;
|
860 | |
861 |
|
862 |
|
863 |
|
864 | applyMoreData: (dataList: KLineData[], more?: boolean, callback?: () => void) => void;
|
865 | updateData: (data: KLineData, callback?: () => void) => void;
|
866 | |
867 |
|
868 |
|
869 |
|
870 | loadMore: (cb: LoadMoreCallback) => void;
|
871 | setLoadDataCallback: (cb: LoadDataCallback) => void;
|
872 | createIndicator: (value: string | IndicatorCreate, isStack?: boolean, paneOptions?: PaneOptions, callback?: () => void) => Nullable<string>;
|
873 | overrideIndicator: (override: IndicatorCreate, paneId?: string, callback?: () => void) => void;
|
874 | getIndicatorByPaneId: (paneId?: string, name?: string) => Nullable<Indicator> | Nullable<Map<string, Indicator>> | Map<string, Map<string, Indicator>>;
|
875 | removeIndicator: (paneId: string, name?: string) => void;
|
876 | createOverlay: (value: string | OverlayCreate | Array<string | OverlayCreate>, paneId?: string) => Nullable<string> | Array<Nullable<string>>;
|
877 | getOverlayById: (id: string) => Nullable<Overlay>;
|
878 | overrideOverlay: (override: Partial<OverlayCreate>) => void;
|
879 | removeOverlay: (remove?: string | OverlayRemove) => void;
|
880 | setPaneOptions: (options: PaneOptions) => void;
|
881 | setZoomEnabled: (enabled: boolean) => void;
|
882 | isZoomEnabled: () => boolean;
|
883 | setScrollEnabled: (enabled: boolean) => void;
|
884 | isScrollEnabled: () => boolean;
|
885 | scrollByDistance: (distance: number, animationDuration?: number) => void;
|
886 | scrollToRealTime: (animationDuration?: number) => void;
|
887 | scrollToDataIndex: (dataIndex: number, animationDuration?: number) => void;
|
888 | scrollToTimestamp: (timestamp: number, animationDuration?: number) => void;
|
889 | zoomAtCoordinate: (scale: number, coordinate?: Coordinate, animationDuration?: number) => void;
|
890 | zoomAtDataIndex: (scale: number, dataIndex: number, animationDuration?: number) => void;
|
891 | zoomAtTimestamp: (scale: number, timestamp: number, animationDuration?: number) => void;
|
892 | convertToPixel: (points: Partial<Point> | Array<Partial<Point>>, finder: ConvertFinder) => Partial<Coordinate> | Array<Partial<Coordinate>>;
|
893 | convertFromPixel: (coordinates: Array<Partial<Coordinate>>, finder: ConvertFinder) => Partial<Point> | Array<Partial<Point>>;
|
894 | executeAction: (type: ActionType, data: any) => void;
|
895 | subscribeAction: (type: ActionType, callback: ActionCallback) => void;
|
896 | unsubscribeAction: (type: ActionType, callback?: ActionCallback) => void;
|
897 | getConvertPictureUrl: (includeOverlay?: boolean, type?: string, backgroundColor?: string) => string;
|
898 | resize: () => void;
|
899 | }
|
900 | export interface AxisTick {
|
901 | coord: number;
|
902 | value: number | string;
|
903 | text: string;
|
904 | }
|
905 | export interface AxisRange extends VisibleRange {
|
906 | readonly range: number;
|
907 | readonly realRange: number;
|
908 | }
|
909 | export interface Axis {
|
910 | convertToPixel: (value: number) => number;
|
911 | convertFromPixel: (px: number) => number;
|
912 | }
|
913 | export interface AxisCreateTicksParams {
|
914 | range: AxisRange;
|
915 | bounding: Bounding;
|
916 | defaultTicks: AxisTick[];
|
917 | }
|
918 | export type AxisCreateTicksCallback = (params: AxisCreateTicksParams) => AxisTick[];
|
919 | export interface AxisTemplate {
|
920 | name: string;
|
921 | createTicks: AxisCreateTicksCallback;
|
922 | }
|
923 | export type XAxis = Axis;
|
924 | export interface Figure<A = any, S = any> {
|
925 | name: string;
|
926 | attrs: A;
|
927 | styles: S;
|
928 | draw: (ctx: CanvasRenderingContext2D, attrs: A, styles: S) => void;
|
929 | checkEventOn: (coordinate: Coordinate, attrs: A, styles: S) => boolean;
|
930 | }
|
931 | export type FigureTemplate<A = any, S = any> = Pick<Figure<A, S>, "name" | "draw" | "checkEventOn">;
|
932 | export type FigureCreate<A = any, S = any> = Pick<Figure<A, S>, "name" | "attrs" | "styles">;
|
933 | export type FigureConstructor<A = any, S = any> = new (figure: FigureCreate<A, S>) => ({
|
934 | draw: (ctx: CanvasRenderingContext2D) => void;
|
935 | });
|
936 | declare function checkCoordinateOnCircle(coordinate: Coordinate, attrs: CircleAttrs | CircleAttrs[]): boolean;
|
937 | declare function drawCircle(ctx: CanvasRenderingContext2D, attrs: CircleAttrs | CircleAttrs[], styles: Partial<PolygonStyle>): void;
|
938 | export interface CircleAttrs {
|
939 | x: number;
|
940 | y: number;
|
941 | r: number;
|
942 | }
|
943 | declare function checkCoordinateOnArc(coordinate: Coordinate, attrs: ArcAttrs | ArcAttrs[]): boolean;
|
944 | declare function drawArc(ctx: CanvasRenderingContext2D, attrs: ArcAttrs | ArcAttrs[], styles: Partial<LineStyle>): void;
|
945 | export interface ArcAttrs extends CircleAttrs {
|
946 | startAngle: number;
|
947 | endAngle: number;
|
948 | }
|
949 | declare function checkCoordinateOnRect(coordinate: Coordinate, attrs: RectAttrs | RectAttrs[]): boolean;
|
950 | declare function drawRect(ctx: CanvasRenderingContext2D, attrs: RectAttrs | RectAttrs[], styles: Partial<RectStyle>): void;
|
951 | export interface RectAttrs {
|
952 | x: number;
|
953 | y: number;
|
954 | width: number;
|
955 | height: number;
|
956 | }
|
957 | declare function checkCoordinateOnText(coordinate: Coordinate, attrs: TextAttrs | TextAttrs[], styles: Partial<TextStyle>): boolean;
|
958 | declare function drawText(ctx: CanvasRenderingContext2D, attrs: TextAttrs | TextAttrs[], styles: Partial<TextStyle>): void;
|
959 | export interface TextAttrs {
|
960 | x: number;
|
961 | y: number;
|
962 | text: string;
|
963 | width?: number;
|
964 | height?: number;
|
965 | align?: CanvasTextAlign;
|
966 | baseline?: CanvasTextBaseline;
|
967 | }
|
968 | export declare enum IndicatorSeries {
|
969 | Normal = "normal",
|
970 | Price = "price",
|
971 | Volume = "volume"
|
972 | }
|
973 | export type IndicatorFigureStyle = Partial<Omit<SmoothLineStyle, "style">> & Partial<Omit<RectStyle, "style">> & Partial<TextStyle> & Partial<{
|
974 | style: LineType[keyof LineType] | PolygonType[keyof PolygonType];
|
975 | }> & Record<string, any>;
|
976 | export type IndicatorFigureAttrs = Partial<ArcAttrs> & Partial<LineStyle> & Partial<RectAttrs> & Partial<TextAttrs> & Record<string, any>;
|
977 | export interface IndicatorFigureCallbackBrother<PCN> {
|
978 | prev: PCN;
|
979 | current: PCN;
|
980 | next: PCN;
|
981 | }
|
982 | export type IndicatorFigureAttrsCallbackCoordinate<D> = IndicatorFigureCallbackBrother<Record<keyof D, number> & {
|
983 | x: number;
|
984 | }>;
|
985 | export interface IndicatorFigureAttrsCallbackParams<D> {
|
986 | coordinate: IndicatorFigureAttrsCallbackCoordinate<D>;
|
987 | bounding: Bounding;
|
988 | barSpace: BarSpace;
|
989 | xAxis: XAxis;
|
990 | yAxis: YAxis;
|
991 | }
|
992 | export interface IndicatorFigureStylesCallbackDataChild<D> {
|
993 | kLineData?: KLineData;
|
994 | indicatorData?: D;
|
995 | }
|
996 | export type IndicatorFigureStylesCallbackData<D> = IndicatorFigureCallbackBrother<IndicatorFigureStylesCallbackDataChild<D>>;
|
997 | export type IndicatorFigureAttrsCallback<D> = (params: IndicatorFigureAttrsCallbackParams<D>) => IndicatorFigureAttrs;
|
998 | export type IndicatorFigureStylesCallback<D> = (data: IndicatorFigureStylesCallbackData<D>, indicator: Indicator<D>, defaultStyles: IndicatorStyle) => IndicatorFigureStyle;
|
999 | export interface IndicatorFigure<D = any> {
|
1000 | key: string;
|
1001 | title?: string;
|
1002 | type?: string;
|
1003 | baseValue?: number;
|
1004 | attrs?: IndicatorFigureAttrsCallback<D>;
|
1005 | styles?: IndicatorFigureStylesCallback<D>;
|
1006 | }
|
1007 | export type IndicatorRegenerateFiguresCallback<D = any> = (calcParams: any[]) => Array<IndicatorFigure<D>>;
|
1008 | export interface IndicatorTooltipData {
|
1009 | name: string;
|
1010 | calcParamsText: string;
|
1011 | icons: TooltipIconStyle[];
|
1012 | values: TooltipLegend[];
|
1013 | }
|
1014 | export interface IndicatorCreateTooltipDataSourceParams<D = any> {
|
1015 | kLineDataList: KLineData[];
|
1016 | indicator: Indicator<D>;
|
1017 | visibleRange: VisibleRange;
|
1018 | bounding: Bounding;
|
1019 | crosshair: Crosshair;
|
1020 | defaultStyles: IndicatorStyle;
|
1021 | xAxis: XAxis;
|
1022 | yAxis: YAxis;
|
1023 | }
|
1024 | export type IndicatorCreateTooltipDataSourceCallback<D = any> = (params: IndicatorCreateTooltipDataSourceParams<D>) => IndicatorTooltipData;
|
1025 | export interface IndicatorDrawParams<D = any> {
|
1026 | ctx: CanvasRenderingContext2D;
|
1027 | kLineDataList: KLineData[];
|
1028 | indicator: Indicator<D>;
|
1029 | visibleRange: VisibleRange;
|
1030 | bounding: Bounding;
|
1031 | barSpace: BarSpace;
|
1032 | defaultStyles: IndicatorStyle;
|
1033 | xAxis: XAxis;
|
1034 | yAxis: YAxis;
|
1035 | }
|
1036 | export type IndicatorDrawCallback<D = any> = (params: IndicatorDrawParams<D>) => boolean;
|
1037 | export type IndicatorCalcCallback<D> = (dataList: KLineData[], indicator: Indicator<D>) => Promise<D[]> | D[];
|
1038 | export interface Indicator<D = any> {
|
1039 | |
1040 |
|
1041 |
|
1042 | name: string;
|
1043 | |
1044 |
|
1045 |
|
1046 | shortName: string;
|
1047 | |
1048 |
|
1049 |
|
1050 | precision: number;
|
1051 | |
1052 |
|
1053 |
|
1054 | calcParams: any[];
|
1055 | |
1056 |
|
1057 |
|
1058 | shouldOhlc: boolean;
|
1059 | |
1060 |
|
1061 |
|
1062 | shouldFormatBigNumber: boolean;
|
1063 | |
1064 |
|
1065 |
|
1066 | visible: boolean;
|
1067 | |
1068 |
|
1069 |
|
1070 | zLevel: number;
|
1071 | |
1072 |
|
1073 |
|
1074 | extendData: any;
|
1075 | |
1076 |
|
1077 |
|
1078 | series: IndicatorSeries;
|
1079 | |
1080 |
|
1081 |
|
1082 | figures: Array<IndicatorFigure<D>>;
|
1083 | |
1084 |
|
1085 |
|
1086 | minValue: Nullable<number>;
|
1087 | |
1088 |
|
1089 |
|
1090 | maxValue: Nullable<number>;
|
1091 | |
1092 |
|
1093 |
|
1094 | styles: Nullable<Partial<IndicatorStyle>>;
|
1095 | |
1096 |
|
1097 |
|
1098 | calc: IndicatorCalcCallback<D>;
|
1099 | |
1100 |
|
1101 |
|
1102 | regenerateFigures: Nullable<IndicatorRegenerateFiguresCallback<D>>;
|
1103 | |
1104 |
|
1105 |
|
1106 | createTooltipDataSource: Nullable<IndicatorCreateTooltipDataSourceCallback>;
|
1107 | |
1108 |
|
1109 |
|
1110 | draw: Nullable<IndicatorDrawCallback<D>>;
|
1111 | |
1112 |
|
1113 |
|
1114 | result: D[];
|
1115 | }
|
1116 | export type IndicatorTemplate<D = any> = ExcludePickPartial<Omit<Indicator<D>, "result">, "name" | "calc">;
|
1117 | export type IndicatorCreate<D = any> = ExcludePickPartial<Omit<Indicator<D>, "result">, "name">;
|
1118 | declare function checkCoordinateOnLine(coordinate: Coordinate, attrs: LineAttrs | LineAttrs[]): boolean;
|
1119 | declare function getLinearYFromSlopeIntercept(kb: Nullable<number[]>, coordinate: Coordinate): number;
|
1120 | declare function getLinearYFromCoordinates(coordinate1: Coordinate, coordinate2: Coordinate, targetCoordinate: Coordinate): number;
|
1121 | declare function getLinearSlopeIntercept(coordinate1: Coordinate, coordinate2: Coordinate): Nullable<number[]>;
|
1122 | declare function drawLine(ctx: CanvasRenderingContext2D, attrs: LineAttrs | LineAttrs[], styles: Partial<SmoothLineStyle>): void;
|
1123 | export interface LineAttrs {
|
1124 | coordinates: Coordinate[];
|
1125 | }
|
1126 | declare function checkCoordinateOnPolygon(coordinate: Coordinate, attrs: PolygonAttrs | PolygonAttrs[]): boolean;
|
1127 | declare function drawPolygon(ctx: CanvasRenderingContext2D, attrs: PolygonAttrs | PolygonAttrs[], styles: Partial<PolygonStyle>): void;
|
1128 | export interface PolygonAttrs {
|
1129 | coordinates: Coordinate[];
|
1130 | }
|
1131 | export declare function getSupportedFigures(): string[];
|
1132 | export declare function registerFigure<A = any, S = any>(figure: FigureTemplate<A, S>): void;
|
1133 | export declare function getFigureClass<A = any, S = any>(name: string): Nullable<FigureConstructor<A, S>>;
|
1134 | export declare function registerIndicator<D>(indicator: IndicatorTemplate<D>): void;
|
1135 | export declare function getSupportedIndicators(): string[];
|
1136 | export declare function registerLocale(locale: string, ls: Locales): void;
|
1137 | export declare function getSupportedLocales(): string[];
|
1138 | export declare function registerOverlay(template: OverlayTemplate): void;
|
1139 | export declare function getOverlayClass(name: string): Nullable<OverlayConstructor>;
|
1140 | export declare function getSupportedOverlays(): string[];
|
1141 | export declare function registerStyles(name: string, ss: DeepPartial<Styles>): void;
|
1142 | export declare function registerXAxis(axis: AxisTemplate): void;
|
1143 | export declare function registerYAxis(axis: AxisTemplate): void;
|
1144 |
|
1145 |
|
1146 |
|
1147 |
|
1148 | export declare function version(): string;
|
1149 |
|
1150 |
|
1151 |
|
1152 |
|
1153 |
|
1154 |
|
1155 | export declare function init(ds: HTMLElement | string, options?: Options): Nullable<Chart>;
|
1156 |
|
1157 |
|
1158 |
|
1159 |
|
1160 | export declare function dispose(dcs: HTMLElement | Chart | string): void;
|
1161 | export declare const utils: {
|
1162 | clone: typeof clone;
|
1163 | merge: typeof merge;
|
1164 | isString: typeof isString;
|
1165 | isNumber: typeof isNumber;
|
1166 | isValid: typeof isValid;
|
1167 | isObject: typeof isObject;
|
1168 | isArray: typeof isArray;
|
1169 | isFunction: typeof isFunction;
|
1170 | isBoolean: typeof isBoolean;
|
1171 | formatValue: typeof formatValue;
|
1172 | formatPrecision: typeof formatPrecision;
|
1173 | formatBigNumber: typeof formatBigNumber;
|
1174 | formatDate: typeof formatDate;
|
1175 | formatThousands: typeof formatThousands;
|
1176 | formatFoldDecimal: typeof formatFoldDecimal;
|
1177 | calcTextWidth: typeof calcTextWidth;
|
1178 | getLinearSlopeIntercept: typeof getLinearSlopeIntercept;
|
1179 | getLinearYFromSlopeIntercept: typeof getLinearYFromSlopeIntercept;
|
1180 | getLinearYFromCoordinates: typeof getLinearYFromCoordinates;
|
1181 | checkCoordinateOnArc: typeof checkCoordinateOnArc;
|
1182 | checkCoordinateOnCircle: typeof checkCoordinateOnCircle;
|
1183 | checkCoordinateOnLine: typeof checkCoordinateOnLine;
|
1184 | checkCoordinateOnPolygon: typeof checkCoordinateOnPolygon;
|
1185 | checkCoordinateOnRect: typeof checkCoordinateOnRect;
|
1186 | checkCoordinateOnText: typeof checkCoordinateOnText;
|
1187 | drawArc: typeof drawArc;
|
1188 | drawCircle: typeof drawCircle;
|
1189 | drawLine: typeof drawLine;
|
1190 | drawPolygon: typeof drawPolygon;
|
1191 | drawRect: typeof drawRect;
|
1192 | drawText: typeof drawText;
|
1193 | drawRectText: typeof drawText;
|
1194 | };
|
1195 |
|
1196 | export as namespace klinecharts;
|
1197 |
|
1198 | export {};
|