react-klinecharts-ui 0.3.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,6 +1,6 @@
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
5
  export { DepthOverlayExtendData, DepthOverlayRow, OrderLineFontStyle, OrderLineLabelStyle, OrderLineLineStyle, OrderLineMarkStyle, OrderLinePadding, depthOverlay, indicators, orderLine, overlays, registerExtensions } from './extensions.cjs';
6
6
 
@@ -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;
@@ -207,6 +229,21 @@ interface UseIndicatorsReturn {
207
229
  isSubIndicatorCollapsed: (name: string) => boolean;
208
230
  /** Reorder a sub-indicator pane up or down relative to other sub-indicators. */
209
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;
210
247
  }
211
248
  declare function useIndicators(): UseIndicatorsReturn;
212
249
 
@@ -418,6 +455,8 @@ interface ChartLayoutState {
418
455
  calcParams: any[];
419
456
  visible: boolean;
420
457
  styles?: any;
458
+ /** Custom Y-axis the indicator is bound to (klinecharts v10 multiple y-axes). */
459
+ yAxisId?: string;
421
460
  }>;
422
461
  drawings: Array<{
423
462
  name: string;
@@ -861,4 +900,4 @@ declare const superTrend: IndicatorTemplate;
861
900
 
862
901
  declare const vwap: IndicatorTemplate;
863
902
 
864
- export { 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 };
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,6 +1,6 @@
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
5
  export { DepthOverlayExtendData, DepthOverlayRow, OrderLineFontStyle, OrderLineLabelStyle, OrderLineLineStyle, OrderLineMarkStyle, OrderLinePadding, depthOverlay, indicators, orderLine, overlays, registerExtensions } from './extensions.js';
6
6
 
@@ -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;
@@ -207,6 +229,21 @@ interface UseIndicatorsReturn {
207
229
  isSubIndicatorCollapsed: (name: string) => boolean;
208
230
  /** Reorder a sub-indicator pane up or down relative to other sub-indicators. */
209
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;
210
247
  }
211
248
  declare function useIndicators(): UseIndicatorsReturn;
212
249
 
@@ -418,6 +455,8 @@ interface ChartLayoutState {
418
455
  calcParams: any[];
419
456
  visible: boolean;
420
457
  styles?: any;
458
+ /** Custom Y-axis the indicator is bound to (klinecharts v10 multiple y-axes). */
459
+ yAxisId?: string;
421
460
  }>;
422
461
  drawings: Array<{
423
462
  name: string;
@@ -861,4 +900,4 @@ declare const superTrend: IndicatorTemplate;
861
900
 
862
901
  declare const vwap: IndicatorTemplate;
863
902
 
864
- export { 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 };
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 };