@funnest/charts 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chart.d.ts +108 -3
- package/dist/index.d.ts +9 -5
- package/dist/index.js +870 -253
- package/dist/indicators/definitions.d.ts +15 -3
- package/dist/indicators/manager.d.ts +8 -1
- package/dist/model/price-scale.d.ts +16 -0
- package/dist/objects/drawings.d.ts +62 -6
- package/dist/objects/trading.d.ts +13 -0
- package/dist/objects/types.d.ts +2 -0
- package/dist/render/renderer.d.ts +4 -0
- package/dist/settings.d.ts +7 -0
- package/package.json +1 -1
package/dist/chart.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type Locale } from './model/time-format';
|
|
2
2
|
import { TimeScale, type IndexRange, type TimeScaleOptions } from './model/time-scale';
|
|
3
|
-
import {
|
|
3
|
+
import type { IndicatorDefinition, IndicatorParams, IndicatorType } from './indicators/definitions';
|
|
4
4
|
import { type IndicatorConfig, type IndicatorPatch } from './indicators/manager';
|
|
5
|
-
import { type Drawing, type DrawingType } from './objects/drawings';
|
|
6
|
-
import { type ExecutionMarker, type LineHandle, type OrderLineOptions, type PositionLineOptions } from './objects/trading';
|
|
5
|
+
import { type Drawing, type DrawingDefinition, type DrawingType } from './objects/drawings';
|
|
6
|
+
import { type AlertLineOptions, type ExecutionMarker, type LineHandle, type OrderLineOptions, type PositionLineOptions } from './objects/trading';
|
|
7
7
|
import { type ChartSettings, type ChartState } from './settings';
|
|
8
8
|
import { type TradingAdapter } from './objects/trading-sync';
|
|
9
9
|
import { type ChartType, type CrosshairInfo, type PaneId } from './render/renderer';
|
|
@@ -33,6 +33,30 @@ export interface ChartOptions {
|
|
|
33
33
|
historyBatchSize?: number;
|
|
34
34
|
/** The user's fills, positions and orders, synced per symbol. See TradingAdapter. */
|
|
35
35
|
trading?: TradingAdapter;
|
|
36
|
+
/** Extra indicators (same shape as the built-ins). They appear in the widget's indicator picker. */
|
|
37
|
+
indicatorDefinitions?: readonly IndicatorDefinition[];
|
|
38
|
+
/** Extra drawing tools. They appear in the widget's drawing bar. */
|
|
39
|
+
drawingDefinitions?: readonly DrawingDefinition[];
|
|
40
|
+
}
|
|
41
|
+
/** A symbol overlaid for comparison. */
|
|
42
|
+
export interface CompareInfo {
|
|
43
|
+
symbol: string;
|
|
44
|
+
/** Display name once resolved (the symbol until then). */
|
|
45
|
+
name: string;
|
|
46
|
+
color: string;
|
|
47
|
+
/** Bars are loaded. */
|
|
48
|
+
ready: boolean;
|
|
49
|
+
}
|
|
50
|
+
/** Bar replay: history is cut at a past bar and played forward. */
|
|
51
|
+
export interface ReplayStatus {
|
|
52
|
+
/** Waiting for the user to click the bar to start from. */
|
|
53
|
+
selecting: boolean;
|
|
54
|
+
active: boolean;
|
|
55
|
+
playing: boolean;
|
|
56
|
+
/** Bars still hidden to the right. */
|
|
57
|
+
remaining: number;
|
|
58
|
+
/** Milliseconds between bars while playing. */
|
|
59
|
+
interval: number;
|
|
36
60
|
}
|
|
37
61
|
export interface ChartEvents {
|
|
38
62
|
crosshairMove: CrosshairInfo | null;
|
|
@@ -68,6 +92,13 @@ export interface ChartEvents {
|
|
|
68
92
|
/** Realtime connection state/latency reported by the datafeed. */
|
|
69
93
|
connectionChange: ConnectionState;
|
|
70
94
|
indicatorsChange: IndicatorConfig[];
|
|
95
|
+
/** Undo/redo availability changed (drawings and indicators are tracked). */
|
|
96
|
+
historyChange: {
|
|
97
|
+
canUndo: boolean;
|
|
98
|
+
canRedo: boolean;
|
|
99
|
+
};
|
|
100
|
+
comparesChange: CompareInfo[];
|
|
101
|
+
replayChange: ReplayStatus;
|
|
71
102
|
error: unknown;
|
|
72
103
|
}
|
|
73
104
|
export interface ChartPaneLayout {
|
|
@@ -165,6 +196,15 @@ export declare class Chart {
|
|
|
165
196
|
private loadingHistory;
|
|
166
197
|
private noMoreHistory;
|
|
167
198
|
private historyRequestedFor;
|
|
199
|
+
private countdownLabel;
|
|
200
|
+
/** Undo/redo of drawings + indicators, as JSON snapshots. */
|
|
201
|
+
private readonly history;
|
|
202
|
+
private readonly compares;
|
|
203
|
+
private compareVersion;
|
|
204
|
+
/** Base bar index of the % axis and compare lines (the first visible bar). */
|
|
205
|
+
private percentBaseIndex;
|
|
206
|
+
private replayState;
|
|
207
|
+
private replaySelecting;
|
|
168
208
|
constructor(container: HTMLElement, options?: ChartOptions);
|
|
169
209
|
/** Replaces all bars and scrolls to the latest. */
|
|
170
210
|
setData(bars: readonly Bar[]): void;
|
|
@@ -272,6 +312,58 @@ export declare class Chart {
|
|
|
272
312
|
/** Formatted indicator values at a bar index (default: the last bar), for legends. */
|
|
273
313
|
indicatorLegend(index?: number): IndicatorLegendItem[];
|
|
274
314
|
private indicatorsChanged;
|
|
315
|
+
/** Built-in and custom indicators this chart can add. */
|
|
316
|
+
indicatorDefinitions(): IndicatorDefinition[];
|
|
317
|
+
indicatorDefinition(type: IndicatorType): IndicatorDefinition | undefined;
|
|
318
|
+
/** Built-in and custom drawing tools, in drawing-bar order. */
|
|
319
|
+
drawingDefinitions(): DrawingDefinition[];
|
|
320
|
+
get canUndo(): boolean;
|
|
321
|
+
get canRedo(): boolean;
|
|
322
|
+
/** Reverts the last drawing or indicator change. */
|
|
323
|
+
undo(): void;
|
|
324
|
+
redo(): void;
|
|
325
|
+
private historySnapshot;
|
|
326
|
+
private recordHistory;
|
|
327
|
+
private resetHistory;
|
|
328
|
+
private applyHistory;
|
|
329
|
+
private emitHistory;
|
|
330
|
+
/**
|
|
331
|
+
* Overlays another symbol's closes as a line, rebased to the first visible bar. The price
|
|
332
|
+
* axis switches to % while any symbol is compared. Needs the `datafeed` option.
|
|
333
|
+
*/
|
|
334
|
+
addCompare(symbol: string): Promise<void>;
|
|
335
|
+
removeCompare(symbol: string): void;
|
|
336
|
+
getCompares(): CompareInfo[];
|
|
337
|
+
/** Each compared symbol's % change from the first visible bar, at `index` (default: the last bar). */
|
|
338
|
+
compareLegend(index?: number): (CompareInfo & {
|
|
339
|
+
value: string;
|
|
340
|
+
})[];
|
|
341
|
+
private comparesChanged;
|
|
342
|
+
/** (Re)loads a compared symbol's bars at the current resolution, back to the main series' first bar. */
|
|
343
|
+
private reloadCompare;
|
|
344
|
+
/** Pages a compared symbol's history back until it covers the main series' first bar. */
|
|
345
|
+
private loadOlderCompare;
|
|
346
|
+
/** Compare closes at each main bar (the compare bar at or before its time). */
|
|
347
|
+
private alignedCompare;
|
|
348
|
+
/** Compare lines in main-price space, each rebased so its first visible value sits on the main close there. */
|
|
349
|
+
private compareOverlays;
|
|
350
|
+
get replay(): ReplayStatus;
|
|
351
|
+
/** Arms start picking: the next click on the chart starts a replay from that bar. Esc cancels. */
|
|
352
|
+
setReplaySelecting(on: boolean): void;
|
|
353
|
+
/** Hides every bar after `time` (UTC ms); reveal them with replayStep/replayPlay. */
|
|
354
|
+
startReplay(time: number): void;
|
|
355
|
+
/** Reveals the next `count` hidden bars. */
|
|
356
|
+
replayStep(count?: number): void;
|
|
357
|
+
/** Plays one bar every `interval` ms (default: the last speed used, initially 1000). */
|
|
358
|
+
replayPlay(interval?: number): void;
|
|
359
|
+
/** Changes the playback speed (ms per bar), also while playing. */
|
|
360
|
+
setReplayInterval(interval: number): void;
|
|
361
|
+
replayPause(): void;
|
|
362
|
+
/** Leaves replay and shows every bar again (including live ones that arrived meanwhile). */
|
|
363
|
+
stopReplay(): void;
|
|
364
|
+
private endReplay;
|
|
365
|
+
private stopReplayTimer;
|
|
366
|
+
private emitReplay;
|
|
275
367
|
private indicatorScale;
|
|
276
368
|
/**
|
|
277
369
|
* Connects the user's account (fills, positions, orders). The chart loads them for the
|
|
@@ -282,6 +374,8 @@ export declare class Chart {
|
|
|
282
374
|
addPositionLine(options: PositionLineOptions): LineHandle<PositionLineOptions>;
|
|
283
375
|
/** Pending order line. Pass `onMove` to make it draggable and `onCancel` for an × button. */
|
|
284
376
|
addOrderLine(options: OrderLineOptions): LineHandle<OrderLineOptions>;
|
|
377
|
+
/** Price alert line (dotted, gray, "알림" label). Pass `onMove` to make it draggable and `onCancel` for an ×. */
|
|
378
|
+
addAlertLine(options: AlertLineOptions): LineHandle<AlertLineOptions>;
|
|
285
379
|
/** Fill markers (▲ buy under the bar, ▼ sell above). Replaces the previous set. */
|
|
286
380
|
setExecutions(markers: readonly ExecutionMarker[]): void;
|
|
287
381
|
setTheme(theme: Partial<ThemeTokens>): void;
|
|
@@ -307,6 +401,15 @@ export declare class Chart {
|
|
|
307
401
|
private barInterval;
|
|
308
402
|
private paneCoords;
|
|
309
403
|
private computeFrame;
|
|
404
|
+
/** Price-pane tick values for the current axis mode. */
|
|
405
|
+
private mainTicks;
|
|
406
|
+
private percentBase;
|
|
407
|
+
/** Price-axis tick labels: prices, or "+2.5%" on a % axis (decimals follow the step). */
|
|
408
|
+
private mainTickFormat;
|
|
409
|
+
/** Crosshair and last-price label of the price pane. */
|
|
410
|
+
private mainValueFormat;
|
|
411
|
+
/** Time left in the last bar, when it's still forming (null otherwise). */
|
|
412
|
+
private countdownText;
|
|
310
413
|
/** Auto-scales the price pane to visible candles and overlay indicators; returns the candle extremes. */
|
|
311
414
|
private autoScale;
|
|
312
415
|
private autoScaleIndicator;
|
|
@@ -325,6 +428,8 @@ export declare class Chart {
|
|
|
325
428
|
private createInteractionHost;
|
|
326
429
|
/** Esc cancels a drawing in progress or deselects; Delete/Backspace removes the selected drawing. */
|
|
327
430
|
private observeKeyboard;
|
|
431
|
+
/** Repaints when the bar-close countdown ticks over (once a second, only while it shows or changes). */
|
|
432
|
+
private observeCountdown;
|
|
328
433
|
private observeSize;
|
|
329
434
|
/** Theme values using `var(--x)` follow the host page's dark-mode / theme switches automatically. */
|
|
330
435
|
private observeThemeVariables;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { Chart, createChart, fallbackResolution } from './chart';
|
|
2
2
|
export { DEFAULT_CHART_SETTINGS, parseChartState } from './settings';
|
|
3
3
|
export type { ChartSettings, ChartState } from './settings';
|
|
4
|
-
export type { ChartEvents, ChartLayout, ChartOptions, ChartPaneLayout, IndicatorLegendItem } from './chart';
|
|
4
|
+
export type { ChartEvents, ChartLayout, ChartOptions, ChartPaneLayout, CompareInfo, IndicatorLegendItem, ReplayStatus } from './chart';
|
|
5
|
+
export type { PriceScaleMode } from './model/price-scale';
|
|
5
6
|
export type { CrosshairInfo, PaneId } from './render/renderer';
|
|
6
7
|
export type { Locale } from './model/time-format';
|
|
7
8
|
export type { IndexRange, TimeScaleOptions } from './model/time-scale';
|
|
@@ -12,15 +13,18 @@ export type { FormatPriceOptions } from './price';
|
|
|
12
13
|
export { decimalsOf, formatCompact, formatPrice, krxTickSize, resolveTickSize, roundToTick } from './price';
|
|
13
14
|
export { isIntradayResolution, resolutionToMs } from './resolution';
|
|
14
15
|
export type { ChartType } from './render/renderer';
|
|
15
|
-
export type { Drawing, DrawingPoint, DrawingType } from './objects/drawings';
|
|
16
|
-
export { FIB_LEVELS } from './objects/drawings';
|
|
16
|
+
export type { BuiltinDrawingType, Drawing, DrawingDefinition, DrawingGeometry, DrawingPoint, DrawingRenderContext, DrawingType, } from './objects/drawings';
|
|
17
|
+
export { BUILTIN_DRAWINGS, distToSegment, FIB_LEVELS } from './objects/drawings';
|
|
18
|
+
export type { PaneCoords } from './objects/types';
|
|
19
|
+
export type { Painter } from './render/painter';
|
|
20
|
+
export type { Palette } from './render/renderer';
|
|
17
21
|
export { snapToOhlc } from './objects/magnet';
|
|
18
|
-
export type { ExecutionGroup, ExecutionMarker, LineHandle, OrderLineOptions, PositionLineOptions } from './objects/trading';
|
|
22
|
+
export type { AlertLineOptions, ExecutionGroup, ExecutionMarker, LineHandle, OrderLineOptions, PositionLineOptions } from './objects/trading';
|
|
19
23
|
export type { Execution, OrderInfo, PositionInfo, TradingAdapter, TradingCallbacks } from './objects/trading-sync';
|
|
20
24
|
export { bucketStart, TickAggregator, timeZoneOffset } from './realtime';
|
|
21
25
|
export type { Tick } from './realtime';
|
|
22
26
|
export { INDICATORS, SERIES_COLORS } from './indicators/definitions';
|
|
23
|
-
export type { IndicatorDefinition, IndicatorOutput, IndicatorParams, IndicatorParamSpec, IndicatorSeries, IndicatorType, } from './indicators/definitions';
|
|
27
|
+
export type { BuiltinIndicatorType, IndicatorDefinition, IndicatorOutput, IndicatorParams, IndicatorParamSpec, IndicatorSeries, IndicatorType, } from './indicators/definitions';
|
|
24
28
|
export type { IndicatorConfig, IndicatorPatch } from './indicators/manager';
|
|
25
29
|
export { maLines, PRICE_SOURCES, priceSource } from './indicators/definitions';
|
|
26
30
|
export type { MaLine, PriceSource, SeriesStyle } from './indicators/definitions';
|