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