react-klinecharts-ui 0.2.0 → 0.4.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/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as react from 'react';
2
2
  import { Dispatch, RefObject, ReactNode, ReactElement } from 'react';
3
- import { Period, SymbolInfo, KLineData, Chart, DeepPartial, Styles, OverlayTemplate, DataLoader, IndicatorTemplate } from 'react-klinecharts';
3
+ import { Period, SymbolInfo, KLineData, Chart, DeepPartial, Styles, OverlayTemplate, YAxisOverride, DataLoader, IndicatorTemplate } from 'react-klinecharts';
4
4
  import { OrderLineExtendData } from './extensions.cjs';
5
- export { OrderLineFontStyle, OrderLineLabelStyle, OrderLineLineStyle, OrderLineMarkStyle, OrderLinePadding, indicators, orderLine, overlays, registerExtensions } from './extensions.cjs';
5
+ export { DepthOverlayExtendData, DepthOverlayRow, OrderLineFontStyle, OrderLineLabelStyle, OrderLineLineStyle, OrderLineMarkStyle, OrderLinePadding, depthOverlay, indicators, orderLine, overlays, registerExtensions } from './extensions.cjs';
6
6
 
7
7
  interface TerminalPeriod extends Period {
8
8
  label: string;
@@ -65,6 +65,15 @@ interface KlinechartsUIState {
65
65
  periods: TerminalPeriod[];
66
66
  mainIndicators: string[];
67
67
  subIndicators: Record<string, string>;
68
+ /**
69
+ * Custom Y-axis bindings for indicators, keyed by indicator id
70
+ * (`main_<name>` / `sub_<name>`), value is the bound `yAxisId`.
71
+ * Only populated for indicators explicitly bound to a secondary
72
+ * (non-default) axis via `useIndicators`. Indicators on the shared
73
+ * default axis are absent. Used to persist bindings across
74
+ * undo/redo and layout presets.
75
+ */
76
+ indicatorAxes: Record<string, string>;
68
77
  styles: DeepPartial<Styles> | undefined;
69
78
  screenshotUrl: string | null;
70
79
  }
@@ -92,6 +101,9 @@ type KlinechartsUIAction = {
92
101
  } | {
93
102
  type: "SET_SUB_INDICATORS";
94
103
  indicators: Record<string, string>;
104
+ } | {
105
+ type: "SET_INDICATOR_AXES";
106
+ axes: Record<string, string>;
95
107
  } | {
96
108
  type: "SET_STYLES";
97
109
  styles: DeepPartial<Styles> | undefined;
@@ -176,6 +188,16 @@ interface IndicatorInfo {
176
188
  name: string;
177
189
  isActive: boolean;
178
190
  }
191
+ /** Options accepted when adding an indicator. */
192
+ interface AddIndicatorOptions {
193
+ /**
194
+ * Bind the indicator to a custom Y-axis (klinecharts v10 multiple y-axes).
195
+ * Provide a stable `id` to create/share a secondary axis; e.g.
196
+ * `{ id: "rsi_axis", position: "left" }`. Omit to use the pane's default
197
+ * (shared) axis.
198
+ */
199
+ yAxis?: YAxisOverride;
200
+ }
179
201
  interface UseIndicatorsReturn {
180
202
  mainIndicators: IndicatorInfo[];
181
203
  subIndicators: IndicatorInfo[];
@@ -183,9 +205,9 @@ interface UseIndicatorsReturn {
183
205
  activeSubIndicators: Record<string, string>;
184
206
  availableMainIndicators: string[];
185
207
  availableSubIndicators: string[];
186
- addMainIndicator: (name: string) => void;
208
+ addMainIndicator: (name: string, options?: AddIndicatorOptions) => void;
187
209
  removeMainIndicator: (name: string) => void;
188
- addSubIndicator: (name: string) => void;
210
+ addSubIndicator: (name: string, options?: AddIndicatorOptions) => void;
189
211
  removeSubIndicator: (name: string) => void;
190
212
  toggleMainIndicator: (name: string) => void;
191
213
  toggleSubIndicator: (name: string) => void;
@@ -199,6 +221,29 @@ interface UseIndicatorsReturn {
199
221
  }[];
200
222
  isMainIndicatorActive: (name: string) => boolean;
201
223
  isSubIndicatorActive: (name: string) => boolean;
224
+ /** Collapse a sub-indicator pane to minimal height (30px). */
225
+ collapseSubIndicator: (name: string) => void;
226
+ /** Expand a previously collapsed sub-indicator pane to its prior height. */
227
+ expandSubIndicator: (name: string) => void;
228
+ /** Whether the given sub-indicator pane is currently collapsed. */
229
+ isSubIndicatorCollapsed: (name: string) => boolean;
230
+ /** Reorder a sub-indicator pane up or down relative to other sub-indicators. */
231
+ reorderSubIndicator: (name: string, direction: "up" | "down") => void;
232
+ /**
233
+ * Custom Y-axis bindings, keyed by indicator id (`main_<name>` /
234
+ * `sub_<name>`). Only contains indicators bound to a secondary axis.
235
+ */
236
+ indicatorAxes: Record<string, string>;
237
+ /** Get the custom `yAxisId` an indicator is bound to, or `undefined` for the default axis. */
238
+ getIndicatorAxis: (name: string, isMain: boolean) => string | undefined;
239
+ /**
240
+ * Rebind an existing indicator to a different Y-axis. Because klinecharts v10
241
+ * `overrideIndicator` cannot change axis binding, this removes and recreates
242
+ * the indicator (preserving calc params, styles and visibility).
243
+ * Pass `yAxis` to bind to a secondary axis, or omit it to return the
244
+ * indicator to the pane's default (shared) axis.
245
+ */
246
+ bindIndicatorToNewAxis: (name: string, isMain: boolean, yAxis?: YAxisOverride) => void;
202
247
  }
203
248
  declare function useIndicators(): UseIndicatorsReturn;
204
249
 
@@ -227,12 +272,16 @@ interface UseDrawingToolsReturn {
227
272
  magnetMode: MagnetMode;
228
273
  isLocked: boolean;
229
274
  isVisible: boolean;
275
+ /** Whether drawing tools auto-retrigger after completing a shape. Default: true. */
276
+ autoRetrigger: boolean;
230
277
  selectTool: (name: string) => void;
231
278
  clearActiveTool: () => void;
232
279
  setMagnetMode: (mode: MagnetMode) => void;
233
280
  toggleLock: () => void;
234
281
  toggleVisibility: () => void;
235
282
  removeAllDrawings: () => void;
283
+ /** Enable/disable auto-retrigger mode. */
284
+ setAutoRetrigger: (enabled: boolean) => void;
236
285
  }
237
286
  declare function useDrawingTools(): UseDrawingToolsReturn;
238
287
 
@@ -406,6 +455,8 @@ interface ChartLayoutState {
406
455
  calcParams: any[];
407
456
  visible: boolean;
408
457
  styles?: any;
458
+ /** Custom Y-axis the indicator is bound to (klinecharts v10 multiple y-axes). */
459
+ yAxisId?: string;
409
460
  }>;
410
461
  drawings: Array<{
411
462
  name: string;
@@ -494,6 +545,182 @@ interface UseScriptEditorReturn {
494
545
  */
495
546
  declare function useScriptEditor(): UseScriptEditorReturn;
496
547
 
548
+ interface CrosshairBarData {
549
+ open: number;
550
+ high: number;
551
+ low: number;
552
+ close: number;
553
+ volume: number;
554
+ timestamp: number;
555
+ change: number;
556
+ changePercent: number;
557
+ }
558
+ interface UseCrosshairReturn {
559
+ /** OHLCV data of the bar under the crosshair. Null when cursor is off-chart. */
560
+ barData: CrosshairBarData | null;
561
+ }
562
+ declare function useCrosshair(): UseCrosshairReturn;
563
+
564
+ type AlertCondition = "crossing_up" | "crossing_down" | "crossing";
565
+ interface Alert {
566
+ id: string;
567
+ price: number;
568
+ condition: AlertCondition;
569
+ message?: string;
570
+ triggered: boolean;
571
+ }
572
+ interface UseAlertsReturn {
573
+ alerts: Alert[];
574
+ addAlert: (price: number, condition: AlertCondition, message?: string) => string;
575
+ removeAlert: (id: string) => void;
576
+ clearAlerts: () => void;
577
+ onAlertTriggered: (callback: (alert: Alert) => void) => void;
578
+ }
579
+ declare function useAlerts(): UseAlertsReturn;
580
+
581
+ type ExportFormat = "csv" | "json";
582
+ interface UseDataExportReturn {
583
+ /** Export all chart data */
584
+ exportAll: (format: ExportFormat) => void;
585
+ /** Export only the visible range */
586
+ exportVisible: (format: ExportFormat) => void;
587
+ }
588
+ declare function useDataExport(): UseDataExportReturn;
589
+
590
+ interface WatchlistItem {
591
+ ticker: string;
592
+ lastPrice: number | null;
593
+ change: number | null;
594
+ changePercent: number | null;
595
+ }
596
+ interface UseWatchlistReturn {
597
+ items: WatchlistItem[];
598
+ addSymbol: (ticker: string) => void;
599
+ removeSymbol: (ticker: string) => void;
600
+ switchSymbol: (ticker: string) => void;
601
+ activeSymbol: string | null;
602
+ }
603
+ declare function useWatchlist(): UseWatchlistReturn;
604
+
605
+ type ReplaySpeed = 1 | 2 | 5 | 10;
606
+ interface UseReplayReturn {
607
+ /** Whether a replay session is active */
608
+ isReplaying: boolean;
609
+ /** Whether the replay is currently paused */
610
+ isPaused: boolean;
611
+ /** Current playback speed multiplier */
612
+ speed: ReplaySpeed;
613
+ /** Current bar index in the replay */
614
+ barIndex: number;
615
+ /** Total number of bars in the saved data */
616
+ totalBars: number;
617
+ /** Start replaying from the beginning */
618
+ startReplay: () => void;
619
+ /** Stop replay and restore original data */
620
+ stopReplay: () => void;
621
+ /** Toggle play/pause */
622
+ togglePause: () => void;
623
+ /** Advance one bar while paused */
624
+ stepForward: () => void;
625
+ /** Go back one bar while paused */
626
+ stepBackward: () => void;
627
+ /** Seek to a specific bar index (0-based). Pauses playback. */
628
+ seekTo: (index: number) => void;
629
+ /** Change the playback speed */
630
+ setSpeed: (speed: ReplaySpeed) => void;
631
+ }
632
+ /**
633
+ * Headless hook for historical data replay (bar-by-bar playback).
634
+ *
635
+ * Loads the current chart data, clears the chart, then progressively adds
636
+ * bars back one at a time at the configured speed. Useful for backtesting
637
+ * and reviewing price action.
638
+ */
639
+ declare function useReplay(): UseReplayReturn;
640
+
641
+ interface CompareSymbol {
642
+ ticker: string;
643
+ /** Base price (first bar close) used for percentage normalization */
644
+ basePrice: number | null;
645
+ color: string;
646
+ visible: boolean;
647
+ }
648
+ interface UseCompareReturn {
649
+ /** Currently compared symbols */
650
+ symbols: CompareSymbol[];
651
+ /** Add a symbol — fetches data, normalizes to %, renders as indicator line */
652
+ addSymbol: (ticker: string, color?: string) => Promise<void>;
653
+ /** Remove a symbol overlay */
654
+ removeSymbol: (ticker: string) => void;
655
+ /** Toggle visibility of a compared symbol */
656
+ toggleSymbol: (ticker: string) => void;
657
+ /** Clear all comparisons */
658
+ clearAll: () => void;
659
+ }
660
+ /**
661
+ * Headless hook for comparing multiple symbols on the same chart.
662
+ *
663
+ * Fetches historical data for each added symbol via the datafeed,
664
+ * normalizes prices to percentage change from the first bar,
665
+ * and renders each as a custom indicator line on the main pane.
666
+ */
667
+ declare function useCompare(): UseCompareReturn;
668
+
669
+ interface MeasurePoint {
670
+ price: number;
671
+ timestamp: number;
672
+ barIndex: number;
673
+ }
674
+ interface MeasureResult {
675
+ from: MeasurePoint;
676
+ to: MeasurePoint;
677
+ /** Absolute price difference */
678
+ priceDiff: number;
679
+ /** Percentage change from → to */
680
+ pricePercent: number;
681
+ /** Number of bars between the two points */
682
+ bars: number;
683
+ /** Time difference in milliseconds */
684
+ timeDiff: number;
685
+ }
686
+ interface UseMeasureReturn {
687
+ /** Whether measure mode is active (waiting for clicks) */
688
+ isActive: boolean;
689
+ /** Start measure mode — next two clicks on chart set from/to */
690
+ startMeasure: () => void;
691
+ /** Cancel measure mode */
692
+ cancelMeasure: () => void;
693
+ /** Current measurement result (null until both points are set) */
694
+ result: MeasureResult | null;
695
+ /** Clear the current measurement */
696
+ clearResult: () => void;
697
+ /** First point (set after first click) */
698
+ fromPoint: MeasurePoint | null;
699
+ }
700
+ /**
701
+ * Headless hook for measuring distance/time/percentage between two points.
702
+ *
703
+ * Activates measure mode, captures two clicks on the chart via overlay
704
+ * interaction, then computes price diff, %, bar count, and time diff.
705
+ */
706
+ declare function useMeasure(): UseMeasureReturn;
707
+
708
+ interface Annotation {
709
+ id: string;
710
+ text: string;
711
+ price: number;
712
+ timestamp: number;
713
+ color?: string;
714
+ }
715
+ interface UseAnnotationsReturn {
716
+ annotations: Annotation[];
717
+ addAnnotation: (text: string, price: number, timestamp: number, color?: string) => string;
718
+ removeAnnotation: (id: string) => void;
719
+ updateAnnotation: (id: string, updates: Partial<Pick<Annotation, "text" | "color">>) => void;
720
+ clearAnnotations: () => void;
721
+ }
722
+ declare function useAnnotations(): UseAnnotationsReturn;
723
+
497
724
  interface TimezoneOption {
498
725
  key: string;
499
726
  localeKey: string;
@@ -673,4 +900,4 @@ declare const superTrend: IndicatorTemplate;
673
900
 
674
901
  declare const vwap: IndicatorTemplate;
675
902
 
676
- export { CANDLE_TYPES, COMPARE_RULES, type CandleTypeItem, type CandleTypeOption, type ChartLayoutState, type CompareRule, DEFAULT_PERIODS, DRAWING_CATEGORIES, type Datafeed, type DrawingCategoryItem, type DrawingTool, type DrawingToolCategory, type DrawingToolItem, INDICATOR_PARAMS, type IndicatorDefinition, type IndicatorInfo, type IndicatorParamConfig, type KlinechartsUIAction, type KlinechartsUIContextValue, KlinechartsUIDispatchContext, type KlinechartsUIDispatchValue, type KlinechartsUIOptions, KlinechartsUIProvider, type KlinechartsUISettingsState, type KlinechartsUIState, KlinechartsUIStateContext, type LayoutEntry, MAIN_INDICATORS, type MagnetMode, OrderLineExtendData, type OrderLineOptions, PRICE_AXIS_TYPES, type PartialSymbolInfo, type PriceAxisType, SUB_INDICATORS, type ScriptPlacement, TA, TIMEZONES, TOOLTIP_SHOW_RULES, type TerminalPeriod, type TimezoneItem, type TimezoneOption, type TooltipShowRule, type UndoRedoAction, type UndoRedoActionType, type UseDrawingToolsReturn, type UseFullscreenReturn, type UseIndicatorsReturn, type UseKlinechartsUILoadingReturn, type UseKlinechartsUISettingsReturn, type UseKlinechartsUIThemeReturn, type UseLayoutManagerReturn, type UseOrderLinesReturn, type UsePeriodsReturn, type UseScreenshotReturn, type UseScriptEditorReturn, type UseSymbolSearchReturn, type UseTimezoneReturn, type UseUndoRedoReturn, YAXIS_POSITIONS, type YAxisPosition, abcd, anyWaves, arrow, bollTv, brush, cci, circle, createDataLoader, eightWaves, elliottWave, fibRetracement, fibonacciCircle, fibonacciExtension, fibonacciSegment, fibonacciSpeedResistanceFan, fibonacciSpiral, fiveWaves, gannBox, gannFan, hma, ichimoku, longPosition, maRibbon, macdTv, measure, parallelChannel, parallelogram, pivotPoints, ray, rect, rsiTv, shortPosition, stochastic, superTrend, threeWaves, triangle, useDrawingTools, useFullscreen, useIndicators, useKlinechartsUI, useKlinechartsUILoading, useKlinechartsUISettings, useKlinechartsUITheme, useLayoutManager, useOrderLines, usePeriods, useScreenshot, useScriptEditor, useSymbolSearch, useTimezone, useUndoRedo, vwap, xabcd };
903
+ export { type AddIndicatorOptions, type Alert, type AlertCondition, type Annotation, CANDLE_TYPES, COMPARE_RULES, type CandleTypeItem, type CandleTypeOption, type ChartLayoutState, type CompareRule, type CompareSymbol, type CrosshairBarData, DEFAULT_PERIODS, DRAWING_CATEGORIES, type Datafeed, type DrawingCategoryItem, type DrawingTool, type DrawingToolCategory, type DrawingToolItem, type ExportFormat, INDICATOR_PARAMS, type IndicatorDefinition, type IndicatorInfo, type IndicatorParamConfig, type KlinechartsUIAction, type KlinechartsUIContextValue, KlinechartsUIDispatchContext, type KlinechartsUIDispatchValue, type KlinechartsUIOptions, KlinechartsUIProvider, type KlinechartsUISettingsState, type KlinechartsUIState, KlinechartsUIStateContext, type LayoutEntry, MAIN_INDICATORS, type MagnetMode, type MeasurePoint, type MeasureResult, OrderLineExtendData, type OrderLineOptions, PRICE_AXIS_TYPES, type PartialSymbolInfo, type PriceAxisType, type ReplaySpeed, SUB_INDICATORS, type ScriptPlacement, TA, TIMEZONES, TOOLTIP_SHOW_RULES, type TerminalPeriod, type TimezoneItem, type TimezoneOption, type TooltipShowRule, type UndoRedoAction, type UndoRedoActionType, type UseAlertsReturn, type UseAnnotationsReturn, type UseCompareReturn, type UseCrosshairReturn, type UseDataExportReturn, type UseDrawingToolsReturn, type UseFullscreenReturn, type UseIndicatorsReturn, type UseKlinechartsUILoadingReturn, type UseKlinechartsUISettingsReturn, type UseKlinechartsUIThemeReturn, type UseLayoutManagerReturn, type UseMeasureReturn, type UseOrderLinesReturn, type UsePeriodsReturn, type UseReplayReturn, type UseScreenshotReturn, type UseScriptEditorReturn, type UseSymbolSearchReturn, type UseTimezoneReturn, type UseUndoRedoReturn, type UseWatchlistReturn, type WatchlistItem, YAXIS_POSITIONS, type YAxisPosition, abcd, anyWaves, arrow, bollTv, brush, cci, circle, createDataLoader, eightWaves, elliottWave, fibRetracement, fibonacciCircle, fibonacciExtension, fibonacciSegment, fibonacciSpeedResistanceFan, fibonacciSpiral, fiveWaves, gannBox, gannFan, hma, ichimoku, longPosition, maRibbon, macdTv, measure, parallelChannel, parallelogram, pivotPoints, ray, rect, rsiTv, shortPosition, stochastic, superTrend, threeWaves, triangle, useAlerts, useAnnotations, useCompare, useCrosshair, useDataExport, useDrawingTools, useFullscreen, useIndicators, useKlinechartsUI, useKlinechartsUILoading, useKlinechartsUISettings, useKlinechartsUITheme, useLayoutManager, useMeasure, useOrderLines, usePeriods, useReplay, useScreenshot, useScriptEditor, useSymbolSearch, useTimezone, useUndoRedo, useWatchlist, vwap, xabcd };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as react from 'react';
2
2
  import { Dispatch, RefObject, ReactNode, ReactElement } from 'react';
3
- import { Period, SymbolInfo, KLineData, Chart, DeepPartial, Styles, OverlayTemplate, DataLoader, IndicatorTemplate } from 'react-klinecharts';
3
+ import { Period, SymbolInfo, KLineData, Chart, DeepPartial, Styles, OverlayTemplate, YAxisOverride, DataLoader, IndicatorTemplate } from 'react-klinecharts';
4
4
  import { OrderLineExtendData } from './extensions.js';
5
- export { OrderLineFontStyle, OrderLineLabelStyle, OrderLineLineStyle, OrderLineMarkStyle, OrderLinePadding, indicators, orderLine, overlays, registerExtensions } from './extensions.js';
5
+ export { DepthOverlayExtendData, DepthOverlayRow, OrderLineFontStyle, OrderLineLabelStyle, OrderLineLineStyle, OrderLineMarkStyle, OrderLinePadding, depthOverlay, indicators, orderLine, overlays, registerExtensions } from './extensions.js';
6
6
 
7
7
  interface TerminalPeriod extends Period {
8
8
  label: string;
@@ -65,6 +65,15 @@ interface KlinechartsUIState {
65
65
  periods: TerminalPeriod[];
66
66
  mainIndicators: string[];
67
67
  subIndicators: Record<string, string>;
68
+ /**
69
+ * Custom Y-axis bindings for indicators, keyed by indicator id
70
+ * (`main_<name>` / `sub_<name>`), value is the bound `yAxisId`.
71
+ * Only populated for indicators explicitly bound to a secondary
72
+ * (non-default) axis via `useIndicators`. Indicators on the shared
73
+ * default axis are absent. Used to persist bindings across
74
+ * undo/redo and layout presets.
75
+ */
76
+ indicatorAxes: Record<string, string>;
68
77
  styles: DeepPartial<Styles> | undefined;
69
78
  screenshotUrl: string | null;
70
79
  }
@@ -92,6 +101,9 @@ type KlinechartsUIAction = {
92
101
  } | {
93
102
  type: "SET_SUB_INDICATORS";
94
103
  indicators: Record<string, string>;
104
+ } | {
105
+ type: "SET_INDICATOR_AXES";
106
+ axes: Record<string, string>;
95
107
  } | {
96
108
  type: "SET_STYLES";
97
109
  styles: DeepPartial<Styles> | undefined;
@@ -176,6 +188,16 @@ interface IndicatorInfo {
176
188
  name: string;
177
189
  isActive: boolean;
178
190
  }
191
+ /** Options accepted when adding an indicator. */
192
+ interface AddIndicatorOptions {
193
+ /**
194
+ * Bind the indicator to a custom Y-axis (klinecharts v10 multiple y-axes).
195
+ * Provide a stable `id` to create/share a secondary axis; e.g.
196
+ * `{ id: "rsi_axis", position: "left" }`. Omit to use the pane's default
197
+ * (shared) axis.
198
+ */
199
+ yAxis?: YAxisOverride;
200
+ }
179
201
  interface UseIndicatorsReturn {
180
202
  mainIndicators: IndicatorInfo[];
181
203
  subIndicators: IndicatorInfo[];
@@ -183,9 +205,9 @@ interface UseIndicatorsReturn {
183
205
  activeSubIndicators: Record<string, string>;
184
206
  availableMainIndicators: string[];
185
207
  availableSubIndicators: string[];
186
- addMainIndicator: (name: string) => void;
208
+ addMainIndicator: (name: string, options?: AddIndicatorOptions) => void;
187
209
  removeMainIndicator: (name: string) => void;
188
- addSubIndicator: (name: string) => void;
210
+ addSubIndicator: (name: string, options?: AddIndicatorOptions) => void;
189
211
  removeSubIndicator: (name: string) => void;
190
212
  toggleMainIndicator: (name: string) => void;
191
213
  toggleSubIndicator: (name: string) => void;
@@ -199,6 +221,29 @@ interface UseIndicatorsReturn {
199
221
  }[];
200
222
  isMainIndicatorActive: (name: string) => boolean;
201
223
  isSubIndicatorActive: (name: string) => boolean;
224
+ /** Collapse a sub-indicator pane to minimal height (30px). */
225
+ collapseSubIndicator: (name: string) => void;
226
+ /** Expand a previously collapsed sub-indicator pane to its prior height. */
227
+ expandSubIndicator: (name: string) => void;
228
+ /** Whether the given sub-indicator pane is currently collapsed. */
229
+ isSubIndicatorCollapsed: (name: string) => boolean;
230
+ /** Reorder a sub-indicator pane up or down relative to other sub-indicators. */
231
+ reorderSubIndicator: (name: string, direction: "up" | "down") => void;
232
+ /**
233
+ * Custom Y-axis bindings, keyed by indicator id (`main_<name>` /
234
+ * `sub_<name>`). Only contains indicators bound to a secondary axis.
235
+ */
236
+ indicatorAxes: Record<string, string>;
237
+ /** Get the custom `yAxisId` an indicator is bound to, or `undefined` for the default axis. */
238
+ getIndicatorAxis: (name: string, isMain: boolean) => string | undefined;
239
+ /**
240
+ * Rebind an existing indicator to a different Y-axis. Because klinecharts v10
241
+ * `overrideIndicator` cannot change axis binding, this removes and recreates
242
+ * the indicator (preserving calc params, styles and visibility).
243
+ * Pass `yAxis` to bind to a secondary axis, or omit it to return the
244
+ * indicator to the pane's default (shared) axis.
245
+ */
246
+ bindIndicatorToNewAxis: (name: string, isMain: boolean, yAxis?: YAxisOverride) => void;
202
247
  }
203
248
  declare function useIndicators(): UseIndicatorsReturn;
204
249
 
@@ -227,12 +272,16 @@ interface UseDrawingToolsReturn {
227
272
  magnetMode: MagnetMode;
228
273
  isLocked: boolean;
229
274
  isVisible: boolean;
275
+ /** Whether drawing tools auto-retrigger after completing a shape. Default: true. */
276
+ autoRetrigger: boolean;
230
277
  selectTool: (name: string) => void;
231
278
  clearActiveTool: () => void;
232
279
  setMagnetMode: (mode: MagnetMode) => void;
233
280
  toggleLock: () => void;
234
281
  toggleVisibility: () => void;
235
282
  removeAllDrawings: () => void;
283
+ /** Enable/disable auto-retrigger mode. */
284
+ setAutoRetrigger: (enabled: boolean) => void;
236
285
  }
237
286
  declare function useDrawingTools(): UseDrawingToolsReturn;
238
287
 
@@ -406,6 +455,8 @@ interface ChartLayoutState {
406
455
  calcParams: any[];
407
456
  visible: boolean;
408
457
  styles?: any;
458
+ /** Custom Y-axis the indicator is bound to (klinecharts v10 multiple y-axes). */
459
+ yAxisId?: string;
409
460
  }>;
410
461
  drawings: Array<{
411
462
  name: string;
@@ -494,6 +545,182 @@ interface UseScriptEditorReturn {
494
545
  */
495
546
  declare function useScriptEditor(): UseScriptEditorReturn;
496
547
 
548
+ interface CrosshairBarData {
549
+ open: number;
550
+ high: number;
551
+ low: number;
552
+ close: number;
553
+ volume: number;
554
+ timestamp: number;
555
+ change: number;
556
+ changePercent: number;
557
+ }
558
+ interface UseCrosshairReturn {
559
+ /** OHLCV data of the bar under the crosshair. Null when cursor is off-chart. */
560
+ barData: CrosshairBarData | null;
561
+ }
562
+ declare function useCrosshair(): UseCrosshairReturn;
563
+
564
+ type AlertCondition = "crossing_up" | "crossing_down" | "crossing";
565
+ interface Alert {
566
+ id: string;
567
+ price: number;
568
+ condition: AlertCondition;
569
+ message?: string;
570
+ triggered: boolean;
571
+ }
572
+ interface UseAlertsReturn {
573
+ alerts: Alert[];
574
+ addAlert: (price: number, condition: AlertCondition, message?: string) => string;
575
+ removeAlert: (id: string) => void;
576
+ clearAlerts: () => void;
577
+ onAlertTriggered: (callback: (alert: Alert) => void) => void;
578
+ }
579
+ declare function useAlerts(): UseAlertsReturn;
580
+
581
+ type ExportFormat = "csv" | "json";
582
+ interface UseDataExportReturn {
583
+ /** Export all chart data */
584
+ exportAll: (format: ExportFormat) => void;
585
+ /** Export only the visible range */
586
+ exportVisible: (format: ExportFormat) => void;
587
+ }
588
+ declare function useDataExport(): UseDataExportReturn;
589
+
590
+ interface WatchlistItem {
591
+ ticker: string;
592
+ lastPrice: number | null;
593
+ change: number | null;
594
+ changePercent: number | null;
595
+ }
596
+ interface UseWatchlistReturn {
597
+ items: WatchlistItem[];
598
+ addSymbol: (ticker: string) => void;
599
+ removeSymbol: (ticker: string) => void;
600
+ switchSymbol: (ticker: string) => void;
601
+ activeSymbol: string | null;
602
+ }
603
+ declare function useWatchlist(): UseWatchlistReturn;
604
+
605
+ type ReplaySpeed = 1 | 2 | 5 | 10;
606
+ interface UseReplayReturn {
607
+ /** Whether a replay session is active */
608
+ isReplaying: boolean;
609
+ /** Whether the replay is currently paused */
610
+ isPaused: boolean;
611
+ /** Current playback speed multiplier */
612
+ speed: ReplaySpeed;
613
+ /** Current bar index in the replay */
614
+ barIndex: number;
615
+ /** Total number of bars in the saved data */
616
+ totalBars: number;
617
+ /** Start replaying from the beginning */
618
+ startReplay: () => void;
619
+ /** Stop replay and restore original data */
620
+ stopReplay: () => void;
621
+ /** Toggle play/pause */
622
+ togglePause: () => void;
623
+ /** Advance one bar while paused */
624
+ stepForward: () => void;
625
+ /** Go back one bar while paused */
626
+ stepBackward: () => void;
627
+ /** Seek to a specific bar index (0-based). Pauses playback. */
628
+ seekTo: (index: number) => void;
629
+ /** Change the playback speed */
630
+ setSpeed: (speed: ReplaySpeed) => void;
631
+ }
632
+ /**
633
+ * Headless hook for historical data replay (bar-by-bar playback).
634
+ *
635
+ * Loads the current chart data, clears the chart, then progressively adds
636
+ * bars back one at a time at the configured speed. Useful for backtesting
637
+ * and reviewing price action.
638
+ */
639
+ declare function useReplay(): UseReplayReturn;
640
+
641
+ interface CompareSymbol {
642
+ ticker: string;
643
+ /** Base price (first bar close) used for percentage normalization */
644
+ basePrice: number | null;
645
+ color: string;
646
+ visible: boolean;
647
+ }
648
+ interface UseCompareReturn {
649
+ /** Currently compared symbols */
650
+ symbols: CompareSymbol[];
651
+ /** Add a symbol — fetches data, normalizes to %, renders as indicator line */
652
+ addSymbol: (ticker: string, color?: string) => Promise<void>;
653
+ /** Remove a symbol overlay */
654
+ removeSymbol: (ticker: string) => void;
655
+ /** Toggle visibility of a compared symbol */
656
+ toggleSymbol: (ticker: string) => void;
657
+ /** Clear all comparisons */
658
+ clearAll: () => void;
659
+ }
660
+ /**
661
+ * Headless hook for comparing multiple symbols on the same chart.
662
+ *
663
+ * Fetches historical data for each added symbol via the datafeed,
664
+ * normalizes prices to percentage change from the first bar,
665
+ * and renders each as a custom indicator line on the main pane.
666
+ */
667
+ declare function useCompare(): UseCompareReturn;
668
+
669
+ interface MeasurePoint {
670
+ price: number;
671
+ timestamp: number;
672
+ barIndex: number;
673
+ }
674
+ interface MeasureResult {
675
+ from: MeasurePoint;
676
+ to: MeasurePoint;
677
+ /** Absolute price difference */
678
+ priceDiff: number;
679
+ /** Percentage change from → to */
680
+ pricePercent: number;
681
+ /** Number of bars between the two points */
682
+ bars: number;
683
+ /** Time difference in milliseconds */
684
+ timeDiff: number;
685
+ }
686
+ interface UseMeasureReturn {
687
+ /** Whether measure mode is active (waiting for clicks) */
688
+ isActive: boolean;
689
+ /** Start measure mode — next two clicks on chart set from/to */
690
+ startMeasure: () => void;
691
+ /** Cancel measure mode */
692
+ cancelMeasure: () => void;
693
+ /** Current measurement result (null until both points are set) */
694
+ result: MeasureResult | null;
695
+ /** Clear the current measurement */
696
+ clearResult: () => void;
697
+ /** First point (set after first click) */
698
+ fromPoint: MeasurePoint | null;
699
+ }
700
+ /**
701
+ * Headless hook for measuring distance/time/percentage between two points.
702
+ *
703
+ * Activates measure mode, captures two clicks on the chart via overlay
704
+ * interaction, then computes price diff, %, bar count, and time diff.
705
+ */
706
+ declare function useMeasure(): UseMeasureReturn;
707
+
708
+ interface Annotation {
709
+ id: string;
710
+ text: string;
711
+ price: number;
712
+ timestamp: number;
713
+ color?: string;
714
+ }
715
+ interface UseAnnotationsReturn {
716
+ annotations: Annotation[];
717
+ addAnnotation: (text: string, price: number, timestamp: number, color?: string) => string;
718
+ removeAnnotation: (id: string) => void;
719
+ updateAnnotation: (id: string, updates: Partial<Pick<Annotation, "text" | "color">>) => void;
720
+ clearAnnotations: () => void;
721
+ }
722
+ declare function useAnnotations(): UseAnnotationsReturn;
723
+
497
724
  interface TimezoneOption {
498
725
  key: string;
499
726
  localeKey: string;
@@ -673,4 +900,4 @@ declare const superTrend: IndicatorTemplate;
673
900
 
674
901
  declare const vwap: IndicatorTemplate;
675
902
 
676
- export { CANDLE_TYPES, COMPARE_RULES, type CandleTypeItem, type CandleTypeOption, type ChartLayoutState, type CompareRule, DEFAULT_PERIODS, DRAWING_CATEGORIES, type Datafeed, type DrawingCategoryItem, type DrawingTool, type DrawingToolCategory, type DrawingToolItem, INDICATOR_PARAMS, type IndicatorDefinition, type IndicatorInfo, type IndicatorParamConfig, type KlinechartsUIAction, type KlinechartsUIContextValue, KlinechartsUIDispatchContext, type KlinechartsUIDispatchValue, type KlinechartsUIOptions, KlinechartsUIProvider, type KlinechartsUISettingsState, type KlinechartsUIState, KlinechartsUIStateContext, type LayoutEntry, MAIN_INDICATORS, type MagnetMode, OrderLineExtendData, type OrderLineOptions, PRICE_AXIS_TYPES, type PartialSymbolInfo, type PriceAxisType, SUB_INDICATORS, type ScriptPlacement, TA, TIMEZONES, TOOLTIP_SHOW_RULES, type TerminalPeriod, type TimezoneItem, type TimezoneOption, type TooltipShowRule, type UndoRedoAction, type UndoRedoActionType, type UseDrawingToolsReturn, type UseFullscreenReturn, type UseIndicatorsReturn, type UseKlinechartsUILoadingReturn, type UseKlinechartsUISettingsReturn, type UseKlinechartsUIThemeReturn, type UseLayoutManagerReturn, type UseOrderLinesReturn, type UsePeriodsReturn, type UseScreenshotReturn, type UseScriptEditorReturn, type UseSymbolSearchReturn, type UseTimezoneReturn, type UseUndoRedoReturn, YAXIS_POSITIONS, type YAxisPosition, abcd, anyWaves, arrow, bollTv, brush, cci, circle, createDataLoader, eightWaves, elliottWave, fibRetracement, fibonacciCircle, fibonacciExtension, fibonacciSegment, fibonacciSpeedResistanceFan, fibonacciSpiral, fiveWaves, gannBox, gannFan, hma, ichimoku, longPosition, maRibbon, macdTv, measure, parallelChannel, parallelogram, pivotPoints, ray, rect, rsiTv, shortPosition, stochastic, superTrend, threeWaves, triangle, useDrawingTools, useFullscreen, useIndicators, useKlinechartsUI, useKlinechartsUILoading, useKlinechartsUISettings, useKlinechartsUITheme, useLayoutManager, useOrderLines, usePeriods, useScreenshot, useScriptEditor, useSymbolSearch, useTimezone, useUndoRedo, vwap, xabcd };
903
+ export { type AddIndicatorOptions, type Alert, type AlertCondition, type Annotation, CANDLE_TYPES, COMPARE_RULES, type CandleTypeItem, type CandleTypeOption, type ChartLayoutState, type CompareRule, type CompareSymbol, type CrosshairBarData, DEFAULT_PERIODS, DRAWING_CATEGORIES, type Datafeed, type DrawingCategoryItem, type DrawingTool, type DrawingToolCategory, type DrawingToolItem, type ExportFormat, INDICATOR_PARAMS, type IndicatorDefinition, type IndicatorInfo, type IndicatorParamConfig, type KlinechartsUIAction, type KlinechartsUIContextValue, KlinechartsUIDispatchContext, type KlinechartsUIDispatchValue, type KlinechartsUIOptions, KlinechartsUIProvider, type KlinechartsUISettingsState, type KlinechartsUIState, KlinechartsUIStateContext, type LayoutEntry, MAIN_INDICATORS, type MagnetMode, type MeasurePoint, type MeasureResult, OrderLineExtendData, type OrderLineOptions, PRICE_AXIS_TYPES, type PartialSymbolInfo, type PriceAxisType, type ReplaySpeed, SUB_INDICATORS, type ScriptPlacement, TA, TIMEZONES, TOOLTIP_SHOW_RULES, type TerminalPeriod, type TimezoneItem, type TimezoneOption, type TooltipShowRule, type UndoRedoAction, type UndoRedoActionType, type UseAlertsReturn, type UseAnnotationsReturn, type UseCompareReturn, type UseCrosshairReturn, type UseDataExportReturn, type UseDrawingToolsReturn, type UseFullscreenReturn, type UseIndicatorsReturn, type UseKlinechartsUILoadingReturn, type UseKlinechartsUISettingsReturn, type UseKlinechartsUIThemeReturn, type UseLayoutManagerReturn, type UseMeasureReturn, type UseOrderLinesReturn, type UsePeriodsReturn, type UseReplayReturn, type UseScreenshotReturn, type UseScriptEditorReturn, type UseSymbolSearchReturn, type UseTimezoneReturn, type UseUndoRedoReturn, type UseWatchlistReturn, type WatchlistItem, YAXIS_POSITIONS, type YAxisPosition, abcd, anyWaves, arrow, bollTv, brush, cci, circle, createDataLoader, eightWaves, elliottWave, fibRetracement, fibonacciCircle, fibonacciExtension, fibonacciSegment, fibonacciSpeedResistanceFan, fibonacciSpiral, fiveWaves, gannBox, gannFan, hma, ichimoku, longPosition, maRibbon, macdTv, measure, parallelChannel, parallelogram, pivotPoints, ray, rect, rsiTv, shortPosition, stochastic, superTrend, threeWaves, triangle, useAlerts, useAnnotations, useCompare, useCrosshair, useDataExport, useDrawingTools, useFullscreen, useIndicators, useKlinechartsUI, useKlinechartsUILoading, useKlinechartsUISettings, useKlinechartsUITheme, useLayoutManager, useMeasure, useOrderLines, usePeriods, useReplay, useScreenshot, useScriptEditor, useSymbolSearch, useTimezone, useUndoRedo, useWatchlist, vwap, xabcd };