UNPKG

38.2 kBTypeScriptView Raw
1/**
2 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at
5
6 * http://www.apache.org/licenses/LICENSE-2.0
7
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */
14export type Nullable<T> = T | null;
15/**
16 * Licensed under the Apache License, Version 2.0 (the "License");
17 * you may not use this file except in compliance with the License.
18 * You may obtain a copy of the License at
19
20 * http://www.apache.org/licenses/LICENSE-2.0
21
22 * Unless required by applicable law or agreed to in writing, software
23 * distributed under the License is distributed on an "AS IS" BASIS,
24 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 * See the License for the specific language governing permissions and
26 * limitations under the License.
27 */
28export 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}
38export interface Margin {
39 marginLeft: number;
40 marginTop: number;
41 marginRight: number;
42 marginBottom: number;
43}
44export interface Padding {
45 paddingLeft: number;
46 paddingTop: number;
47 paddingRight: number;
48 paddingBottom: number;
49}
50export interface Offset {
51 offsetLeft: number;
52 offsetTop: number;
53 offsetRight: number;
54 offsetBottom: number;
55}
56/**
57 * line type
58 */
59export declare enum LineType {
60 Dashed = "dashed",
61 Solid = "solid"
62}
63export interface LineStyle {
64 style: LineType;
65 size: number;
66 color: string;
67 dashedValue: number[];
68}
69export interface SmoothLineStyle extends LineStyle {
70 smooth: boolean | number;
71}
72export interface StateLineStyle extends LineStyle {
73 show: boolean;
74}
75export declare enum PolygonType {
76 Stroke = "stroke",
77 Fill = "fill",
78 StrokeFill = "stroke_fill"
79}
80export interface PolygonStyle {
81 style: PolygonType;
82 color: string | CanvasGradient;
83 borderColor: string;
84 borderSize: number;
85 borderStyle: LineType;
86 borderDashedValue: number[];
87}
88export interface RectStyle extends PolygonStyle {
89 borderRadius: number;
90}
91export 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}
104export interface StateTextStyle extends TextStyle {
105 show: boolean;
106}
107export type LastValueMarkTextStyle = Omit<StateTextStyle, "backgroundColor">;
108export declare enum TooltipShowRule {
109 Always = "always",
110 FollowCross = "follow_cross",
111 None = "none"
112}
113export declare enum TooltipShowType {
114 Standard = "standard",
115 Rect = "rect"
116}
117export interface ChangeColor {
118 upColor: string;
119 downColor: string;
120 noChangeColor: string;
121}
122export interface GradientColor {
123 offset: number;
124 color: string;
125}
126export interface GridStyle {
127 show: boolean;
128 horizontal: StateLineStyle;
129 vertical: StateLineStyle;
130}
131export type TooltipTextStyle = Pick<TextStyle, "color" | "size" | "family" | "weight"> & Margin;
132export interface TooltipLegendChild {
133 text: string;
134 color: string;
135}
136export interface TooltipLegend {
137 title: string | TooltipLegendChild;
138 value: string | TooltipLegendChild;
139}
140export declare enum TooltipIconPosition {
141 Left = "left",
142 Middle = "middle",
143 Right = "right"
144}
145export 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}
156export interface TooltipStyle {
157 showRule: TooltipShowRule;
158 showType: TooltipShowType;
159 defaultValue: string;
160 text: TooltipTextStyle;
161 icons: TooltipIconStyle[];
162}
163export interface CandleAreaPointStyle {
164 show: boolean;
165 color: string;
166 radius: number;
167 rippleColor: string;
168 rippleRadius: number;
169 animation: boolean;
170 animationDuration: number;
171}
172export interface CandleAreaStyle {
173 lineSize: number;
174 lineColor: string;
175 value: string;
176 smooth: boolean;
177 backgroundColor: string | GradientColor[];
178 point: CandleAreaPointStyle;
179}
180export interface CandleHighLowPriceMarkStyle {
181 show: boolean;
182 color: string;
183 textOffset: number;
184 textSize: number;
185 textFamily: string;
186 textWeight: string;
187}
188export type CandleLastPriceMarkLineStyle = Omit<StateLineStyle, "color">;
189export interface CandleLastPriceMarkStyle extends ChangeColor {
190 show: boolean;
191 line: CandleLastPriceMarkLineStyle;
192 text: LastValueMarkTextStyle;
193}
194export interface CandlePriceMarkStyle {
195 show: boolean;
196 high: CandleHighLowPriceMarkStyle;
197 low: CandleHighLowPriceMarkStyle;
198 last: CandleLastPriceMarkStyle;
199}
200declare enum CandleTooltipRectPosition {
201 Fixed = "fixed",
202 Pointer = "pointer"
203}
204export interface CandleTooltipRectStyle extends Omit<RectStyle, "style" | "borderDashedValue" | "borderStyle">, Padding, Offset {
205 position: CandleTooltipRectPosition;
206}
207export interface CandleTooltipCustomCallbackData {
208 prev: Nullable<KLineData>;
209 current: KLineData;
210 next: Nullable<KLineData>;
211}
212export type CandleTooltipCustomCallback = (data: CandleTooltipCustomCallbackData, styles: CandleStyle) => TooltipLegend[];
213export interface CandleTooltipStyle extends TooltipStyle, Offset {
214 custom: CandleTooltipCustomCallback | TooltipLegend[];
215 rect: CandleTooltipRectStyle;
216}
217export 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}
225export interface CandleBarColor extends ChangeColor {
226 upBorderColor: string;
227 downBorderColor: string;
228 noChangeBorderColor: string;
229 upWickColor: string;
230 downWickColor: string;
231 noChangeWickColor: string;
232}
233export interface CandleStyle {
234 type: CandleType;
235 bar: CandleBarColor;
236 area: CandleAreaStyle;
237 priceMark: CandlePriceMarkStyle;
238 tooltip: CandleTooltipStyle;
239}
240export type IndicatorPolygonStyle = Omit<PolygonStyle, "color" | "borderColor"> & ChangeColor;
241export interface IndicatorLastValueMarkStyle {
242 show: boolean;
243 text: LastValueMarkTextStyle;
244}
245export interface IndicatorTooltipStyle extends TooltipStyle, Offset {
246 showName: boolean;
247 showParams: boolean;
248}
249export 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}
258export type AxisLineStyle = Omit<StateLineStyle, "style" | "dashedValue">;
259export interface AxisTickLineStyle extends AxisLineStyle {
260 length: number;
261}
262export interface AxisTickTextStyle extends Pick<StateTextStyle, "show" | "color" | "weight" | "family" | "size"> {
263 marginStart: number;
264 marginEnd: number;
265}
266export interface AxisStyle {
267 show: boolean;
268 size: number | "auto";
269 axisLine: AxisLineStyle;
270 tickLine: AxisTickLineStyle;
271 tickText: AxisTickTextStyle;
272}
273export type XAxisStyle = AxisStyle;
274export declare enum YAxisPosition {
275 Left = "left",
276 Right = "right"
277}
278export declare enum YAxisType {
279 Normal = "normal",
280 Percentage = "percentage",
281 Log = "log"
282}
283export interface YAxisStyle extends AxisStyle {
284 type: YAxisType;
285 position: YAxisPosition;
286 inside: boolean;
287 reverse: boolean;
288}
289export interface CrosshairDirectionStyle {
290 show: boolean;
291 line: StateLineStyle;
292 text: StateTextStyle;
293}
294export interface CrosshairStyle {
295 show: boolean;
296 horizontal: CrosshairDirectionStyle;
297 vertical: CrosshairDirectionStyle;
298}
299export 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}
309export 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 * @deprecated
319 * Starting from v10, it will be deleted
320 */
321 rectText: TextStyle;
322 [key: string]: any;
323}
324export interface SeparatorStyle {
325 size: number;
326 color: string;
327 fill: boolean;
328 activeBackgroundColor: string;
329}
330export 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}
340declare function merge(target: any, source: any): void;
341declare function clone<T>(target: T): T;
342declare function isArray<T = any>(value: any): value is T[];
343declare function isFunction<T = (...args: any) => any>(value: any): value is T;
344declare function isObject(value: any): value is object;
345declare function isNumber(value: any): value is number;
346declare function isValid<T>(value: T | null | undefined): value is T;
347declare function isBoolean(value: any): value is boolean;
348declare function isString(value: any): value is string;
349declare function formatValue(data: unknown, key: string, defaultValue?: unknown): unknown;
350declare function formatDate(dateTimeFormat: Intl.DateTimeFormat, timestamp: number, format: string): string;
351declare function formatPrecision(value: string | number, precision?: number): string;
352declare function formatBigNumber(value: string | number): string;
353declare function formatThousands(value: string | number, sign: string): string;
354declare function formatFoldDecimal(value: string | number, threshold: number): string;
355declare function calcTextWidth(text: string, size?: number, weight?: string | number, family?: string): number;
356/**
357 * Licensed under the Apache License, Version 2.0 (the "License");
358 * you may not use this file except in compliance with the License.
359 * You may obtain a copy of the License at
360
361 * http://www.apache.org/licenses/LICENSE-2.0
362
363 * Unless required by applicable law or agreed to in writing, software
364 * distributed under the License is distributed on an "AS IS" BASIS,
365 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
366 * See the License for the specific language governing permissions and
367 * limitations under the License.
368 */
369export type ActionCallback = (data?: any) => void;
370export 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 * Licensed under the Apache License, Version 2.0 (the "License");
382 * you may not use this file except in compliance with the License.
383 * You may obtain a copy of the License at
384
385 * http://www.apache.org/licenses/LICENSE-2.0
386
387 * Unless required by applicable law or agreed to in writing, software
388 * distributed under the License is distributed on an "AS IS" BASIS,
389 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
390 * See the License for the specific language governing permissions and
391 * limitations under the License.
392 */
393export type ExcludePickPartial<T, K extends keyof T> = Partial<Omit<T, K>> & Pick<T, K>;
394/**
395 * Licensed under the Apache License, Version 2.0 (the "License");
396 * you may not use this file except in compliance with the License.
397 * You may obtain a copy of the License at
398
399 * http://www.apache.org/licenses/LICENSE-2.0
400
401 * Unless required by applicable law or agreed to in writing, software
402 * distributed under the License is distributed on an "AS IS" BASIS,
403 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
404 * See the License for the specific language governing permissions and
405 * limitations under the License.
406 */
407export interface Bounding {
408 width: number;
409 height: number;
410 left: number;
411 right: number;
412 top: number;
413 bottom: number;
414}
415/**
416 * Licensed under the Apache License, Version 2.0 (the "License");
417 * you may not use this file except in compliance with the License.
418 * You may obtain a copy of the License at
419
420 * http://www.apache.org/licenses/LICENSE-2.0
421
422 * Unless required by applicable law or agreed to in writing, software
423 * distributed under the License is distributed on an "AS IS" BASIS,
424 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
425 * See the License for the specific language governing permissions and
426 * limitations under the License.
427 */
428export interface VisibleRange {
429 readonly from: number;
430 readonly to: number;
431 readonly realFrom: number;
432 readonly realTo: number;
433}
434/**
435 * Licensed under the Apache License, Version 2.0 (the "License");
436 * you may not use this file except in compliance with the License.
437 * You may obtain a copy of the License at
438
439 * http://www.apache.org/licenses/LICENSE-2.0
440
441 * Unless required by applicable law or agreed to in writing, software
442 * distributed under the License is distributed on an "AS IS" BASIS,
443 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
444 * See the License for the specific language governing permissions and
445 * limitations under the License.
446 */
447export interface BarSpace {
448 bar: number;
449 halfBar: number;
450 gapBar: number;
451 halfGapBar: number;
452}
453/**
454 * Licensed under the Apache License, Version 2.0 (the "License");
455 * you may not use this file except in compliance with the License.
456 * You may obtain a copy of the License at
457
458 * http://www.apache.org/licenses/LICENSE-2.0
459
460 * Unless required by applicable law or agreed to in writing, software
461 * distributed under the License is distributed on an "AS IS" BASIS,
462 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
463 * See the License for the specific language governing permissions and
464 * limitations under the License.
465 */
466export interface Coordinate {
467 x: number;
468 y: number;
469}
470export interface Crosshair extends Partial<Coordinate> {
471 paneId?: string;
472 realX?: number;
473 kLineData?: KLineData;
474 dataIndex?: number;
475 realDataIndex?: number;
476}
477export interface MouseTouchEvent extends Coordinate {
478 pageX: number;
479 pageY: number;
480 isTouch?: boolean;
481 preventDefault?: () => void;
482}
483/**
484 * Licensed under the Apache License, Version 2.0 (the "License");
485 * you may not use this file except in compliance with the License.
486 * You may obtain a copy of the License at
487
488 * http://www.apache.org/licenses/LICENSE-2.0
489
490 * Unless required by applicable law or agreed to in writing, software
491 * distributed under the License is distributed on an "AS IS" BASIS,
492 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
493 * See the License for the specific language governing permissions and
494 * limitations under the License.
495 */
496export 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 * Licensed under the Apache License, Version 2.0 (the "License");
501 * you may not use this file except in compliance with the License.
502 * You may obtain a copy of the License at
503
504 * http://www.apache.org/licenses/LICENSE-2.0
505
506 * Unless required by applicable law or agreed to in writing, software
507 * distributed under the License is distributed on an "AS IS" BASIS,
508 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
509 * See the License for the specific language governing permissions and
510 * limitations under the License.
511 */
512export interface Point {
513 dataIndex: number;
514 timestamp: number;
515 value: number;
516}
517/**
518 * Since v9.8.0 deprecated, since v10 removed
519 * @deprecated
520 */
521export type LoadMoreCallback = (timestamp: Nullable<number>) => void;
522declare enum LoadDataType {
523 Init = "init",
524 Forward = "forward",
525 Backward = "backward"
526}
527export interface LoadDataParams {
528 type: LoadDataType;
529 data: Nullable<KLineData>;
530 callback: (dataList: KLineData[], more?: boolean) => void;
531}
532export type LoadDataCallback = (params: LoadDataParams) => void;
533/**
534 * Licensed under the Apache License, Version 2.0 (the "License");
535 * you may not use this file except in compliance with the License.
536 * You may obtain a copy of the License at
537
538 * http://www.apache.org/licenses/LICENSE-2.0
539
540 * Unless required by applicable law or agreed to in writing, software
541 * distributed under the License is distributed on an "AS IS" BASIS,
542 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
543 * See the License for the specific language governing permissions and
544 * limitations under the License.
545 */
546export interface Precision {
547 price: number;
548 volume: number;
549}
550/**
551 * Licensed under the Apache License, Version 2.0 (the "License");
552 * you may not use this file except in compliance with the License.
553 * You may obtain a copy of the License at
554
555 * http://www.apache.org/licenses/LICENSE-2.0
556
557 * Unless required by applicable law or agreed to in writing, software
558 * distributed under the License is distributed on an "AS IS" BASIS,
559 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
560 * See the License for the specific language governing permissions and
561 * limitations under the License.
562 */
563export interface PaneGap {
564 top?: number;
565 bottom?: number;
566}
567export interface PaneAxisOptions {
568 name?: string;
569 scrollZoomEnabled?: boolean;
570}
571export declare const enum PanePosition {
572 Top = "top",
573 Bottom = "bottom"
574}
575export interface PaneOptions {
576 id?: string;
577 height?: number;
578 minHeight?: number;
579 dragEnabled?: boolean;
580 position?: PanePosition;
581 gap?: PaneGap;
582 axisOptions?: PaneAxisOptions;
583}
584export declare enum FormatDateType {
585 Tooltip = 0,
586 Crosshair = 1,
587 XAxis = 2
588}
589export type FormatDate = (dateTimeFormat: Intl.DateTimeFormat, timestamp: number, format: string, type: FormatDateType) => string;
590export type FormatBigNumber = (value: string | number) => string;
591export interface CustomApi {
592 formatDate: FormatDate;
593 formatBigNumber: FormatBigNumber;
594}
595export 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}
606export declare const enum LayoutChildType {
607 Candle = "candle",
608 Indicator = "indicator",
609 XAxis = "xAxis"
610}
611export interface LayoutChild {
612 type: LayoutChildType;
613 content?: Array<string | IndicatorCreate>;
614 options?: PaneOptions;
615}
616export 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}
625export interface YAxis extends Axis {
626 isFromZero: () => boolean;
627 isInCandle: () => boolean;
628}
629export declare enum OverlayMode {
630 Normal = "normal",
631 WeakMagnet = "weak_magnet",
632 StrongMagnet = "strong_magnet"
633}
634export interface OverlayPerformEventParams {
635 currentStep: number;
636 mode: OverlayMode;
637 points: Array<Partial<Point>>;
638 performPointIndex: number;
639 performPoint: Partial<Point>;
640}
641export type OverlayFigureIgnoreEventType = "mouseClickEvent" | "mouseRightClickEvent" | "tapEvent" | "doubleTapEvent" | "mouseDownEvent" | "touchStartEvent" | "mouseMoveEvent" | "touchMoveEvent" | "mouseDoubleClickEvent";
642export interface OverlayFigure {
643 key?: string;
644 type: string;
645 attrs: any;
646 styles?: any;
647 ignoreEvent?: boolean | OverlayFigureIgnoreEventType[];
648}
649export interface OverlayPrecision extends Precision {
650 max: number;
651 min: number;
652 excludePriceVolumeMax: number;
653 excludePriceVolumeMin: number;
654 [key: string]: number;
655}
656export 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}
669export interface OverlayEvent extends Partial<MouseTouchEvent> {
670 figureKey?: string;
671 figureIndex?: number;
672 overlay: Overlay;
673}
674export type OverlayEventCallback = (event: OverlayEvent) => boolean;
675export type OverlayCreateFiguresCallback = (params: OverlayCreateFiguresCallbackParams) => OverlayFigure | OverlayFigure[];
676export interface Overlay {
677 /**
678 * Unique identification
679 */
680 id: string;
681 /**
682 * Group id
683 */
684 groupId: string;
685 /**
686 * Pane id
687 */
688 paneId: string;
689 /**
690 * Name
691 */
692 name: string;
693 /**
694 * Total number of steps required to complete mouse operation
695 */
696 totalStep: number;
697 /**
698 * Current step
699 */
700 currentStep: number;
701 /**
702 * Whether it is locked. When it is true, it will not respond to events
703 */
704 lock: boolean;
705 /**
706 * Whether the overlay is visible
707 */
708 visible: boolean;
709 /**
710 * Draw level
711 */
712 zLevel: number;
713 /**
714 * Whether the default figure corresponding to the point is required
715 */
716 needDefaultPointFigure: boolean;
717 /**
718 * Whether the default figure on the Y axis is required
719 */
720 needDefaultXAxisFigure: boolean;
721 /**
722 * Whether the default figure on the X axis is required
723 */
724 needDefaultYAxisFigure: boolean;
725 /**
726 * Mode
727 */
728 mode: OverlayMode;
729 /**
730 * When mode is weak_magnet is the response distance
731 */
732 modeSensitivity: number;
733 /**
734 * Time and value information
735 */
736 points: Array<Partial<Point>>;
737 /**
738 * Extended Data
739 */
740 extendData: any;
741 /**
742 * The style information and format are consistent with the overlay in the unified configuration
743 */
744 styles: Nullable<DeepPartial<OverlayStyle>>;
745 /**
746 * Create figures corresponding to points
747 */
748 createPointFigures: Nullable<OverlayCreateFiguresCallback>;
749 /**
750 * Create figures on the Y axis
751 */
752 createXAxisFigures: Nullable<OverlayCreateFiguresCallback>;
753 /**
754 * Create figures on the X axis
755 */
756 createYAxisFigures: Nullable<OverlayCreateFiguresCallback>;
757 /**
758 * Special handling callbacks when pressing events
759 */
760 performEventPressedMove: Nullable<(params: OverlayPerformEventParams) => void>;
761 /**
762 * In drawing, special handling callback when moving events
763 */
764 performEventMoveForDrawing: Nullable<(params: OverlayPerformEventParams) => void>;
765 /**
766 * Start drawing event
767 */
768 onDrawStart: Nullable<OverlayEventCallback>;
769 /**
770 * In drawing event
771 */
772 onDrawing: Nullable<OverlayEventCallback>;
773 /**
774 * Draw End Event
775 */
776 onDrawEnd: Nullable<OverlayEventCallback>;
777 /**
778 * Click event
779 */
780 onClick: Nullable<OverlayEventCallback>;
781 /**
782 * Double Click event
783 */
784 onDoubleClick: Nullable<OverlayEventCallback>;
785 /**
786 * Right click event
787 */
788 onRightClick: Nullable<OverlayEventCallback>;
789 /**
790 * Pressed move start event
791 */
792 onPressedMoveStart: Nullable<OverlayEventCallback>;
793 /**
794 * Pressed moving event
795 */
796 onPressedMoving: Nullable<OverlayEventCallback>;
797 /**
798 * Pressed move end event
799 */
800 onPressedMoveEnd: Nullable<OverlayEventCallback>;
801 /**
802 * Mouse enter event
803 */
804 onMouseEnter: Nullable<OverlayEventCallback>;
805 /**
806 * Mouse leave event
807 */
808 onMouseLeave: Nullable<OverlayEventCallback>;
809 /**
810 * Removed event
811 */
812 onRemoved: Nullable<OverlayEventCallback>;
813 /**
814 * Selected event
815 */
816 onSelected: Nullable<OverlayEventCallback>;
817 /**
818 * Deselected event
819 */
820 onDeselected: Nullable<OverlayEventCallback>;
821}
822export type OverlayTemplate = ExcludePickPartial<Omit<Overlay, "id" | "groupId" | "paneId" | "points" | "currentStep">, "name">;
823export type OverlayCreate = ExcludePickPartial<Omit<Overlay, "paneId" | "currentStep" | "totalStep" | "createPointFigures" | "createXAxisFigures" | "createYAxisFigures" | "performEventPressedMove" | "performEventMoveForDrawing">, "name">;
824export type OverlayRemove = Partial<Pick<Overlay, "id" | "groupId" | "name">>;
825export type OverlayConstructor = new () => Overlay;
826export declare enum DomPosition {
827 Root = "root",
828 Main = "main",
829 YAxis = "yAxis"
830}
831export interface ConvertFinder {
832 paneId?: string;
833 absolute?: boolean;
834}
835export 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 * @deprecated
862 * Since v9.8.0 deprecated, since v10 removed
863 */
864 applyMoreData: (dataList: KLineData[], more?: boolean, callback?: () => void) => void;
865 updateData: (data: KLineData, callback?: () => void) => void;
866 /**
867 * @deprecated
868 * Since v9.8.0 deprecated, since v10 removed
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}
900export interface AxisTick {
901 coord: number;
902 value: number | string;
903 text: string;
904}
905export interface AxisRange extends VisibleRange {
906 readonly range: number;
907 readonly realRange: number;
908}
909export interface Axis {
910 convertToPixel: (value: number) => number;
911 convertFromPixel: (px: number) => number;
912}
913export interface AxisCreateTicksParams {
914 range: AxisRange;
915 bounding: Bounding;
916 defaultTicks: AxisTick[];
917}
918export type AxisCreateTicksCallback = (params: AxisCreateTicksParams) => AxisTick[];
919export interface AxisTemplate {
920 name: string;
921 createTicks: AxisCreateTicksCallback;
922}
923export type XAxis = Axis;
924export 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}
931export type FigureTemplate<A = any, S = any> = Pick<Figure<A, S>, "name" | "draw" | "checkEventOn">;
932export type FigureCreate<A = any, S = any> = Pick<Figure<A, S>, "name" | "attrs" | "styles">;
933export type FigureConstructor<A = any, S = any> = new (figure: FigureCreate<A, S>) => ({
934 draw: (ctx: CanvasRenderingContext2D) => void;
935});
936declare function checkCoordinateOnCircle(coordinate: Coordinate, attrs: CircleAttrs | CircleAttrs[]): boolean;
937declare function drawCircle(ctx: CanvasRenderingContext2D, attrs: CircleAttrs | CircleAttrs[], styles: Partial<PolygonStyle>): void;
938export interface CircleAttrs {
939 x: number;
940 y: number;
941 r: number;
942}
943declare function checkCoordinateOnArc(coordinate: Coordinate, attrs: ArcAttrs | ArcAttrs[]): boolean;
944declare function drawArc(ctx: CanvasRenderingContext2D, attrs: ArcAttrs | ArcAttrs[], styles: Partial<LineStyle>): void;
945export interface ArcAttrs extends CircleAttrs {
946 startAngle: number;
947 endAngle: number;
948}
949declare function checkCoordinateOnRect(coordinate: Coordinate, attrs: RectAttrs | RectAttrs[]): boolean;
950declare function drawRect(ctx: CanvasRenderingContext2D, attrs: RectAttrs | RectAttrs[], styles: Partial<RectStyle>): void;
951export interface RectAttrs {
952 x: number;
953 y: number;
954 width: number;
955 height: number;
956}
957declare function checkCoordinateOnText(coordinate: Coordinate, attrs: TextAttrs | TextAttrs[], styles: Partial<TextStyle>): boolean;
958declare function drawText(ctx: CanvasRenderingContext2D, attrs: TextAttrs | TextAttrs[], styles: Partial<TextStyle>): void;
959export interface TextAttrs {
960 x: number;
961 y: number;
962 text: string;
963 width?: number;
964 height?: number;
965 align?: CanvasTextAlign;
966 baseline?: CanvasTextBaseline;
967}
968export declare enum IndicatorSeries {
969 Normal = "normal",
970 Price = "price",
971 Volume = "volume"
972}
973export 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>;
976export type IndicatorFigureAttrs = Partial<ArcAttrs> & Partial<LineStyle> & Partial<RectAttrs> & Partial<TextAttrs> & Record<string, any>;
977export interface IndicatorFigureCallbackBrother<PCN> {
978 prev: PCN;
979 current: PCN;
980 next: PCN;
981}
982export type IndicatorFigureAttrsCallbackCoordinate<D> = IndicatorFigureCallbackBrother<Record<keyof D, number> & {
983 x: number;
984}>;
985export interface IndicatorFigureAttrsCallbackParams<D> {
986 coordinate: IndicatorFigureAttrsCallbackCoordinate<D>;
987 bounding: Bounding;
988 barSpace: BarSpace;
989 xAxis: XAxis;
990 yAxis: YAxis;
991}
992export interface IndicatorFigureStylesCallbackDataChild<D> {
993 kLineData?: KLineData;
994 indicatorData?: D;
995}
996export type IndicatorFigureStylesCallbackData<D> = IndicatorFigureCallbackBrother<IndicatorFigureStylesCallbackDataChild<D>>;
997export type IndicatorFigureAttrsCallback<D> = (params: IndicatorFigureAttrsCallbackParams<D>) => IndicatorFigureAttrs;
998export type IndicatorFigureStylesCallback<D> = (data: IndicatorFigureStylesCallbackData<D>, indicator: Indicator<D>, defaultStyles: IndicatorStyle) => IndicatorFigureStyle;
999export 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}
1007export type IndicatorRegenerateFiguresCallback<D = any> = (calcParams: any[]) => Array<IndicatorFigure<D>>;
1008export interface IndicatorTooltipData {
1009 name: string;
1010 calcParamsText: string;
1011 icons: TooltipIconStyle[];
1012 values: TooltipLegend[];
1013}
1014export 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}
1024export type IndicatorCreateTooltipDataSourceCallback<D = any> = (params: IndicatorCreateTooltipDataSourceParams<D>) => IndicatorTooltipData;
1025export 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}
1036export type IndicatorDrawCallback<D = any> = (params: IndicatorDrawParams<D>) => boolean;
1037export type IndicatorCalcCallback<D> = (dataList: KLineData[], indicator: Indicator<D>) => Promise<D[]> | D[];
1038export interface Indicator<D = any> {
1039 /**
1040 * Indicator name
1041 */
1042 name: string;
1043 /**
1044 * Short name, for display
1045 */
1046 shortName: string;
1047 /**
1048 * Precision
1049 */
1050 precision: number;
1051 /**
1052 * Calculation parameters
1053 */
1054 calcParams: any[];
1055 /**
1056 * Whether ohlc column is required
1057 */
1058 shouldOhlc: boolean;
1059 /**
1060 * Whether large data values need to be formatted, starting from 1000, for example, whether 100000 needs to be formatted with 100K
1061 */
1062 shouldFormatBigNumber: boolean;
1063 /**
1064 * Whether the indicator is visible
1065 */
1066 visible: boolean;
1067 /**
1068 * Z index
1069 */
1070 zLevel: number;
1071 /**
1072 * Extend data
1073 */
1074 extendData: any;
1075 /**
1076 * Indicator series
1077 */
1078 series: IndicatorSeries;
1079 /**
1080 * Figure configuration information
1081 */
1082 figures: Array<IndicatorFigure<D>>;
1083 /**
1084 * Specified minimum value
1085 */
1086 minValue: Nullable<number>;
1087 /**
1088 * Specified maximum value
1089 */
1090 maxValue: Nullable<number>;
1091 /**
1092 * Style configuration
1093 */
1094 styles: Nullable<Partial<IndicatorStyle>>;
1095 /**
1096 * Indicator calculation
1097 */
1098 calc: IndicatorCalcCallback<D>;
1099 /**
1100 * Regenerate figure configuration
1101 */
1102 regenerateFigures: Nullable<IndicatorRegenerateFiguresCallback<D>>;
1103 /**
1104 * Create custom tooltip text
1105 */
1106 createTooltipDataSource: Nullable<IndicatorCreateTooltipDataSourceCallback>;
1107 /**
1108 * Custom draw
1109 */
1110 draw: Nullable<IndicatorDrawCallback<D>>;
1111 /**
1112 * Calculation result
1113 */
1114 result: D[];
1115}
1116export type IndicatorTemplate<D = any> = ExcludePickPartial<Omit<Indicator<D>, "result">, "name" | "calc">;
1117export type IndicatorCreate<D = any> = ExcludePickPartial<Omit<Indicator<D>, "result">, "name">;
1118declare function checkCoordinateOnLine(coordinate: Coordinate, attrs: LineAttrs | LineAttrs[]): boolean;
1119declare function getLinearYFromSlopeIntercept(kb: Nullable<number[]>, coordinate: Coordinate): number;
1120declare function getLinearYFromCoordinates(coordinate1: Coordinate, coordinate2: Coordinate, targetCoordinate: Coordinate): number;
1121declare function getLinearSlopeIntercept(coordinate1: Coordinate, coordinate2: Coordinate): Nullable<number[]>;
1122declare function drawLine(ctx: CanvasRenderingContext2D, attrs: LineAttrs | LineAttrs[], styles: Partial<SmoothLineStyle>): void;
1123export interface LineAttrs {
1124 coordinates: Coordinate[];
1125}
1126declare function checkCoordinateOnPolygon(coordinate: Coordinate, attrs: PolygonAttrs | PolygonAttrs[]): boolean;
1127declare function drawPolygon(ctx: CanvasRenderingContext2D, attrs: PolygonAttrs | PolygonAttrs[], styles: Partial<PolygonStyle>): void;
1128export interface PolygonAttrs {
1129 coordinates: Coordinate[];
1130}
1131export declare function getSupportedFigures(): string[];
1132export declare function registerFigure<A = any, S = any>(figure: FigureTemplate<A, S>): void;
1133export declare function getFigureClass<A = any, S = any>(name: string): Nullable<FigureConstructor<A, S>>;
1134export declare function registerIndicator<D>(indicator: IndicatorTemplate<D>): void;
1135export declare function getSupportedIndicators(): string[];
1136export declare function registerLocale(locale: string, ls: Locales): void;
1137export declare function getSupportedLocales(): string[];
1138export declare function registerOverlay(template: OverlayTemplate): void;
1139export declare function getOverlayClass(name: string): Nullable<OverlayConstructor>;
1140export declare function getSupportedOverlays(): string[];
1141export declare function registerStyles(name: string, ss: DeepPartial<Styles>): void;
1142export declare function registerXAxis(axis: AxisTemplate): void;
1143export declare function registerYAxis(axis: AxisTemplate): void;
1144/**
1145 * Chart version
1146 * @return {string}
1147 */
1148export declare function version(): string;
1149/**
1150 * Init chart instance
1151 * @param ds
1152 * @param options
1153 * @returns {Chart}
1154 */
1155export declare function init(ds: HTMLElement | string, options?: Options): Nullable<Chart>;
1156/**
1157 * Destroy chart instance
1158 * @param dcs
1159 */
1160export declare function dispose(dcs: HTMLElement | Chart | string): void;
1161export 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
1196export as namespace klinecharts;
1197
1198export {};