@quantlife/qlchart 0.0.1
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/.idea/QLChart.iml +12 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/README.md +75 -0
- package/demo/App.css +213 -0
- package/demo/App.tsx +46 -0
- package/demo/components/ControlPanel.tsx +13 -0
- package/demo/components/DemoNav.tsx +27 -0
- package/demo/index.html +16 -0
- package/demo/main.tsx +10 -0
- package/demo/pages/BasicChartDemo.tsx +61 -0
- package/demo/pages/DrawingDemo.tsx +22 -0
- package/demo/pages/IndicatorDemo.tsx +22 -0
- package/demo/pages/LayoutDemo.tsx +35 -0
- package/demo/pages/MultiPeriodDemo.tsx +31 -0
- package/demo/pages/ReplayDemo.tsx +195 -0
- package/demo/pages/SaveDemo.tsx +27 -0
- package/demo/pages/ThemeDemo.tsx +29 -0
- package/demo/standalone-demo.html +597 -0
- package/demo/vite.config.demo.ts +17 -0
- package/dist/index.d.ts +1973 -0
- package/dist/qlchart.js +23169 -0
- package/dist/style.css +1 -0
- package/doc/api/indicator-data-processor.md +35 -0
- package/doc/api-reference/.nojekyll +1 -0
- package/doc/api-reference/assets/hierarchy.js +1 -0
- package/doc/api-reference/assets/highlight.css +43 -0
- package/doc/api-reference/assets/icons.js +18 -0
- package/doc/api-reference/assets/icons.svg +1 -0
- package/doc/api-reference/assets/main.js +60 -0
- package/doc/api-reference/assets/navigation.js +1 -0
- package/doc/api-reference/assets/search.js +1 -0
- package/doc/api-reference/assets/style.css +1611 -0
- package/doc/api-reference/classes/ChartManager.html +16 -0
- package/doc/api-reference/classes/DataManager.html +13 -0
- package/doc/api-reference/classes/DrawingAdapter.html +64 -0
- package/doc/api-reference/classes/DrawingPersistence.html +21 -0
- package/doc/api-reference/classes/EventManager.html +12 -0
- package/doc/api-reference/classes/HollowCandlestickSeries.html +22 -0
- package/doc/api-reference/classes/IndicatorRenderer.html +20 -0
- package/doc/api-reference/classes/KlineReplay.html +31 -0
- package/doc/api-reference/classes/MockDataService.html +13 -0
- package/doc/api-reference/classes/MockIndicatorService.html +4 -0
- package/doc/api-reference/classes/OverlayIndicator.html +11 -0
- package/doc/api-reference/classes/PaneIndicator.html +16 -0
- package/doc/api-reference/classes/PaneManager.html +24 -0
- package/doc/api-reference/classes/RealtimeDataFeed.html +22 -0
- package/doc/api-reference/classes/RenkoSeries.html +22 -0
- package/doc/api-reference/classes/ScreenshotUtil.html +10 -0
- package/doc/api-reference/classes/SeriesManager.html +30 -0
- package/doc/api-reference/classes/ThemeManager.html +18 -0
- package/doc/api-reference/enums/ChartEvent.html +12 -0
- package/doc/api-reference/enums/IndicatorType.html +4 -0
- package/doc/api-reference/enums/SeriesType.html +13 -0
- package/doc/api-reference/functions/ChartFunctionMenu.html +1 -0
- package/doc/api-reference/functions/DrawingModule.html +8 -0
- package/doc/api-reference/functions/IndicatorPanel.html +2 -0
- package/doc/api-reference/functions/IndicatorTag.html +2 -0
- package/doc/api-reference/functions/KlineTypeSelector.html +1 -0
- package/doc/api-reference/functions/LayoutSwitcher.html +1 -0
- package/doc/api-reference/functions/PeriodSelector.html +1 -0
- package/doc/api-reference/functions/QLChartLayout.html +1 -0
- package/doc/api-reference/functions/QLChartPanel.html +10 -0
- package/doc/api-reference/functions/QLChartProvider.html +2 -0
- package/doc/api-reference/functions/QLToolbar.html +1 -0
- package/doc/api-reference/functions/ReplayController.html +1 -0
- package/doc/api-reference/functions/TimeBarModule.html +4 -0
- package/doc/api-reference/functions/TimeRangeSelector.html +1 -0
- package/doc/api-reference/functions/createIndicatorConfig.html +2 -0
- package/doc/api-reference/functions/getToolConfig.html +2 -0
- package/doc/api-reference/functions/getToolsByCategory.html +2 -0
- package/doc/api-reference/functions/getToolsByPriority.html +2 -0
- package/doc/api-reference/functions/mapLibTypeToOurs.html +2 -0
- package/doc/api-reference/functions/mapToolTypeToLib.html +3 -0
- package/doc/api-reference/functions/transformCandlestickData.html +3 -0
- package/doc/api-reference/functions/transformIndicatorData.html +2 -0
- package/doc/api-reference/functions/transformVolumeData.html +3 -0
- package/doc/api-reference/functions/useChart.html +4 -0
- package/doc/api-reference/functions/useChartStore.html +8 -0
- package/doc/api-reference/functions/useCrosshairSync.html +8 -0
- package/doc/api-reference/functions/useDrawingModule.html +1 -0
- package/doc/api-reference/functions/useDrawingStore.html +8 -0
- package/doc/api-reference/functions/useIndicatorStore.html +8 -0
- package/doc/api-reference/functions/useQLChartConfig.html +2 -0
- package/doc/api-reference/functions/useReplayStore.html +8 -0
- package/doc/api-reference/functions/useTheme.html +2 -0
- package/doc/api-reference/functions/useTimeBarStore.html +8 -0
- package/doc/api-reference/index.html +1 -0
- package/doc/api-reference/interfaces/CandlestickData.html +7 -0
- package/doc/api-reference/interfaces/CandlestickRawData.html +8 -0
- package/doc/api-reference/interfaces/ChartFunctionMenuProps.html +2 -0
- package/doc/api-reference/interfaces/ChartManagerCreateOptions.html +4 -0
- package/doc/api-reference/interfaces/ChartOptions.html +8 -0
- package/doc/api-reference/interfaces/ChartRequestParams.html +8 -0
- package/doc/api-reference/interfaces/ChartResponse.html +5 -0
- package/doc/api-reference/interfaces/ChartState.html +24 -0
- package/doc/api-reference/interfaces/ChartThemeOptions.html +5 -0
- package/doc/api-reference/interfaces/CrosshairData.html +5 -0
- package/doc/api-reference/interfaces/DrawingModuleProps.html +5 -0
- package/doc/api-reference/interfaces/DrawingState.html +48 -0
- package/doc/api-reference/interfaces/HistogramData.html +5 -0
- package/doc/api-reference/interfaces/HollowCandlestickData.html +14 -0
- package/doc/api-reference/interfaces/IndicatorConfig.html +11 -0
- package/doc/api-reference/interfaces/IndicatorDataPoint.html +4 -0
- package/doc/api-reference/interfaces/IndicatorDataResponse.html +5 -0
- package/doc/api-reference/interfaces/IndicatorDefinition.html +9 -0
- package/doc/api-reference/interfaces/IndicatorPanelProps.html +3 -0
- package/doc/api-reference/interfaces/IndicatorParamDef.html +8 -0
- package/doc/api-reference/interfaces/IndicatorRawData.html +4 -0
- package/doc/api-reference/interfaces/IndicatorState.html +19 -0
- package/doc/api-reference/interfaces/IndicatorTagProps.html +2 -0
- package/doc/api-reference/interfaces/KlineReplayOptions.html +4 -0
- package/doc/api-reference/interfaces/LayoutSwitcherProps.html +3 -0
- package/doc/api-reference/interfaces/LineData.html +4 -0
- package/doc/api-reference/interfaces/MockDataConfig.html +8 -0
- package/doc/api-reference/interfaces/MockIndicatorConfig.html +5 -0
- package/doc/api-reference/interfaces/PairInfo.html +6 -0
- package/doc/api-reference/interfaces/PaneInfo.html +6 -0
- package/doc/api-reference/interfaces/PanelConfig.html +9 -0
- package/doc/api-reference/interfaces/PersistenceConfig.html +12 -0
- package/doc/api-reference/interfaces/QLChartConfig.html +18 -0
- package/doc/api-reference/interfaces/QLChartLayoutProps.html +9 -0
- package/doc/api-reference/interfaces/QLChartPanelProps.html +13 -0
- package/doc/api-reference/interfaces/QLChartPanelRef.html +14 -0
- package/doc/api-reference/interfaces/QLToolbarProps.html +7 -0
- package/doc/api-reference/interfaces/RealtimeCandle.html +9 -0
- package/doc/api-reference/interfaces/RealtimeSubscribeFn.html +2 -0
- package/doc/api-reference/interfaces/RenkoData.html +16 -0
- package/doc/api-reference/interfaces/ReplayControllerProps.html +2 -0
- package/doc/api-reference/interfaces/ReplayState.html +19 -0
- package/doc/api-reference/interfaces/ThemeConfig.html +14 -0
- package/doc/api-reference/interfaces/TimeBarModuleProps.html +5 -0
- package/doc/api-reference/interfaces/TimeBarState.html +13 -0
- package/doc/api-reference/interfaces/UseChartReturn.html +4 -0
- package/doc/api-reference/interfaces/UseDrawingModuleOptions.html +11 -0
- package/doc/api-reference/interfaces/UseDrawingModuleReturn.html +6 -0
- package/doc/api-reference/interfaces/UseThemeReturn.html +5 -0
- package/doc/api-reference/types/EventHandler.html +2 -0
- package/doc/api-reference/types/FetchFn.html +2 -0
- package/doc/api-reference/types/LayoutMode.html +2 -0
- package/doc/api-reference/types/MarketTrend.html +2 -0
- package/doc/api-reference/types/ThemePreset.html +2 -0
- package/doc/api-reference/variables/BUILTIN_INDICATORS.html +2 -0
- package/doc/api-reference/variables/CATEGORY_LABELS.html +2 -0
- package/doc/api-reference/variables/DRAWING_TOOLS.html +3 -0
- package/doc/api-reference/variables/MARKET_PRESETS.html +1 -0
- package/doc/api-reference/variables/PAIR_PRESETS.html +1 -0
- package/doc/api-reference/variables/darkPreset.html +1 -0
- package/doc/api-reference/variables/lightPreset.html +1 -0
- package/doc/components/drawing-module.md +24 -0
- package/doc/components/indicator-list-panel.md +24 -0
- package/doc/components/indicator-panel.md +17 -0
- package/doc/components/pane-divider.md +25 -0
- package/doc/components/qlchart-layout.md +30 -0
- package/doc/components/qlchart-panel.md +93 -0
- package/doc/components/qlchart-provider.md +73 -0
- package/doc/components/qltoolbar.md +17 -0
- package/doc/components/replay-controller.md +23 -0
- package/doc/components/timebar-module.md +13 -0
- package/doc/core/chart-manager.md +14 -0
- package/doc/core/data-manager.md +33 -0
- package/doc/core/event-manager.md +26 -0
- package/doc/core/pane-manager.md +13 -0
- package/doc/core/series-manager.md +19 -0
- package/doc/core/theme-manager.md +21 -0
- package/doc/examples/basic-chart.md +24 -0
- package/doc/examples/data-format-guide.md +119 -0
- package/doc/examples/drawing-tools.md +30 -0
- package/doc/examples/indicator-properties.md +34 -0
- package/doc/examples/multi-pane.md +24 -0
- package/doc/examples/multi-panel.md +23 -0
- package/doc/examples/realtime-data.md +147 -0
- package/doc/examples/standalone-js.md +333 -0
- package/doc/guide/architecture.md +87 -0
- package/doc/guide/data-flow.md +310 -0
- package/doc/guide/deployment.md +59 -0
- package/doc/guide/drawing-properties.md +40 -0
- package/doc/guide/getting-started.md +94 -0
- package/doc/guide/pane-system.md +47 -0
- package/doc/guide/theme-switching.md +58 -0
- package/doc/hooks/use-chart.md +20 -0
- package/doc/hooks/use-crosshair-sync.md +14 -0
- package/doc/hooks/use-drawing-module.md +43 -0
- package/doc/hooks/use-theme.md +15 -0
- package/doc/index.md +33 -0
- package/doc/plugins/drawing/overview.md +36 -0
- package/doc/plugins/drawing/persistence.md +42 -0
- package/doc/plugins/drawing/tool-registry.md +29 -0
- package/doc/plugins/hollow-candlestick.md +18 -0
- package/doc/plugins/indicators.md +28 -0
- package/doc/plugins/renko.md +17 -0
- package/doc/plugins/replay.md +21 -0
- package/doc/plugins/screenshot.md +20 -0
- package/docs/api.md +94 -0
- package/package.json +54 -0
- package/python/qlchart/__init__.py +9 -0
- package/python/qlchart/__pycache__/__init__.cpython-311.pyc +0 -0
- package/python/qlchart/__pycache__/chart.cpython-311.pyc +0 -0
- package/python/qlchart/chart.py +333 -0
- package/python/qlchart/templates/chart_template.html +304 -0
- package/python/requirements.txt +1 -0
- package/python/setup.py +18 -0
- package/python/tests/__init__.py +1 -0
- package/python/tests/__pycache__/__init__.cpython-311.pyc +0 -0
- package/python/tests/__pycache__/test_chart.cpython-311-pytest-8.3.3.pyc +0 -0
- package/python/tests/test_chart.py +114 -0
- package/quantlife-qlchart-0.0.1.tgz +0 -0
- package/src/api/chartApi.ts +30 -0
- package/src/api/indicatorApi.ts +27 -0
- package/src/components/ChartFunctionMenu.tsx +64 -0
- package/src/components/PaneChartPanel.tsx +116 -0
- package/src/components/PaneDivider.tsx +66 -0
- package/src/components/QLChartLayout.tsx +151 -0
- package/src/components/QLChartPanel.tsx +560 -0
- package/src/components/QLChartProvider.tsx +90 -0
- package/src/components/context-menu/ChartContextMenu.tsx +139 -0
- package/src/components/context-menu/index.ts +2 -0
- package/src/components/drawing/DrawingModule.tsx +36 -0
- package/src/components/drawing/DrawingPropertyPanel.tsx +347 -0
- package/src/components/drawing/DrawingToolbar.tsx +305 -0
- package/src/components/drawing/index.ts +5 -0
- package/src/components/index.ts +43 -0
- package/src/components/indicator/IndicatorListPanel.tsx +94 -0
- package/src/components/indicator/IndicatorModal.tsx +171 -0
- package/src/components/indicator/IndicatorPanel.tsx +9 -0
- package/src/components/indicator/IndicatorPropertyPanel.tsx +130 -0
- package/src/components/indicator/IndicatorTag.tsx +173 -0
- package/src/components/indicator/index.ts +4 -0
- package/src/components/replay/ReplayController.css +97 -0
- package/src/components/replay/ReplayController.tsx +138 -0
- package/src/components/timebar/TimeBarModule.tsx +30 -0
- package/src/components/timebar/TimeRangeSelector.tsx +96 -0
- package/src/components/timebar/index.ts +3 -0
- package/src/components/toolbar/GlobalToolbar.tsx +58 -0
- package/src/components/toolbar/KlineTypeSelector.tsx +123 -0
- package/src/components/toolbar/LayoutSwitcher.tsx +45 -0
- package/src/components/toolbar/PeriodSelector.tsx +35 -0
- package/src/components/toolbar/QLToolbar.tsx +71 -0
- package/src/components/toolbar/TimeRangeSelector.tsx +89 -0
- package/src/components/ui/Modal.tsx +67 -0
- package/src/core/ChartManager.ts +95 -0
- package/src/core/DataManager.ts +427 -0
- package/src/core/EventManager.ts +63 -0
- package/src/core/IndicatorDataProcessor.ts +104 -0
- package/src/core/PaneManager.ts +121 -0
- package/src/core/RealtimeDataFeed.ts +110 -0
- package/src/core/SeriesManager.ts +210 -0
- package/src/core/ThemeManager.ts +59 -0
- package/src/core/index.ts +10 -0
- package/src/css.d.ts +4 -0
- package/src/hooks/useChart.ts +62 -0
- package/src/hooks/useCrosshairSync.ts +109 -0
- package/src/hooks/useDrawingModule.ts +475 -0
- package/src/hooks/useTheme.ts +31 -0
- package/src/index.ts +170 -0
- package/src/mock/MockDataService.ts +102 -0
- package/src/mock/MockIndicatorService.ts +40 -0
- package/src/mock/index.ts +5 -0
- package/src/mock/presets.ts +16 -0
- package/src/plugins/drawing/DrawingAdapter.ts +1762 -0
- package/src/plugins/drawing/DrawingPersistence.ts +273 -0
- package/src/plugins/drawing/DrawingPropertyTemplates.ts +327 -0
- package/src/plugins/drawing/DrawingSharedService.ts +125 -0
- package/src/plugins/drawing/DrawingToolRegistry.ts +684 -0
- package/src/plugins/drawing/TextLabelOverlay.ts +101 -0
- package/src/plugins/drawing/colorUtils.ts +53 -0
- package/src/plugins/drawing/index.ts +10 -0
- package/src/plugins/drawing/lineStyleMap.ts +46 -0
- package/src/plugins/drawing/migration.ts +105 -0
- package/src/plugins/drawing/patterns/PatternDefinitions.ts +57 -0
- package/src/plugins/drawing/patterns/index.ts +2 -0
- package/src/plugins/drawing/periodUtils.ts +51 -0
- package/src/plugins/indicators/AutoIndicatorRenderer.ts +204 -0
- package/src/plugins/indicators/IndicatorRenderer.ts +350 -0
- package/src/plugins/indicators/OverlayIndicator.ts +114 -0
- package/src/plugins/indicators/PaneIndicator.ts +137 -0
- package/src/plugins/indicators/index.ts +4 -0
- package/src/plugins/replay/KlineReplay.ts +163 -0
- package/src/plugins/replay/index.ts +2 -0
- package/src/plugins/screenshot/ScreenshotUtil.ts +123 -0
- package/src/plugins/screenshot/index.ts +1 -0
- package/src/plugins/series/HollowCandlestickSeries.ts +111 -0
- package/src/plugins/series/RenkoSeries.ts +104 -0
- package/src/plugins/series/VolumeCandlestickSeries.ts +127 -0
- package/src/plugins/series/index.ts +6 -0
- package/src/standalone.ts +386 -0
- package/src/store/useChartStore.ts +101 -0
- package/src/store/useDrawingStore.ts +135 -0
- package/src/store/useIndicatorStore.ts +100 -0
- package/src/store/usePanelRegistry.ts +50 -0
- package/src/store/useReplayStore.ts +42 -0
- package/src/store/useTimeBarStore.ts +34 -0
- package/src/styles/chart.css +312 -0
- package/src/styles/components.css +184 -0
- package/src/styles/context-menu.css +60 -0
- package/src/styles/drawing.css +524 -0
- package/src/styles/indicator-modal.css +216 -0
- package/src/styles/indicator-tag.css +210 -0
- package/src/styles/pane-chart.css +9 -0
- package/src/styles/responsive.css +71 -0
- package/src/styles/themes/dark.css +63 -0
- package/src/styles/themes/light.css +61 -0
- package/src/styles/toolbar.css +129 -0
- package/src/types/api.ts +36 -0
- package/src/types/chart.ts +44 -0
- package/src/types/drawing.ts +265 -0
- package/src/types/index.ts +40 -0
- package/src/types/indicator.ts +344 -0
- package/src/types/series.ts +53 -0
- package/src/types/theme.ts +48 -0
- package/src/utils/dataTransformer.ts +63 -0
- package/src/utils/heikinAshi.ts +41 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/lineBreak.ts +88 -0
- package/src/utils/themePresets.ts +69 -0
- package/src/utils/timeFormatter.ts +29 -0
- package/src/utils/timeScaleUtils.ts +68 -0
- package/tsconfig.json +21 -0
- package/typedoc.json +10 -0
- package/vite.config.standalone.ts +31 -0
- package/vite.config.ts +24 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1973 @@
|
|
|
1
|
+
import { CandlestickData as CandlestickData_2 } from 'lightweight-charts';
|
|
2
|
+
import { ChartOptions as ChartOptions_2 } from 'lightweight-charts';
|
|
3
|
+
import { CustomData } from 'lightweight-charts';
|
|
4
|
+
import { CustomSeriesOptions } from 'lightweight-charts';
|
|
5
|
+
import { CustomSeriesPricePlotValues } from 'lightweight-charts';
|
|
6
|
+
import { CustomSeriesWhitespaceData } from 'lightweight-charts';
|
|
7
|
+
import { DeepPartial } from 'lightweight-charts';
|
|
8
|
+
import { ForwardRefExoticComponent } from 'react';
|
|
9
|
+
import { IChartApi } from 'lightweight-charts';
|
|
10
|
+
import { ICustomSeriesPaneRenderer } from 'lightweight-charts';
|
|
11
|
+
import { ICustomSeriesPaneView } from 'lightweight-charts';
|
|
12
|
+
import { IDrawing } from 'lightweight-charts-drawing';
|
|
13
|
+
import { ISeriesApi } from 'lightweight-charts';
|
|
14
|
+
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
15
|
+
import { PaneRendererCustomData } from 'lightweight-charts';
|
|
16
|
+
import { ReactNode } from 'react';
|
|
17
|
+
import { RefAttributes } from 'react';
|
|
18
|
+
import { RefObject } from 'react';
|
|
19
|
+
import { SeriesType as SeriesType_2 } from 'lightweight-charts';
|
|
20
|
+
import { StoreApi } from 'zustand';
|
|
21
|
+
import { Time } from 'lightweight-charts';
|
|
22
|
+
import { UseBoundStore } from 'zustand';
|
|
23
|
+
import { UTCTimestamp } from 'lightweight-charts';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 用户激活的指标配置
|
|
27
|
+
*/
|
|
28
|
+
declare interface ActiveIndicatorConfig {
|
|
29
|
+
/** 对应IndicatorTemplate.key */
|
|
30
|
+
key: string;
|
|
31
|
+
/** 用户自定义参数(覆盖defaultParams) */
|
|
32
|
+
params: Record<string, number>;
|
|
33
|
+
/** 是否可见 */
|
|
34
|
+
visible: boolean;
|
|
35
|
+
/** 用户自定义样式(覆盖lines中的默认颜色) */
|
|
36
|
+
styleOverrides?: Record<string, string>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** 内置指标定义 */
|
|
40
|
+
export declare const BUILTIN_INDICATORS: IndicatorDefinition[];
|
|
41
|
+
|
|
42
|
+
/** LWC K线数据 */
|
|
43
|
+
export declare interface CandlestickData {
|
|
44
|
+
time: number;
|
|
45
|
+
open: number;
|
|
46
|
+
high: number;
|
|
47
|
+
low: number;
|
|
48
|
+
close: number;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** K线数据(API返回的原始格式) */
|
|
52
|
+
export declare interface CandlestickRawData {
|
|
53
|
+
time: number;
|
|
54
|
+
open: number;
|
|
55
|
+
high: number;
|
|
56
|
+
low: number;
|
|
57
|
+
close: number;
|
|
58
|
+
volume?: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** 分类中文标签 */
|
|
62
|
+
export declare const CATEGORY_LABELS: Record<DrawingToolCategory, string>;
|
|
63
|
+
|
|
64
|
+
/** 图表事件枚举 */
|
|
65
|
+
export declare enum ChartEvent {
|
|
66
|
+
ChartCreated = "chart:created",
|
|
67
|
+
ChartDisposed = "chart:disposed",
|
|
68
|
+
DataLoaded = "data:loaded",
|
|
69
|
+
PeriodChanged = "period:changed",
|
|
70
|
+
CrosshairMove = "crosshair:move",
|
|
71
|
+
SeriesAdded = "series:added",
|
|
72
|
+
SeriesRemoved = "series:removed",
|
|
73
|
+
ThemeChanged = "theme:changed",
|
|
74
|
+
LayoutChanged = "layout:changed",
|
|
75
|
+
Error = "error"
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export declare function ChartFunctionMenu({ chart }: ChartFunctionMenuProps): JSX_2.Element;
|
|
79
|
+
|
|
80
|
+
export declare interface ChartFunctionMenuProps {
|
|
81
|
+
chart: IChartApi | null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 图表管理器
|
|
86
|
+
* 封装 LWC IChartApi 的生命周期
|
|
87
|
+
*/
|
|
88
|
+
export declare class ChartManager {
|
|
89
|
+
private chart;
|
|
90
|
+
private eventManager;
|
|
91
|
+
private container;
|
|
92
|
+
constructor(eventManager: EventManager);
|
|
93
|
+
/** 创建图表实例 */
|
|
94
|
+
create(container: HTMLElement, options?: ChartManagerCreateOptions): IChartApi;
|
|
95
|
+
/** 销毁图表实例 */
|
|
96
|
+
dispose(): void;
|
|
97
|
+
/** 更新图表选项 */
|
|
98
|
+
updateOptions(options: DeepPartial<ChartOptions_2>): void;
|
|
99
|
+
/** 获取图表实例 */
|
|
100
|
+
getChart(): IChartApi | null;
|
|
101
|
+
/** 调整图表大小 */
|
|
102
|
+
resize(width: number, height: number): void;
|
|
103
|
+
/** 截图 */
|
|
104
|
+
screenshot(): string | null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export declare interface ChartManagerCreateOptions {
|
|
108
|
+
width?: number;
|
|
109
|
+
height?: number;
|
|
110
|
+
theme?: DeepPartial<ChartOptions_2>;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** 图表选项 */
|
|
114
|
+
export declare interface ChartOptions {
|
|
115
|
+
width?: number;
|
|
116
|
+
height?: number;
|
|
117
|
+
layout?: {
|
|
118
|
+
background?: string;
|
|
119
|
+
textColor?: string;
|
|
120
|
+
};
|
|
121
|
+
grid?: {
|
|
122
|
+
vertLines?: {
|
|
123
|
+
color?: string;
|
|
124
|
+
};
|
|
125
|
+
horzLines?: {
|
|
126
|
+
color?: string;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
crosshair?: {
|
|
130
|
+
mode?: 'normal' | 'magnet';
|
|
131
|
+
};
|
|
132
|
+
timeScale?: {
|
|
133
|
+
timeVisible?: boolean;
|
|
134
|
+
secondsVisible?: boolean;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** 图表数据请求参数 */
|
|
139
|
+
export declare interface ChartRequestParams {
|
|
140
|
+
pairId: string;
|
|
141
|
+
product: string;
|
|
142
|
+
period: string;
|
|
143
|
+
startTime?: number;
|
|
144
|
+
endTime?: number;
|
|
145
|
+
limit?: number;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** 图表API响应 */
|
|
149
|
+
export declare interface ChartResponse<T = unknown> {
|
|
150
|
+
code: number;
|
|
151
|
+
data: T;
|
|
152
|
+
msg?: string;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export declare interface ChartState {
|
|
156
|
+
activePairId: string | null;
|
|
157
|
+
activeProduct: string | null;
|
|
158
|
+
activePeriod: string;
|
|
159
|
+
activeSeriesType: SeriesType;
|
|
160
|
+
activeTheme: 'dark' | 'light';
|
|
161
|
+
layoutMode: LayoutMode;
|
|
162
|
+
panels: PanelConfig[];
|
|
163
|
+
/** 当前活跃面板 ID(全局工具栏操作的目标) */
|
|
164
|
+
activePanelId: string | null;
|
|
165
|
+
/** 每个面板的独立周期状态:panelId → period */
|
|
166
|
+
panelPeriods: Record<string, string>;
|
|
167
|
+
setPair: (pairId: string, product: string) => void;
|
|
168
|
+
setPeriod: (period: string) => void;
|
|
169
|
+
setSeriesType: (type: SeriesType) => void;
|
|
170
|
+
setTheme: (theme: 'dark' | 'light') => void;
|
|
171
|
+
setLayoutMode: (mode: LayoutMode) => void;
|
|
172
|
+
updatePanel: (index: number, config: Partial<PanelConfig>) => void;
|
|
173
|
+
/** 设置活跃面板 */
|
|
174
|
+
setActivePanel: (panelId: string) => void;
|
|
175
|
+
/** 设置当前活跃面板的周期(多面板写入panelPeriods,单面板fallback全局) */
|
|
176
|
+
setActivePanelPeriod: (period: string) => void;
|
|
177
|
+
/** 设置指定面板的周期 */
|
|
178
|
+
setPanelPeriod: (panelId: string, period: string) => void;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** 图表主题选项(映射到LWC的theme相关选项) */
|
|
182
|
+
export declare interface ChartThemeOptions {
|
|
183
|
+
layout: {
|
|
184
|
+
background: {
|
|
185
|
+
color: string;
|
|
186
|
+
};
|
|
187
|
+
textColor: string;
|
|
188
|
+
};
|
|
189
|
+
grid: {
|
|
190
|
+
vertLines: {
|
|
191
|
+
color: string;
|
|
192
|
+
};
|
|
193
|
+
horzLines: {
|
|
194
|
+
color: string;
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
crosshair?: {
|
|
198
|
+
mode?: number;
|
|
199
|
+
vertLine?: {
|
|
200
|
+
color?: string;
|
|
201
|
+
labelBackgroundColor?: string;
|
|
202
|
+
};
|
|
203
|
+
horzLine?: {
|
|
204
|
+
color?: string;
|
|
205
|
+
labelBackgroundColor?: string;
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
/** ★ V3: 时间格式化配置 */
|
|
209
|
+
localization?: {
|
|
210
|
+
timeFormatter?: (time: Time) => string;
|
|
211
|
+
dateFormat?: string;
|
|
212
|
+
};
|
|
213
|
+
/** ★ V3: 时间轴配置 */
|
|
214
|
+
timeScale?: {
|
|
215
|
+
timeVisible?: boolean;
|
|
216
|
+
secondsVisible?: boolean;
|
|
217
|
+
tickMarkFormatter?: (time: Time, tickMarkType: number, locale: string) => string;
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** 创建一个指标配置 */
|
|
222
|
+
export declare function createIndicatorConfig(definition: IndicatorDefinition, overrides?: Partial<IndicatorConfig>): IndicatorConfig;
|
|
223
|
+
|
|
224
|
+
/** 十字光标数据 */
|
|
225
|
+
export declare interface CrosshairData {
|
|
226
|
+
time: Time;
|
|
227
|
+
price: number;
|
|
228
|
+
volume?: number;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export declare const darkPreset: ThemeConfig;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* 数据管理器(增强版)
|
|
235
|
+
*
|
|
236
|
+
* 三大核心能力:
|
|
237
|
+
* 1. 拖动加载(ScrollLoader)— 监听 visibleLogicalRangeChange,触底自动加载历史
|
|
238
|
+
* 2. 定时获取(RealtimePoller)— setInterval 拉取最新 K 线
|
|
239
|
+
* 3. 分片缓存(SliceCache)— 按 pair+product+period 维度缓存已加载的分片
|
|
240
|
+
*
|
|
241
|
+
* 同时保持对旧 fetchChartData() 的向后兼容。
|
|
242
|
+
*/
|
|
243
|
+
export declare class DataManager {
|
|
244
|
+
private fetchFn;
|
|
245
|
+
private cache;
|
|
246
|
+
private cacheTTL;
|
|
247
|
+
private chart;
|
|
248
|
+
private series;
|
|
249
|
+
private pairId;
|
|
250
|
+
private product;
|
|
251
|
+
private period;
|
|
252
|
+
private isLoadingHistory;
|
|
253
|
+
private hasMoreHistory;
|
|
254
|
+
private scrollHandler;
|
|
255
|
+
private realtimeTimer;
|
|
256
|
+
private allData;
|
|
257
|
+
private slices;
|
|
258
|
+
constructor(fetchFn: FetchFn);
|
|
259
|
+
/**
|
|
260
|
+
* 绑定到图表实例,启用拖动加载
|
|
261
|
+
*/
|
|
262
|
+
attachToChart(chart: IChartApi, series: ISeriesApi<any>, params: {
|
|
263
|
+
pairId: string;
|
|
264
|
+
product: string;
|
|
265
|
+
period: string;
|
|
266
|
+
}): void;
|
|
267
|
+
/**
|
|
268
|
+
* 解绑图表,清理所有监听和定时器
|
|
269
|
+
*/
|
|
270
|
+
detach(): void;
|
|
271
|
+
/**
|
|
272
|
+
* 加载更早的历史数据
|
|
273
|
+
*/
|
|
274
|
+
private loadMoreHistory;
|
|
275
|
+
/**
|
|
276
|
+
* 在 series 前面追加历史数据(方案B:维护全量数组)
|
|
277
|
+
*/
|
|
278
|
+
private prependData;
|
|
279
|
+
/**
|
|
280
|
+
* 启动定时获取最新数据
|
|
281
|
+
*/
|
|
282
|
+
startRealtimeFetch(intervalMs?: number): void;
|
|
283
|
+
/**
|
|
284
|
+
* 停止定时获取
|
|
285
|
+
*/
|
|
286
|
+
stopRealtimeFetch(): void;
|
|
287
|
+
/**
|
|
288
|
+
* 获取最新 K 线并增量更新
|
|
289
|
+
*/
|
|
290
|
+
private fetchLatest;
|
|
291
|
+
private getCacheKey;
|
|
292
|
+
/**
|
|
293
|
+
* 保存分片到缓存
|
|
294
|
+
*/
|
|
295
|
+
private saveSlice;
|
|
296
|
+
/**
|
|
297
|
+
* 查询缓存中是否包含指定时间范围的数据
|
|
298
|
+
*/
|
|
299
|
+
private getCachedSlices;
|
|
300
|
+
/**
|
|
301
|
+
* 检查分片缓存是否覆盖了请求范围
|
|
302
|
+
*/
|
|
303
|
+
private isRangeCached;
|
|
304
|
+
/**
|
|
305
|
+
* 从当前 allData 获取最早时间戳(毫秒)
|
|
306
|
+
*/
|
|
307
|
+
private getEarliestDataTime;
|
|
308
|
+
/**
|
|
309
|
+
* 从当前 allData 获取最新时间戳(毫秒)
|
|
310
|
+
*/
|
|
311
|
+
private getLatestDataTime;
|
|
312
|
+
/**
|
|
313
|
+
* 从 series 同步全量数据到 allData
|
|
314
|
+
*/
|
|
315
|
+
private syncAllDataFromSeries;
|
|
316
|
+
/**
|
|
317
|
+
* 手动设置全量数据(外部调用 setData 后同步)
|
|
318
|
+
*/
|
|
319
|
+
setAllData(data: CandlestickData[]): void;
|
|
320
|
+
/**
|
|
321
|
+
* 获取图表数据(带缓存,向后兼容)
|
|
322
|
+
*/
|
|
323
|
+
fetchChartData(params: ChartRequestParams): Promise<unknown>;
|
|
324
|
+
private getLegacyCacheKey;
|
|
325
|
+
private getCacheEntry;
|
|
326
|
+
private setCache;
|
|
327
|
+
/** 手动设置缓存数据 */
|
|
328
|
+
setCacheData(params: ChartRequestParams, data: unknown): void;
|
|
329
|
+
/** 清除所有缓存(旧缓存 + 分片缓存) */
|
|
330
|
+
clearCache(): void;
|
|
331
|
+
/** 设置缓存TTL(毫秒) */
|
|
332
|
+
setCacheTTL(ttl: number): void;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* 绘图工具注册表
|
|
337
|
+
* 从 lightweight-charts-drawing 的 68 种工具中筛选出我们需要的 21 种
|
|
338
|
+
*/
|
|
339
|
+
export declare const DRAWING_TOOLS: DrawingToolConfig[];
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* DrawingAdapter - 绘图适配器
|
|
343
|
+
* 作为 QLChart 和 lightweight-charts-drawing DrawingManager 的桥接层
|
|
344
|
+
*
|
|
345
|
+
* Core/Plugin 层不依赖 React
|
|
346
|
+
*/
|
|
347
|
+
export declare class DrawingAdapter {
|
|
348
|
+
private manager;
|
|
349
|
+
private chart;
|
|
350
|
+
private series;
|
|
351
|
+
private container;
|
|
352
|
+
private unsubscribers;
|
|
353
|
+
private chartId;
|
|
354
|
+
private creationState;
|
|
355
|
+
private chartClickHandler;
|
|
356
|
+
private chartDblClickHandler;
|
|
357
|
+
private containerMouseMoveHandler;
|
|
358
|
+
private keydownHandler;
|
|
359
|
+
private defaultDrawingStyle;
|
|
360
|
+
private bodyDragState;
|
|
361
|
+
private bodyDragStartHandler;
|
|
362
|
+
private bodyDragMoveHandler;
|
|
363
|
+
private bodyDragEndHandler;
|
|
364
|
+
private freeDrawStartHandler;
|
|
365
|
+
private freeDrawMoveHandler;
|
|
366
|
+
private freeDrawEndHandler;
|
|
367
|
+
private freeDrawActive;
|
|
368
|
+
private freeDrawRafId;
|
|
369
|
+
private freeDrawPendingEvent;
|
|
370
|
+
private rafId;
|
|
371
|
+
private pendingDragEvent;
|
|
372
|
+
private magnetEnabled;
|
|
373
|
+
private candleData;
|
|
374
|
+
private priceRangeCache;
|
|
375
|
+
private activeToolType;
|
|
376
|
+
private currentPeriod;
|
|
377
|
+
private textLabelOverlay;
|
|
378
|
+
private textInputEditor;
|
|
379
|
+
/** 当前绘图目标 pane index(0 = 主图) */
|
|
380
|
+
private currentPaneIndex;
|
|
381
|
+
/** paneIndex → 该 pane 的绘图数据(绘图隔离) */
|
|
382
|
+
private paneDrawingsMap;
|
|
383
|
+
/** pane 切换请求回调(通知外部获取目标 pane 的 series) */
|
|
384
|
+
private onPaneSwitchNeededCb?;
|
|
385
|
+
/** ★ V5 需求1:paneIndex → series 映射(内部维护,不再依赖外部回查) */
|
|
386
|
+
private paneSeriesInternalMap;
|
|
387
|
+
private savedScrollOptions;
|
|
388
|
+
private savedScaleOptions;
|
|
389
|
+
private onDrawingCreatedCb?;
|
|
390
|
+
private onDrawingSelectedCb?;
|
|
391
|
+
private onDrawingModifiedCb?;
|
|
392
|
+
private onDrawingRemovedCb?;
|
|
393
|
+
private onToolChangedCb?;
|
|
394
|
+
private onDrawingDoubleClickCb?;
|
|
395
|
+
/**
|
|
396
|
+
* 绑定 DrawingManager 到 chart/series/container
|
|
397
|
+
*/
|
|
398
|
+
attach(chart: IChartApi, series: ISeriesApi<SeriesType_2>, container: HTMLElement, chartId?: string): void;
|
|
399
|
+
/**
|
|
400
|
+
* 解绑并销毁 DrawingManager
|
|
401
|
+
*/
|
|
402
|
+
detach(): void;
|
|
403
|
+
/** 是否已绑定 */
|
|
404
|
+
isAttached(): boolean;
|
|
405
|
+
isFullyAttached(): boolean;
|
|
406
|
+
getAttachDiagnostics(): Record<string, unknown>;
|
|
407
|
+
/**
|
|
408
|
+
* 设置当前绘图工具
|
|
409
|
+
* 'cursor' = 取消绘图模式
|
|
410
|
+
*/
|
|
411
|
+
setActiveTool(toolType: DrawingToolType): void;
|
|
412
|
+
/** 获取当前工具类型 */
|
|
413
|
+
getActiveTool(): string | null;
|
|
414
|
+
setPeriod(period: string): void;
|
|
415
|
+
/** 获取当前周期 */
|
|
416
|
+
getCurrentPeriod(): string;
|
|
417
|
+
/**
|
|
418
|
+
* Bug1修复:刷新测量器标签 — patch 所有 date-price-range 绘图
|
|
419
|
+
*/
|
|
420
|
+
private refreshMeasureLabels;
|
|
421
|
+
/**
|
|
422
|
+
* Bug1修复:Patch 测量器绘图,覆盖 getMeasureInfo 计算正确的 bars
|
|
423
|
+
*/
|
|
424
|
+
private patchMeasureDrawing;
|
|
425
|
+
/**
|
|
426
|
+
* Bug1修复:将周期字符串转换为秒数
|
|
427
|
+
*/
|
|
428
|
+
private periodToSeconds;
|
|
429
|
+
/**
|
|
430
|
+
* Bug1修复:公开方法 — patch 测量器绘图(供外部调用)
|
|
431
|
+
*/
|
|
432
|
+
patchMeasureDrawingPublic(drawing: IDrawing): void;
|
|
433
|
+
/** 获取所有绘图实例 */
|
|
434
|
+
getAllDrawings(): IDrawing[];
|
|
435
|
+
/** 设置所有绘图的可见性 */
|
|
436
|
+
setAllVisible(visible: boolean): void;
|
|
437
|
+
/** 获取所有绘图是否可见 */
|
|
438
|
+
getAllVisible(): boolean;
|
|
439
|
+
/** 选中某个绘图 */
|
|
440
|
+
selectDrawing(id: string): void;
|
|
441
|
+
/** 取消选中 */
|
|
442
|
+
deselectAll(): void;
|
|
443
|
+
/** 获取当前选中的绘图 */
|
|
444
|
+
getSelectedDrawing(): IDrawing | null;
|
|
445
|
+
/** 删除指定绘图 */
|
|
446
|
+
removeDrawing(id: string): void;
|
|
447
|
+
/** 删除当前选中的绘图 */
|
|
448
|
+
removeSelected(): void;
|
|
449
|
+
/** 清空所有绘图 */
|
|
450
|
+
clearAll(): void;
|
|
451
|
+
/**
|
|
452
|
+
* 导出绘图数据(用于持久化)
|
|
453
|
+
*/
|
|
454
|
+
exportDrawings(): DrawingPersistData[];
|
|
455
|
+
/**
|
|
456
|
+
* 导入绘图数据(从后端加载恢复)
|
|
457
|
+
*/
|
|
458
|
+
importDrawings(data: DrawingPersistData[]): void;
|
|
459
|
+
/**
|
|
460
|
+
* 更新主序列引用(数据重载后调用)
|
|
461
|
+
*/
|
|
462
|
+
updateSeries(series: ISeriesApi<SeriesType_2>): void;
|
|
463
|
+
/**
|
|
464
|
+
* ★ Bug5修复:切换绘图目标series(用于在副图中绘图)
|
|
465
|
+
*/
|
|
466
|
+
setTargetSeries(series: ISeriesApi<SeriesType_2>): void;
|
|
467
|
+
/** 设置K线数据(用于磁铁吸附计算) */
|
|
468
|
+
setCandleData(data: CandlestickData_2[]): void;
|
|
469
|
+
/**
|
|
470
|
+
* ★ 多周期共享修复:二分查找最接近targetTime的K线时间戳
|
|
471
|
+
* candleData按time升序排列(由transformCandlestickData保证)
|
|
472
|
+
* 时间复杂度: O(log n)
|
|
473
|
+
*/
|
|
474
|
+
private findNearestCandleTime;
|
|
475
|
+
/**
|
|
476
|
+
* ★ 多周期共享修复:将锚点时间对齐到当前周期的K线时间戳
|
|
477
|
+
* 用于跨周期共享时解决时间戳不匹配问题
|
|
478
|
+
*/
|
|
479
|
+
private alignAnchorsToPeriod;
|
|
480
|
+
/** 设置磁铁吸附开关 */
|
|
481
|
+
setMagnetEnabled(enabled: boolean): void;
|
|
482
|
+
/**
|
|
483
|
+
* 获取鼠标位置最近的K线价格(磁铁吸附)
|
|
484
|
+
*/
|
|
485
|
+
getNearestPrice(clientX: number, clientY: number): {
|
|
486
|
+
time: number;
|
|
487
|
+
price: number;
|
|
488
|
+
} | null;
|
|
489
|
+
/** 设置事件回调 */
|
|
490
|
+
onDrawingCreated(cb: (drawing: IDrawing) => void): void;
|
|
491
|
+
onDrawingSelected(cb: (drawing: IDrawing | null) => void): void;
|
|
492
|
+
onDrawingModified(cb: (drawing: IDrawing) => void): void;
|
|
493
|
+
onDrawingRemoved(cb: (id: string) => void): void;
|
|
494
|
+
onToolChanged(cb: (tool: string | null) => void): void;
|
|
495
|
+
onDrawingDoubleClick(cb: (drawing: IDrawing | null) => void): void;
|
|
496
|
+
/** Bug3修复:设置绘图文字标签(从属性面板调用) */
|
|
497
|
+
setDrawingText(drawingId: string, text: string): void;
|
|
498
|
+
/** 销毁 */
|
|
499
|
+
dispose(): void;
|
|
500
|
+
/**
|
|
501
|
+
* ★ V2: 检测点击落在哪个 pane
|
|
502
|
+
* LWC v5 提供 chart.panes() API,每个 pane 有 getHeight()
|
|
503
|
+
*/
|
|
504
|
+
private detectPaneIndex;
|
|
505
|
+
/**
|
|
506
|
+
* ★ V2: 切换绘图目标 pane(带绘图隔离)
|
|
507
|
+
*/
|
|
508
|
+
switchPane(paneIndex: number, paneSeries: ISeriesApi<SeriesType_2>): void;
|
|
509
|
+
/**
|
|
510
|
+
* ★ V2: 获取当前目标 pane index
|
|
511
|
+
*/
|
|
512
|
+
getCurrentPaneIndex(): number;
|
|
513
|
+
/**
|
|
514
|
+
* ★ V2: 重置到主图 pane
|
|
515
|
+
*/
|
|
516
|
+
resetToMainPane(): void;
|
|
517
|
+
/**
|
|
518
|
+
* ★ V6 需求1:清除所有 pane series 映射(指标 clearAll 后调用)
|
|
519
|
+
*/
|
|
520
|
+
clearPaneSeriesMap(): void;
|
|
521
|
+
/**
|
|
522
|
+
* ★ V5 需求1:注册 pane series 映射(供内部 detectPaneIndex 自动切换)
|
|
523
|
+
*/
|
|
524
|
+
registerPaneSeries(paneIndex: number, series: ISeriesApi<SeriesType_2>): void;
|
|
525
|
+
/**
|
|
526
|
+
* ★ V5 需求1:取消注册 pane series
|
|
527
|
+
*/
|
|
528
|
+
unregisterPaneSeries(paneIndex: number): void;
|
|
529
|
+
/**
|
|
530
|
+
* ★ V2: 设置 pane 切换请求回调
|
|
531
|
+
*/
|
|
532
|
+
onPaneSwitchNeeded(cb: (paneIndex: number) => void): void;
|
|
533
|
+
/**
|
|
534
|
+
* Bug①修复:绑定拖拽交互
|
|
535
|
+
* 选中绘图时禁用 chart 的平移和缩放,取消选中时恢复
|
|
536
|
+
* 关键:handleScroll/handleScale 是 ChartOptions 顶层属性,pressedMouseMove 是正确属性名
|
|
537
|
+
*/
|
|
538
|
+
private bindDragInteraction;
|
|
539
|
+
private bindEvents;
|
|
540
|
+
private unbindEvents;
|
|
541
|
+
/**
|
|
542
|
+
* 处理图表点击 — 绘图创建核心逻辑
|
|
543
|
+
*/
|
|
544
|
+
private handleChartClick;
|
|
545
|
+
/**
|
|
546
|
+
* 开始创建绘图
|
|
547
|
+
*/
|
|
548
|
+
private startCreation;
|
|
549
|
+
/**
|
|
550
|
+
* 添加锚点
|
|
551
|
+
*/
|
|
552
|
+
private addAnchor;
|
|
553
|
+
/**
|
|
554
|
+
* 完成创建 — 重置状态,自动切回光标
|
|
555
|
+
*/
|
|
556
|
+
private completeCreation;
|
|
557
|
+
/**
|
|
558
|
+
* 取消创建 — 移除创建中的绘图,重置状态
|
|
559
|
+
*/
|
|
560
|
+
private cancelCreation;
|
|
561
|
+
/**
|
|
562
|
+
* 处理双击 — 动态锚点工具结束创建
|
|
563
|
+
*/
|
|
564
|
+
private handleChartDblClick;
|
|
565
|
+
/**
|
|
566
|
+
* 处理鼠标移动 — 实时预览创建中的绘图
|
|
567
|
+
*/
|
|
568
|
+
private handleContainerMouseMove;
|
|
569
|
+
/**
|
|
570
|
+
* 处理键盘 — Esc 取消创建
|
|
571
|
+
*/
|
|
572
|
+
private handleKeydown;
|
|
573
|
+
/**
|
|
574
|
+
* 整体拖拽:启动检测(capture 阶段,先于库的 mousedown)
|
|
575
|
+
*/
|
|
576
|
+
private handleBodyDragStart;
|
|
577
|
+
/**
|
|
578
|
+
* 整体拖拽:移动入口(rAF节流)
|
|
579
|
+
*/
|
|
580
|
+
private handleBodyDragMove;
|
|
581
|
+
/**
|
|
582
|
+
* 整体拖拽:实际移动逻辑(逐锚点像素转换方案)
|
|
583
|
+
*/
|
|
584
|
+
private processBodyDragMove;
|
|
585
|
+
/**
|
|
586
|
+
* 整体拖拽:结束
|
|
587
|
+
*/
|
|
588
|
+
private handleBodyDragEnd;
|
|
589
|
+
/**
|
|
590
|
+
* 画笔自由绘制:mousedown 拦截
|
|
591
|
+
*/
|
|
592
|
+
private handleFreeDrawStart;
|
|
593
|
+
/**
|
|
594
|
+
* 画笔自由绘制:mousemove(rAF节流)
|
|
595
|
+
*/
|
|
596
|
+
private handleFreeDrawMove;
|
|
597
|
+
/**
|
|
598
|
+
* 画笔自由绘制:mouseup
|
|
599
|
+
*/
|
|
600
|
+
private handleFreeDrawEnd;
|
|
601
|
+
/**
|
|
602
|
+
* 显示文字输入编辑器
|
|
603
|
+
*/
|
|
604
|
+
private showTextInputEditor;
|
|
605
|
+
/**
|
|
606
|
+
* 隐藏文字输入编辑器
|
|
607
|
+
*/
|
|
608
|
+
private hideTextInputEditor;
|
|
609
|
+
/**
|
|
610
|
+
* Bug4修复:更新所有文字标签位置(图表滚动/缩放后调用)
|
|
611
|
+
*/
|
|
612
|
+
private updateTextLabels;
|
|
613
|
+
/**
|
|
614
|
+
* 辅助:构造 Viewport
|
|
615
|
+
*/
|
|
616
|
+
private getViewport;
|
|
617
|
+
/**
|
|
618
|
+
* Bug2修复:获取K线价格范围(带缓存)
|
|
619
|
+
*/
|
|
620
|
+
private getPriceRange;
|
|
621
|
+
/**
|
|
622
|
+
* Bug2修复:限制价格在K线数据的合理范围内
|
|
623
|
+
* 允许 20% 的超出余量,避免完全锁死影响用户体验
|
|
624
|
+
*/
|
|
625
|
+
private clampPriceToData;
|
|
626
|
+
/**
|
|
627
|
+
* Fib Bug修复:扩大命中范围的 fallback hitTest
|
|
628
|
+
* @param pixel 鼠标像素坐标
|
|
629
|
+
* @param threshold 扩大的命中阈值(像素)
|
|
630
|
+
* @return 最近的命中绘图,或 null
|
|
631
|
+
*/
|
|
632
|
+
private hitTestFallback;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* 绘图模块容器组件
|
|
637
|
+
*
|
|
638
|
+
* 独立管理绘图工具栏的渲染。
|
|
639
|
+
* 渲染位置由父组件控制(通常在QLChartPanel中)。
|
|
640
|
+
*
|
|
641
|
+
* 使用方式:
|
|
642
|
+
* ```tsx
|
|
643
|
+
* <DrawingModule />
|
|
644
|
+
* ```
|
|
645
|
+
*/
|
|
646
|
+
export declare function DrawingModule({ showPropertyPanel, className, }: DrawingModuleProps): JSX_2.Element;
|
|
647
|
+
|
|
648
|
+
export declare interface DrawingModuleProps {
|
|
649
|
+
/** 是否显示属性面板(默认true) */
|
|
650
|
+
showPropertyPanel?: boolean;
|
|
651
|
+
/** 自定义 className */
|
|
652
|
+
className?: string;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
/** 绘图持久化数据 */
|
|
656
|
+
declare interface DrawingPersistData {
|
|
657
|
+
id: string;
|
|
658
|
+
chartId: string;
|
|
659
|
+
type: string;
|
|
660
|
+
anchors: Array<{
|
|
661
|
+
time: number;
|
|
662
|
+
price: number;
|
|
663
|
+
}>;
|
|
664
|
+
style: DrawingStyleConfig;
|
|
665
|
+
options: {
|
|
666
|
+
visible?: boolean;
|
|
667
|
+
locked?: boolean;
|
|
668
|
+
zIndex?: number;
|
|
669
|
+
extendLeft?: boolean;
|
|
670
|
+
extendRight?: boolean;
|
|
671
|
+
};
|
|
672
|
+
createdAt: number;
|
|
673
|
+
updatedAt: number;
|
|
674
|
+
/** ★ V2 新增:所属 pane index(0=主图) */
|
|
675
|
+
paneIndex?: number;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/** 持久化管理器 */
|
|
679
|
+
export declare class DrawingPersistence {
|
|
680
|
+
private storageKey;
|
|
681
|
+
private pairId;
|
|
682
|
+
private product;
|
|
683
|
+
private mode;
|
|
684
|
+
private apiBaseUrl?;
|
|
685
|
+
private debounceTimer;
|
|
686
|
+
constructor(config: PersistenceConfig);
|
|
687
|
+
/** 保存画图数据 */
|
|
688
|
+
save(drawings: DrawingPersistData[]): Promise<void>;
|
|
689
|
+
/** 加载画图数据 */
|
|
690
|
+
load(): Promise<DrawingPersistData[]>;
|
|
691
|
+
/** 删除指定画图 */
|
|
692
|
+
remove(id: string): Promise<void>;
|
|
693
|
+
/** 更新单条绘图(增量更新) */
|
|
694
|
+
update(drawing: DrawingPersistData): Promise<void>;
|
|
695
|
+
/** 清空所有画图 */
|
|
696
|
+
clear(): Promise<void>;
|
|
697
|
+
/** 导出为JSON字符串(备份用) */
|
|
698
|
+
exportJSON(drawings: DrawingPersistData[]): string;
|
|
699
|
+
/** 从JSON字符串导入 */
|
|
700
|
+
importJSON(json: string): Promise<void>;
|
|
701
|
+
/** 自动保存(debounce) */
|
|
702
|
+
autoSave(drawings: DrawingPersistData[]): void;
|
|
703
|
+
/** 销毁 */
|
|
704
|
+
dispose(): void;
|
|
705
|
+
/** 构建存储Key(仅使用 pairId + product,移除 chartId 和 period) */
|
|
706
|
+
private buildKey;
|
|
707
|
+
/** 简单hash函数 */
|
|
708
|
+
private simpleHash;
|
|
709
|
+
private localSave;
|
|
710
|
+
private localLoad;
|
|
711
|
+
private localRemove;
|
|
712
|
+
private localClear;
|
|
713
|
+
/** 检查localStorage容量 */
|
|
714
|
+
private checkStorageSize;
|
|
715
|
+
/** 批量保存(全量覆盖) */
|
|
716
|
+
private remoteSave;
|
|
717
|
+
/** 按交易对加载全部绘图 */
|
|
718
|
+
private remoteLoad;
|
|
719
|
+
/** 删除单条绘图 */
|
|
720
|
+
private remoteRemove;
|
|
721
|
+
/** 更新单条绘图(增量更新) */
|
|
722
|
+
private remoteUpdate;
|
|
723
|
+
/** 清空指定交易对的所有绘图 */
|
|
724
|
+
private remoteClear;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
export declare interface DrawingState {
|
|
728
|
+
/** 当前激活的绘图工具 */
|
|
729
|
+
activeTool: DrawingToolType;
|
|
730
|
+
/** 绘图数量(用于显示 badge) */
|
|
731
|
+
drawingCount: number;
|
|
732
|
+
/** 当前选中的绘图 ID */
|
|
733
|
+
selectedDrawingId: string | null;
|
|
734
|
+
/** 当前选中的绘图类型 */
|
|
735
|
+
selectedDrawingType: string | null;
|
|
736
|
+
/** 磁铁吸附开关 */
|
|
737
|
+
magnetEnabled: boolean;
|
|
738
|
+
/** 是否正在绘图 */
|
|
739
|
+
isDrawing: boolean;
|
|
740
|
+
/** 显示属性面板 */
|
|
741
|
+
showPropertyPanel: boolean;
|
|
742
|
+
/** 属性面板是否被双击锁定打开 */
|
|
743
|
+
isPropertyPanelPinned: boolean;
|
|
744
|
+
/** 工具栏方向 */
|
|
745
|
+
toolbarOrientation: 'vertical' | 'horizontal';
|
|
746
|
+
/** 工具栏自定义位置 */
|
|
747
|
+
toolbarPosition: {
|
|
748
|
+
x: number;
|
|
749
|
+
y: number;
|
|
750
|
+
} | null;
|
|
751
|
+
/** 工具栏是否正在拖拽 */
|
|
752
|
+
isToolbarDragging: boolean;
|
|
753
|
+
/** 选中绘图的样式快照(用于属性面板编辑) */
|
|
754
|
+
selectedStyle: DrawingStyleConfig | null;
|
|
755
|
+
/** 绘图工具栏是否展开 */
|
|
756
|
+
drawingToolbarOpen: boolean;
|
|
757
|
+
/** 每分类的展开状态 */
|
|
758
|
+
expandedCategory: DrawingToolCategory | null;
|
|
759
|
+
/** 每分类当前选中的工具(用于显示分类行的 icon) */
|
|
760
|
+
categoryActiveTools: Partial<Record<DrawingToolCategory, DrawingToolType>>;
|
|
761
|
+
/** ★ V2: 当前绘图目标 pane index(0 = 主图) */
|
|
762
|
+
currentPaneIndex: number;
|
|
763
|
+
setActiveTool: (tool: DrawingToolType) => void;
|
|
764
|
+
setDrawingCount: (count: number) => void;
|
|
765
|
+
selectDrawing: (id: string | null, style?: DrawingStyleConfig | null, type?: string | null) => void;
|
|
766
|
+
setMagnetEnabled: (enabled: boolean) => void;
|
|
767
|
+
setIsDrawing: (drawing: boolean) => void;
|
|
768
|
+
setShowPropertyPanel: (show: boolean) => void;
|
|
769
|
+
setIsPropertyPanelPinned: (pinned: boolean) => void;
|
|
770
|
+
setToolbarOrientation: (o: 'vertical' | 'horizontal') => void;
|
|
771
|
+
setToolbarPosition: (pos: {
|
|
772
|
+
x: number;
|
|
773
|
+
y: number;
|
|
774
|
+
} | null) => void;
|
|
775
|
+
setIsToolbarDragging: (dragging: boolean) => void;
|
|
776
|
+
setSelectedStyle: (style: DrawingStyleConfig | null) => void;
|
|
777
|
+
setDrawingToolbarOpen: (open: boolean) => void;
|
|
778
|
+
/** 设置展开的分类 */
|
|
779
|
+
setExpandedCategory: (category: DrawingToolCategory | null) => void;
|
|
780
|
+
/** 设置分类当前工具 */
|
|
781
|
+
setCategoryActiveTool: (category: DrawingToolCategory, tool: DrawingToolType) => void;
|
|
782
|
+
/** ★ V2: 设置当前 pane index */
|
|
783
|
+
setCurrentPaneIndex: (index: number) => void;
|
|
784
|
+
clearAll: () => void;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
/** 绘图样式(与库的 DrawingStyle 对齐) */
|
|
788
|
+
declare interface DrawingStyleConfig {
|
|
789
|
+
lineColor: string;
|
|
790
|
+
lineWidth: number;
|
|
791
|
+
lineDash?: number[];
|
|
792
|
+
fillColor?: string;
|
|
793
|
+
fillOpacity?: number;
|
|
794
|
+
showLabels?: boolean;
|
|
795
|
+
labelFont?: string;
|
|
796
|
+
labelColor?: string;
|
|
797
|
+
/** 附加文字标签 */
|
|
798
|
+
text?: string;
|
|
799
|
+
/** 线条样式名称 */
|
|
800
|
+
lineStyle?: string;
|
|
801
|
+
/** 斐波那契比例线 */
|
|
802
|
+
fibRatios?: string;
|
|
803
|
+
/** ★ Req3:斐波那契级别(序列化为 JSON 字符串便于存储) */
|
|
804
|
+
fibLevels?: string;
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
/** 绘图工具分类 */
|
|
808
|
+
declare enum DrawingToolCategory {
|
|
809
|
+
Lines = "line",
|
|
810
|
+
Channels = "channel",
|
|
811
|
+
Fibonacci = "fibonacci",
|
|
812
|
+
Shapes = "shape",
|
|
813
|
+
Annotations = "annotation",
|
|
814
|
+
Positions = "trading",
|
|
815
|
+
Measure = "measurement",
|
|
816
|
+
Patterns = "pattern",
|
|
817
|
+
VolumeProfile = "volume-profile"
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
/** 绘图工具配置 */
|
|
821
|
+
declare interface DrawingToolConfig {
|
|
822
|
+
type: DrawingToolType;
|
|
823
|
+
label: string;
|
|
824
|
+
icon: string;
|
|
825
|
+
category: DrawingToolCategory;
|
|
826
|
+
anchorCount: number;
|
|
827
|
+
priority: number;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
/** 绘图工具类型 - 映射到 lightweight-charts-drawing 的 tool type strings */
|
|
831
|
+
declare type DrawingToolType = 'cursor' | 'trend-line' | 'horizontal-line' | 'vertical-line' | 'ray' | 'rectangle' | 'fib-retracement' | 'path' | 'parallel-channel' | 'circle' | 'ellipse' | 'triangle' | 'fib-extension' | 'arrow' | 'brush' | 'cross-line' | 'callout' | 'long-position' | 'short-position' | 'fib-fan' | 'date-price-range' | 'fib-circles' | 'fib-time-zone' | 'rotated-rectangle' | 'pattern-abcd' | 'pattern-xabcd' | 'pattern-head-shoulders' | 'pattern-triangle' | 'pattern-cypher' | 'info-line' | 'extended-line' | 'trend-angle' | 'horizontal-ray' | 'regression-trend' | 'flat-top-bottom' | 'disjoint-channel' | 'andrews-pitchfork' | 'schiff-pitchfork' | 'modified-schiff-pitchfork' | 'inside-pitchfork' | 'fib-channel' | 'fib-time-extension' | 'fib-spiral' | 'fib-arcs' | 'fib-wedge' | 'pitchfan' | 'gann-box' | 'gann-fan' | 'gann-square-fixed' | 'gann-square' | 'forecast' | 'bars-pattern' | 'projection' | 'price-range' | 'date-range' | 'polyline' | 'curve' | 'double-curve' | 'arc' | 'polygon' | 'text' | 'text-annotation' | 'anchored-text' | 'note' | 'price-note' | 'price-label' | 'flag-mark' | 'pin' | 'comment' | 'signpost' | 'table' | 'highlighter' | 'arrow-marker' | 'arrow-mark-up' | 'arrow-mark-down' | 'volume-profile';
|
|
832
|
+
|
|
833
|
+
/** 事件处理器类型 */
|
|
834
|
+
export declare type EventHandler<T = unknown> = (data: T) => void;
|
|
835
|
+
|
|
836
|
+
/**
|
|
837
|
+
* 泛型事件总线
|
|
838
|
+
* 用于图表各模块间的解耦通信
|
|
839
|
+
*/
|
|
840
|
+
export declare class EventManager {
|
|
841
|
+
private listeners;
|
|
842
|
+
/** 注册事件监听 */
|
|
843
|
+
on<T = unknown>(event: string, handler: EventHandler<T>): () => void;
|
|
844
|
+
/** 取消事件监听 */
|
|
845
|
+
off<T = unknown>(event: string, handler: EventHandler<T>): void;
|
|
846
|
+
/** 触发事件 */
|
|
847
|
+
emit<T = unknown>(event: string, data?: T): void;
|
|
848
|
+
/** 清除所有监听 */
|
|
849
|
+
clear(): void;
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
/** 数据获取回调函数类型 */
|
|
853
|
+
export declare type FetchFn = (params: ChartRequestParams) => Promise<unknown>;
|
|
854
|
+
|
|
855
|
+
/** 获取工具配置 */
|
|
856
|
+
export declare function getToolConfig(type: DrawingToolType): DrawingToolConfig | undefined;
|
|
857
|
+
|
|
858
|
+
/** 获取按分类分组的工具 */
|
|
859
|
+
export declare function getToolsByCategory(): Map<DrawingToolCategory, DrawingToolConfig[]>;
|
|
860
|
+
|
|
861
|
+
/** 获取按优先级分组的工具 */
|
|
862
|
+
export declare function getToolsByPriority(priority: number): DrawingToolConfig[];
|
|
863
|
+
|
|
864
|
+
/** LWC 成交量数据 */
|
|
865
|
+
export declare interface HistogramData {
|
|
866
|
+
time: number;
|
|
867
|
+
value: number;
|
|
868
|
+
color?: string;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
/** 空心蜡烛图数据 */
|
|
872
|
+
export declare interface HollowCandlestickData extends CustomData {
|
|
873
|
+
open: number;
|
|
874
|
+
high: number;
|
|
875
|
+
low: number;
|
|
876
|
+
close: number;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
/** 空心蜡烛图 PaneView */
|
|
880
|
+
export declare class HollowCandlestickSeries implements ICustomSeriesPaneView<unknown, HollowCandlestickData, CustomSeriesOptions> {
|
|
881
|
+
private _renderer;
|
|
882
|
+
defaultOptions(): CustomSeriesOptions;
|
|
883
|
+
renderer(): ICustomSeriesPaneRenderer;
|
|
884
|
+
update(data: PaneRendererCustomData<unknown, HollowCandlestickData>, _seriesOptions: CustomSeriesOptions): void;
|
|
885
|
+
priceValueBuilder(plotRow: HollowCandlestickData): CustomSeriesPricePlotValues;
|
|
886
|
+
isWhitespace(data: HollowCandlestickData | CustomSeriesWhitespaceData<unknown>): data is CustomSeriesWhitespaceData<unknown>;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
/** 活跃指标配置 */
|
|
890
|
+
export declare interface IndicatorConfig {
|
|
891
|
+
id: string;
|
|
892
|
+
name: string;
|
|
893
|
+
label: string;
|
|
894
|
+
type: IndicatorType;
|
|
895
|
+
params: Record<string, number>;
|
|
896
|
+
visible: boolean;
|
|
897
|
+
color?: string;
|
|
898
|
+
seriesIds: string[];
|
|
899
|
+
paneIndex?: number;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
/** 单条指标数据 */
|
|
903
|
+
export declare interface IndicatorDataPoint {
|
|
904
|
+
time: number;
|
|
905
|
+
values: Record<string, number>;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
/** 指标数据响应(API返回) */
|
|
909
|
+
export declare interface IndicatorDataResponse {
|
|
910
|
+
name: string;
|
|
911
|
+
params: Record<string, number>;
|
|
912
|
+
data: IndicatorDataPoint[];
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
/** 指标定义(注册表) */
|
|
916
|
+
export declare interface IndicatorDefinition {
|
|
917
|
+
name: string;
|
|
918
|
+
label: string;
|
|
919
|
+
type: IndicatorType;
|
|
920
|
+
defaultParams: Record<string, number>;
|
|
921
|
+
paramDefs: IndicatorParamDef[];
|
|
922
|
+
description: string;
|
|
923
|
+
colors: string[];
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
/**
|
|
927
|
+
* 指标显示类型(v2新架构)
|
|
928
|
+
*/
|
|
929
|
+
declare enum IndicatorDisplayType {
|
|
930
|
+
/** 主图叠加(如MA、EMA、BOLL) */
|
|
931
|
+
Overlay = "overlay",
|
|
932
|
+
/** 主图背景(如成交量Volume) */
|
|
933
|
+
Background = "background",
|
|
934
|
+
/** 副图指标(如MACD、RSI、KDJ) */
|
|
935
|
+
Pane = "pane"
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
/**
|
|
939
|
+
* 单条指标线定义(v2新架构)
|
|
940
|
+
* 一个指标(如MACD)可能包含多条线(DIF、DEA、MACD柱)
|
|
941
|
+
*/
|
|
942
|
+
declare interface IndicatorLineDef {
|
|
943
|
+
/** 线的唯一key(如 'dif', 'dea', 'macd') */
|
|
944
|
+
key: string;
|
|
945
|
+
/** 显示名称(如 'DIF') */
|
|
946
|
+
label: string;
|
|
947
|
+
/** 该线的数据在data二维数组的每行中的列索引 */
|
|
948
|
+
dataIndex: number;
|
|
949
|
+
/** 渲染类型 */
|
|
950
|
+
renderType: 'line' | 'histogram' | 'area';
|
|
951
|
+
/** 默认颜色 */
|
|
952
|
+
color: string;
|
|
953
|
+
/** 线宽(默认1) */
|
|
954
|
+
lineWidth?: number;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
/** 指标线条渲染定义 */
|
|
958
|
+
declare interface IndicatorLineSpec {
|
|
959
|
+
/** 数据字段名(对应 indicatorData 中的 key) */
|
|
960
|
+
field: string;
|
|
961
|
+
/** 显示名称 */
|
|
962
|
+
label: string;
|
|
963
|
+
/** 渲染类型 */
|
|
964
|
+
type: 'line' | 'histogram' | 'area';
|
|
965
|
+
/** 颜色 */
|
|
966
|
+
color: string;
|
|
967
|
+
/** 线宽(默认1) */
|
|
968
|
+
lineWidth?: number;
|
|
969
|
+
/** 柱状图正值颜色(仅 histogram) */
|
|
970
|
+
positiveColor?: string;
|
|
971
|
+
/** 柱状图负值颜色(仅 histogram) */
|
|
972
|
+
negativeColor?: string;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* 后端返回的指标列表响应
|
|
977
|
+
*/
|
|
978
|
+
declare interface IndicatorListResponse {
|
|
979
|
+
/** 可用指标列表 */
|
|
980
|
+
indicators: IndicatorTemplate[];
|
|
981
|
+
/** 用户已添加的指标(上次会话状态) */
|
|
982
|
+
activeIndicators?: ActiveIndicatorConfig[];
|
|
983
|
+
/** 指标分类列表(用于面板分类筛选) */
|
|
984
|
+
categories?: string[];
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
declare interface IndicatorModalProps {
|
|
988
|
+
open: boolean;
|
|
989
|
+
onClose: () => void;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
/** 指标面板 — 现在渲染 IndicatorModal */
|
|
993
|
+
export declare function IndicatorPanel(props: IndicatorPanelProps): JSX_2.Element;
|
|
994
|
+
|
|
995
|
+
/** 向后兼容别名 */
|
|
996
|
+
export declare type IndicatorPanelProps = IndicatorModalProps;
|
|
997
|
+
|
|
998
|
+
/** 指标参数定义 */
|
|
999
|
+
export declare interface IndicatorParamDef {
|
|
1000
|
+
name: string;
|
|
1001
|
+
label: string;
|
|
1002
|
+
defaultValue: number;
|
|
1003
|
+
min?: number;
|
|
1004
|
+
max?: number;
|
|
1005
|
+
step?: number;
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
/** 指标数据(API返回) */
|
|
1009
|
+
export declare interface IndicatorRawData {
|
|
1010
|
+
time: number;
|
|
1011
|
+
value: number;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
/**
|
|
1015
|
+
* IndicatorRenderer - 指标渲染器
|
|
1016
|
+
* 统一管理指标的渲染和移除
|
|
1017
|
+
*
|
|
1018
|
+
* 双模式架构:
|
|
1019
|
+
* - 有 renderSpec → AutoIndicatorRenderer(数据驱动,零硬编码)
|
|
1020
|
+
* - 无 renderSpec → switch-case fallback(兼容旧模式)
|
|
1021
|
+
*
|
|
1022
|
+
* 重构:副图指标使用LWC v5原生pane系统,不再使用PaneChartPanel
|
|
1023
|
+
*/
|
|
1024
|
+
export declare class IndicatorRenderer {
|
|
1025
|
+
private chart;
|
|
1026
|
+
private seriesManager;
|
|
1027
|
+
/** indicatorConfig.id → series引用列表 */
|
|
1028
|
+
private renderedSeries;
|
|
1029
|
+
/** 副图pane索引分配器(0是主图,从1开始) */
|
|
1030
|
+
private nextPaneIndex;
|
|
1031
|
+
/** indicatorConfig.id → paneIndex 映射 */
|
|
1032
|
+
private indicatorPaneMap;
|
|
1033
|
+
/** ★ V2 新增:paneIndex → 主series 引用(副图的代表性series) */
|
|
1034
|
+
private paneSeriesMap;
|
|
1035
|
+
/** ★ 任务3-2.3:自动渲染引擎(数据驱动模式) */
|
|
1036
|
+
private autoRenderer;
|
|
1037
|
+
/** ★ 任务3-2.3:使用 AutoRenderer 渲染的 spec key 集合 */
|
|
1038
|
+
private autoRenderedKeys;
|
|
1039
|
+
setChart(chart: IChartApi): void;
|
|
1040
|
+
setSeriesManager(sm: SeriesManager): void;
|
|
1041
|
+
/**
|
|
1042
|
+
* @deprecated 不再需要独立的paneChart,副图使用LWC v5原生pane
|
|
1043
|
+
*/
|
|
1044
|
+
setPaneChart(_chart: IChartApi): void;
|
|
1045
|
+
/**
|
|
1046
|
+
* 渲染指标(双模式)
|
|
1047
|
+
* - 有 config.renderSpec → 使用 AutoIndicatorRenderer(数据驱动)
|
|
1048
|
+
* - 无 spec → fallback 到 switch-case
|
|
1049
|
+
* @returns 渲染后创建的 seriesIds
|
|
1050
|
+
*/
|
|
1051
|
+
renderIndicator(config: IndicatorConfig & {
|
|
1052
|
+
renderSpec?: IndicatorRenderSpec;
|
|
1053
|
+
}, data: IndicatorDataPoint[]): string[];
|
|
1054
|
+
/**
|
|
1055
|
+
* 分配pane索引(同一指标复用同一pane)
|
|
1056
|
+
*/
|
|
1057
|
+
private allocPaneIndex;
|
|
1058
|
+
/**
|
|
1059
|
+
* ★ V5 需求3:设置pane拉伸比例(使用 LWC v5 setStretchFactor)
|
|
1060
|
+
* 主图保持大比例,副图保持小比例,确保时间轴有空间
|
|
1061
|
+
*/
|
|
1062
|
+
private setPaneHeight;
|
|
1063
|
+
/**
|
|
1064
|
+
* 更新指标(移除旧的,重新渲染)
|
|
1065
|
+
*/
|
|
1066
|
+
updateIndicator(config: IndicatorConfig, data: IndicatorDataPoint[]): string[];
|
|
1067
|
+
/**
|
|
1068
|
+
* 移除指标
|
|
1069
|
+
*/
|
|
1070
|
+
removeIndicator(indicatorId: string): void;
|
|
1071
|
+
/**
|
|
1072
|
+
* 获取已渲染的指标ID列表
|
|
1073
|
+
*/
|
|
1074
|
+
getRenderedIndicatorIds(): string[];
|
|
1075
|
+
/**
|
|
1076
|
+
* 清理所有渲染的指标
|
|
1077
|
+
*/
|
|
1078
|
+
clearAll(): void;
|
|
1079
|
+
/**
|
|
1080
|
+
* ★ V2: 获取指定 pane 的代表 series
|
|
1081
|
+
*/
|
|
1082
|
+
getPaneSeries(paneIndex: number): ISeriesApi<any> | null;
|
|
1083
|
+
/**
|
|
1084
|
+
* ★ V2: 根据 series 反查 paneIndex
|
|
1085
|
+
*/
|
|
1086
|
+
getPaneIndexBySeries(series: ISeriesApi<any>): number;
|
|
1087
|
+
/**
|
|
1088
|
+
* ★ V5 需求1: 根据指标ID获取 paneIndex
|
|
1089
|
+
*/
|
|
1090
|
+
getPaneIndexByIndicatorId(indicatorId: string): number;
|
|
1091
|
+
/**
|
|
1092
|
+
* ★ V2: 获取所有已注册的 pane 信息
|
|
1093
|
+
*/
|
|
1094
|
+
getRegisteredPanes(): Array<{
|
|
1095
|
+
paneIndex: number;
|
|
1096
|
+
hasSeries: boolean;
|
|
1097
|
+
}>;
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
/** 指标渲染描述(后端返回,前端自动渲染) */
|
|
1101
|
+
declare interface IndicatorRenderSpec {
|
|
1102
|
+
/** 指标唯一key */
|
|
1103
|
+
key: string;
|
|
1104
|
+
/** 显示名称 */
|
|
1105
|
+
label: string;
|
|
1106
|
+
/** 渲染位置 */
|
|
1107
|
+
placement: 'overlay' | 'pane';
|
|
1108
|
+
/** 副图高度比例(仅pane,默认0.2) */
|
|
1109
|
+
paneHeightRatio?: number;
|
|
1110
|
+
/** 线条定义 */
|
|
1111
|
+
lines: IndicatorLineSpec[];
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
/** 指标搜索查询参数 */
|
|
1115
|
+
declare interface IndicatorSearchQuery {
|
|
1116
|
+
keyword?: string;
|
|
1117
|
+
category?: string;
|
|
1118
|
+
displayType?: 'overlay' | 'pane';
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
export declare interface IndicatorState {
|
|
1122
|
+
/** 当前活跃的指标 */
|
|
1123
|
+
activeIndicators: IndicatorConfig[];
|
|
1124
|
+
/** 可用指标列表 */
|
|
1125
|
+
availableIndicators: IndicatorDefinition[];
|
|
1126
|
+
/** 指标数据缓存 name → data */
|
|
1127
|
+
indicatorDataCache: Record<string, IndicatorDataResponse>;
|
|
1128
|
+
/** 添加指标 */
|
|
1129
|
+
addIndicator: (config: IndicatorConfig) => void;
|
|
1130
|
+
/** 移除指标 */
|
|
1131
|
+
removeIndicator: (id: string) => void;
|
|
1132
|
+
/** 切换指标可见性 */
|
|
1133
|
+
toggleIndicator: (id: string) => void;
|
|
1134
|
+
/** 更新指标参数 */
|
|
1135
|
+
updateIndicatorParams: (id: string, params: Record<string, number>) => void;
|
|
1136
|
+
/** 设置指标数据 */
|
|
1137
|
+
setIndicatorData: (name: string, data: IndicatorDataResponse) => void;
|
|
1138
|
+
/** 清理所有 */
|
|
1139
|
+
clearAll: () => void;
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
/** 指标标签 - 显示指标名+当前值+配置按钮 */
|
|
1143
|
+
export declare function IndicatorTag({ config }: IndicatorTagProps): JSX_2.Element;
|
|
1144
|
+
|
|
1145
|
+
export declare interface IndicatorTagProps {
|
|
1146
|
+
config: IndicatorConfig;
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
/**
|
|
1150
|
+
* 后端返回的指标列表项模板
|
|
1151
|
+
*/
|
|
1152
|
+
declare interface IndicatorTemplate {
|
|
1153
|
+
/** 指标唯一标识 */
|
|
1154
|
+
key: string;
|
|
1155
|
+
/** 显示名称 */
|
|
1156
|
+
label: string;
|
|
1157
|
+
/** 简短描述 */
|
|
1158
|
+
description: string;
|
|
1159
|
+
/** 显示类型 */
|
|
1160
|
+
displayType: IndicatorDisplayType;
|
|
1161
|
+
/** 分类(如 '趋势', '震荡', '成交量', '通道') */
|
|
1162
|
+
category: string;
|
|
1163
|
+
/** 默认参数 */
|
|
1164
|
+
defaultParams: Record<string, number>;
|
|
1165
|
+
/** 参数定义(用户可调整) */
|
|
1166
|
+
paramDefs: IndicatorParamDef[];
|
|
1167
|
+
/** 包含的线条定义 */
|
|
1168
|
+
lines: IndicatorLineDef[];
|
|
1169
|
+
/** 默认副图高度比例(仅pane类型) */
|
|
1170
|
+
paneHeightRatio?: number;
|
|
1171
|
+
/** 是否内置(vs自定义) */
|
|
1172
|
+
builtin: boolean;
|
|
1173
|
+
/** 图标(emoji或CSS class) */
|
|
1174
|
+
icon?: string;
|
|
1175
|
+
/** 排序权重 */
|
|
1176
|
+
sortOrder?: number;
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
/** 指标显示类型 */
|
|
1180
|
+
export declare enum IndicatorType {
|
|
1181
|
+
Overlay = "overlay",// 主图叠加
|
|
1182
|
+
Pane = "pane"
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
/** K线回放引擎 */
|
|
1186
|
+
export declare class KlineReplay {
|
|
1187
|
+
private allData;
|
|
1188
|
+
private currentIndex;
|
|
1189
|
+
private timerId;
|
|
1190
|
+
private speed;
|
|
1191
|
+
private series;
|
|
1192
|
+
private onProgress;
|
|
1193
|
+
/** 绑定序列 */
|
|
1194
|
+
attach(series: ISeriesApi<SeriesType_2>): void;
|
|
1195
|
+
/** 设置进度回调 */
|
|
1196
|
+
setOnProgress(cb: (current: number, total: number) => void): void;
|
|
1197
|
+
/** 加载全部K线数据(回放前调用) */
|
|
1198
|
+
load(data: any[]): void;
|
|
1199
|
+
/** 开始回放:从第一根开始逐根播放 */
|
|
1200
|
+
play(): void;
|
|
1201
|
+
/** 暂停回放 */
|
|
1202
|
+
pause(): void;
|
|
1203
|
+
/** 继续回放 */
|
|
1204
|
+
resume(): void;
|
|
1205
|
+
/** 停止回放并恢复全部数据 */
|
|
1206
|
+
stop(): void;
|
|
1207
|
+
/** 手动步进到下一根 */
|
|
1208
|
+
next(): void;
|
|
1209
|
+
/** 手动步进到上一根 */
|
|
1210
|
+
prev(): void;
|
|
1211
|
+
/** 跳转到指定索引位置 */
|
|
1212
|
+
goto(index: number): void;
|
|
1213
|
+
/** 设置播放速度 */
|
|
1214
|
+
setSpeed(ms: number): void;
|
|
1215
|
+
/** 获取当前进度 */
|
|
1216
|
+
getProgress(): {
|
|
1217
|
+
current: number;
|
|
1218
|
+
total: number;
|
|
1219
|
+
};
|
|
1220
|
+
/** 是否正在播放 */
|
|
1221
|
+
get isPlaying(): boolean;
|
|
1222
|
+
/** 销毁,清理定时器 */
|
|
1223
|
+
dispose(): void;
|
|
1224
|
+
private startTimer;
|
|
1225
|
+
private clearTimer;
|
|
1226
|
+
private emitProgress;
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
/** K线回放选项 */
|
|
1230
|
+
export declare interface KlineReplayOptions {
|
|
1231
|
+
/** 每根K线的间隔时间(ms),默认 1000 */
|
|
1232
|
+
speed: number;
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
export declare function KlineTypeSelector({ activeType }: KlineTypeSelectorProps): JSX_2.Element;
|
|
1236
|
+
|
|
1237
|
+
declare interface KlineTypeSelectorProps {
|
|
1238
|
+
activeType: SeriesType;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
/** 布局模式:单图、水平双屏、垂直双屏、四分屏 */
|
|
1242
|
+
export declare type LayoutMode = '1' | '2h' | '2v' | '4';
|
|
1243
|
+
|
|
1244
|
+
export declare function LayoutSwitcher({ currentMode, onModeChange }: LayoutSwitcherProps): JSX_2.Element;
|
|
1245
|
+
|
|
1246
|
+
export declare interface LayoutSwitcherProps {
|
|
1247
|
+
currentMode?: LayoutMode;
|
|
1248
|
+
onModeChange?: (mode: LayoutMode) => void;
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
export declare const lightPreset: ThemeConfig;
|
|
1252
|
+
|
|
1253
|
+
/** LWC 线数据 */
|
|
1254
|
+
export declare interface LineData {
|
|
1255
|
+
time: number;
|
|
1256
|
+
value: number;
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
/**
|
|
1260
|
+
* 从库的 tool type 映射回我们的 DrawingToolType
|
|
1261
|
+
*/
|
|
1262
|
+
export declare function mapLibTypeToOurs(libType: string): DrawingToolType | null;
|
|
1263
|
+
|
|
1264
|
+
/**
|
|
1265
|
+
* 工具类型映射:将我们的 DrawingToolType 映射到库的 tool type string
|
|
1266
|
+
* 注意:fib-fan 在库中是 fib-speed-fan
|
|
1267
|
+
*/
|
|
1268
|
+
export declare function mapToolTypeToLib(type: DrawingToolType): string | null;
|
|
1269
|
+
|
|
1270
|
+
export declare const MARKET_PRESETS: Record<string, Partial<MockDataConfig>>;
|
|
1271
|
+
|
|
1272
|
+
/** 行情趋势类型 */
|
|
1273
|
+
export declare type MarketTrend = 'up' | 'down' | 'side' | 'v-reverse' | 'random';
|
|
1274
|
+
|
|
1275
|
+
/** Mock数据生成配置 */
|
|
1276
|
+
export declare interface MockDataConfig {
|
|
1277
|
+
period: string;
|
|
1278
|
+
count: number;
|
|
1279
|
+
startPrice: number;
|
|
1280
|
+
trend: MarketTrend;
|
|
1281
|
+
volatility: number;
|
|
1282
|
+
volumeRange: [number, number];
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
export declare class MockDataService {
|
|
1286
|
+
/**
|
|
1287
|
+
* 生成K线数据
|
|
1288
|
+
* 基于几何布朗运动模型(GBM)
|
|
1289
|
+
*/
|
|
1290
|
+
static generateCandlesticks(config: MockDataConfig): CandlestickRawData[];
|
|
1291
|
+
private static getTrendFactor;
|
|
1292
|
+
static generateBullMarket(count?: number): CandlestickRawData[];
|
|
1293
|
+
static generateBearMarket(count?: number): CandlestickRawData[];
|
|
1294
|
+
static generateSideways(count?: number): CandlestickRawData[];
|
|
1295
|
+
static generateVShape(count?: number): CandlestickRawData[];
|
|
1296
|
+
static generateRandom(count?: number): CandlestickRawData[];
|
|
1297
|
+
/**
|
|
1298
|
+
* 创建可作为QLChartProvider.fetchFn使用的Mock函数
|
|
1299
|
+
* 这是连接Mock数据与QLChart组件的桥梁
|
|
1300
|
+
*/
|
|
1301
|
+
static createMockFetchFn(defaultConfig?: Partial<MockDataConfig>): FetchFn;
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
export declare interface MockIndicatorConfig {
|
|
1305
|
+
name: string;
|
|
1306
|
+
count: number;
|
|
1307
|
+
baseTime?: number;
|
|
1308
|
+
interval?: number;
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
export declare class MockIndicatorService {
|
|
1312
|
+
static generate(config: MockIndicatorConfig): IndicatorDataPoint[];
|
|
1313
|
+
static generateMultiple(names: string[], count: number, baseTime?: number, interval?: number): Record<string, IndicatorDataPoint[]>;
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
/**
|
|
1317
|
+
* OverlayIndicator - 主图叠加指标渲染
|
|
1318
|
+
* MA, EMA, BOLL 等
|
|
1319
|
+
*/
|
|
1320
|
+
export declare class OverlayIndicator {
|
|
1321
|
+
/**
|
|
1322
|
+
* 渲染 MA 指标
|
|
1323
|
+
* @returns seriesId[]
|
|
1324
|
+
*/
|
|
1325
|
+
static renderMA(seriesManager: SeriesManager, data: IndicatorDataPoint[], color?: string): string[];
|
|
1326
|
+
/**
|
|
1327
|
+
* 渲染 EMA 指标
|
|
1328
|
+
*/
|
|
1329
|
+
static renderEMA(seriesManager: SeriesManager, data: IndicatorDataPoint[], color?: string): string[];
|
|
1330
|
+
/**
|
|
1331
|
+
* 渲染 BOLL 布林带(3条线)
|
|
1332
|
+
*/
|
|
1333
|
+
static renderBOLL(seriesManager: SeriesManager, data: IndicatorDataPoint[], colors?: string[]): string[];
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
export declare const PAIR_PRESETS: Record<string, Partial<MockDataConfig>>;
|
|
1337
|
+
|
|
1338
|
+
/** 交易对信息 */
|
|
1339
|
+
export declare interface PairInfo {
|
|
1340
|
+
pairId: string;
|
|
1341
|
+
product: string;
|
|
1342
|
+
name: string;
|
|
1343
|
+
decimals: number;
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
/**
|
|
1347
|
+
* PaneIndicator - 副图指标渲染(LWC v5原生pane系统)
|
|
1348
|
+
*
|
|
1349
|
+
* 使用 chart.addSeries(def, options, paneIndex) 将series添加到指定pane
|
|
1350
|
+
* 不再需要独立的PaneChartPanel
|
|
1351
|
+
*/
|
|
1352
|
+
export declare class PaneIndicator {
|
|
1353
|
+
/**
|
|
1354
|
+
* 在指定pane中渲染指标线
|
|
1355
|
+
* @returns 创建的series引用列表
|
|
1356
|
+
*/
|
|
1357
|
+
static render(chart: IChartApi, paneIndex: number, lines: PaneLineData[], priceScaleId?: string): Array<{
|
|
1358
|
+
id: string;
|
|
1359
|
+
series: ISeriesApi<any>;
|
|
1360
|
+
}>;
|
|
1361
|
+
/**
|
|
1362
|
+
* 渲染 MACD(2条线 + 1个柱状图)
|
|
1363
|
+
*/
|
|
1364
|
+
static renderMACD(chart: IChartApi, paneIndex: number, data: Array<{
|
|
1365
|
+
time: UTCTimestamp;
|
|
1366
|
+
value: number;
|
|
1367
|
+
}>[], colors?: string[]): Array<{
|
|
1368
|
+
id: string;
|
|
1369
|
+
series: ISeriesApi<any>;
|
|
1370
|
+
}>;
|
|
1371
|
+
/**
|
|
1372
|
+
* 渲染 RSI
|
|
1373
|
+
*/
|
|
1374
|
+
static renderRSI(chart: IChartApi, paneIndex: number, data: Array<{
|
|
1375
|
+
time: UTCTimestamp;
|
|
1376
|
+
value: number;
|
|
1377
|
+
}>, color?: string): Array<{
|
|
1378
|
+
id: string;
|
|
1379
|
+
series: ISeriesApi<any>;
|
|
1380
|
+
}>;
|
|
1381
|
+
/**
|
|
1382
|
+
* 渲染 KDJ(3条线)
|
|
1383
|
+
*/
|
|
1384
|
+
static renderKDJ(chart: IChartApi, paneIndex: number, data: Array<{
|
|
1385
|
+
time: UTCTimestamp;
|
|
1386
|
+
value: number;
|
|
1387
|
+
}>[], colors?: string[]): Array<{
|
|
1388
|
+
id: string;
|
|
1389
|
+
series: ISeriesApi<any>;
|
|
1390
|
+
}>;
|
|
1391
|
+
/**
|
|
1392
|
+
* 渲染 CCI
|
|
1393
|
+
*/
|
|
1394
|
+
static renderCCI(chart: IChartApi, paneIndex: number, data: Array<{
|
|
1395
|
+
time: UTCTimestamp;
|
|
1396
|
+
value: number;
|
|
1397
|
+
}>, color?: string): Array<{
|
|
1398
|
+
id: string;
|
|
1399
|
+
series: ISeriesApi<any>;
|
|
1400
|
+
}>;
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
/** 面板信息 */
|
|
1404
|
+
export declare interface PaneInfo {
|
|
1405
|
+
index: number;
|
|
1406
|
+
heightPercent: number;
|
|
1407
|
+
seriesIds: string[];
|
|
1408
|
+
label: string;
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
/** 面板配置 */
|
|
1412
|
+
export declare interface PanelConfig {
|
|
1413
|
+
id: string;
|
|
1414
|
+
pairId: string;
|
|
1415
|
+
product: string;
|
|
1416
|
+
period: string;
|
|
1417
|
+
seriesType: SeriesType;
|
|
1418
|
+
showToolbar: boolean;
|
|
1419
|
+
weight?: number;
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
/** 副图指标线数据 */
|
|
1423
|
+
declare interface PaneLineData {
|
|
1424
|
+
key: string;
|
|
1425
|
+
label: string;
|
|
1426
|
+
data: Array<{
|
|
1427
|
+
time: UTCTimestamp;
|
|
1428
|
+
value: number;
|
|
1429
|
+
}>;
|
|
1430
|
+
renderType: 'line' | 'histogram' | 'area';
|
|
1431
|
+
color: string;
|
|
1432
|
+
lineWidth?: number;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
/**
|
|
1436
|
+
* 多面板管理器
|
|
1437
|
+
* 管理 LWC v5 的 pane 系统,用于副图指标
|
|
1438
|
+
*/
|
|
1439
|
+
export declare class PaneManager {
|
|
1440
|
+
private chart;
|
|
1441
|
+
private eventManager;
|
|
1442
|
+
private panes;
|
|
1443
|
+
private nextPaneIndex;
|
|
1444
|
+
constructor(eventManager: EventManager);
|
|
1445
|
+
/** 设置图表实例 */
|
|
1446
|
+
setChart(chart: IChartApi): void;
|
|
1447
|
+
/** 获取主图 pane 信息 */
|
|
1448
|
+
getMainPane(): PaneInfo;
|
|
1449
|
+
/**
|
|
1450
|
+
* 添加成交量叠加层
|
|
1451
|
+
* 在主图底部用 HistogramSeries + priceScaleMargins 实现
|
|
1452
|
+
*/
|
|
1453
|
+
addVolumeOverlay(heightPercent?: number): ISeriesApi<SeriesType_2> | null;
|
|
1454
|
+
/**
|
|
1455
|
+
* 添加指标面板(副图)
|
|
1456
|
+
* 使用独立的 priceScaleId 创建新 pane
|
|
1457
|
+
*/
|
|
1458
|
+
addIndicatorPane(indicatorName: string, heightPercent?: number): string;
|
|
1459
|
+
/** 移除面板 */
|
|
1460
|
+
removePane(paneIndex: number): void;
|
|
1461
|
+
/** 设置面板高度 */
|
|
1462
|
+
setPaneHeight(paneIndex: number, heightPercent: number): void;
|
|
1463
|
+
/** 获取所有面板 */
|
|
1464
|
+
getPanes(): PaneInfo[];
|
|
1465
|
+
/** 根据 priceScaleId 获取面板信息 */
|
|
1466
|
+
getPaneByIndex(index: number): PaneInfo | undefined;
|
|
1467
|
+
/** 清理所有面板 */
|
|
1468
|
+
dispose(): void;
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
export declare function PeriodSelector({ activePeriod }: PeriodSelectorProps): JSX_2.Element;
|
|
1472
|
+
|
|
1473
|
+
declare interface PeriodSelectorProps {
|
|
1474
|
+
activePeriod: string;
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
/** 持久化配置 */
|
|
1478
|
+
export declare interface PersistenceConfig {
|
|
1479
|
+
/** 交易对ID(核心标识) */
|
|
1480
|
+
pairId: string;
|
|
1481
|
+
/** 产品类型 */
|
|
1482
|
+
product: string;
|
|
1483
|
+
/** 周期(保留用于UI层,不参与持久化key) */
|
|
1484
|
+
period?: string;
|
|
1485
|
+
/** 图表实例ID(保留用于内部标识,不参与持久化key) */
|
|
1486
|
+
chartId?: string;
|
|
1487
|
+
/** API基础URL,有值则使用远程模式 */
|
|
1488
|
+
apiBaseUrl?: string;
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
/** QLChart 配置 */
|
|
1492
|
+
export declare interface QLChartConfig {
|
|
1493
|
+
/** API基础URL */
|
|
1494
|
+
apiBaseUrl?: string;
|
|
1495
|
+
/** 默认主题 */
|
|
1496
|
+
defaultTheme?: ThemePreset;
|
|
1497
|
+
/** 默认周期 */
|
|
1498
|
+
defaultPeriod?: string;
|
|
1499
|
+
/** 默认序列类型 */
|
|
1500
|
+
defaultSeriesType?: SeriesType;
|
|
1501
|
+
/** 数据获取函数 */
|
|
1502
|
+
fetchFn?: (params: Record<string, unknown>) => Promise<unknown>;
|
|
1503
|
+
/** ★ Req1:是否启用数据缓存(默认true) */
|
|
1504
|
+
cacheEnabled?: boolean;
|
|
1505
|
+
/** ★ Req1:缓存TTL(毫秒,默认300000 = 5分钟) */
|
|
1506
|
+
cacheTTL?: number;
|
|
1507
|
+
/** ★ Req1:实时数据订阅(WebSocket场景) */
|
|
1508
|
+
realtimeSubscribe?: RealtimeSubscribeFn;
|
|
1509
|
+
/** 指标列表查询函数(注入式,未注入时 fallback 到 BUILTIN_INDICATORS) */
|
|
1510
|
+
indicatorListFn?: () => Promise<IndicatorListResponse>;
|
|
1511
|
+
/** 指标搜索函数(注入式,用于指标面板搜索) */
|
|
1512
|
+
indicatorSearchFn?: (query: IndicatorSearchQuery) => Promise<IndicatorTemplate[]>;
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
export declare function QLChartLayout({ mode: modeProp, panels: panelsProp, crosshairSync, onLayoutChange, }: QLChartLayoutProps): JSX_2.Element;
|
|
1516
|
+
|
|
1517
|
+
export declare interface QLChartLayoutProps {
|
|
1518
|
+
/** 布局模式 */
|
|
1519
|
+
mode?: LayoutMode;
|
|
1520
|
+
/** 面板配置 */
|
|
1521
|
+
panels?: PanelConfig[];
|
|
1522
|
+
/** 是否开启光标联动 */
|
|
1523
|
+
crosshairSync?: boolean;
|
|
1524
|
+
/** 布局变化回调 */
|
|
1525
|
+
onLayoutChange?: (mode: LayoutMode) => void;
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
export declare const QLChartPanel: ForwardRefExoticComponent<QLChartPanelProps & RefAttributes<QLChartPanelRef>>;
|
|
1529
|
+
|
|
1530
|
+
export declare interface QLChartPanelProps {
|
|
1531
|
+
pairId: string;
|
|
1532
|
+
product: string;
|
|
1533
|
+
period?: string;
|
|
1534
|
+
seriesType?: SeriesType;
|
|
1535
|
+
showToolbar?: boolean;
|
|
1536
|
+
panelId?: string;
|
|
1537
|
+
panelIndex?: number;
|
|
1538
|
+
onChartCreated?: (chart: IChartApi | null, index: number) => void;
|
|
1539
|
+
/** chart 和 series 就绪回调 */
|
|
1540
|
+
onChartReady?: (chart: IChartApi | null, mainSeries: ISeriesApi<SeriesType_2> | null) => void;
|
|
1541
|
+
/** 是否为单面板模式(控制绘图UI渲染位置) */
|
|
1542
|
+
isSinglePanel?: boolean;
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
/** ★ Req1:QLChartPanel 暴露的命令式API */
|
|
1546
|
+
export declare interface QLChartPanelRef {
|
|
1547
|
+
/** 推送实时K线数据(增量更新) */
|
|
1548
|
+
pushRealtimeData: (data: RealtimeCandle) => void;
|
|
1549
|
+
/** 批量推送实时数据 */
|
|
1550
|
+
pushRealtimeBatch: (datas: RealtimeCandle[]) => void;
|
|
1551
|
+
/** 重载数据 */
|
|
1552
|
+
reload: () => void;
|
|
1553
|
+
/** 获取chart实例 */
|
|
1554
|
+
getChart: () => IChartApi | null;
|
|
1555
|
+
/** 获取主序列 */
|
|
1556
|
+
getMainSeries: () => ISeriesApi<SeriesType_2> | null;
|
|
1557
|
+
/** 清除缓存 */
|
|
1558
|
+
clearCache: () => void;
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
/** 配置Provider
|
|
1562
|
+
*
|
|
1563
|
+
* 支持两种使用方式:
|
|
1564
|
+
* 1. 散装属性(推荐):`<QLChartProvider fetchFn={fn} cacheEnabled />`
|
|
1565
|
+
* 2. config对象(向后兼容):`<QLChartProvider config={{ fetchFn: fn }} />`
|
|
1566
|
+
*/
|
|
1567
|
+
export declare function QLChartProvider({ config, children, ...restProps }: {
|
|
1568
|
+
config?: QLChartConfig;
|
|
1569
|
+
children: ReactNode;
|
|
1570
|
+
} & Partial<QLChartConfig>): JSX_2.Element;
|
|
1571
|
+
|
|
1572
|
+
export declare function QLToolbar({ period, seriesType, theme, chartManager, chartRef, containerRef }: QLToolbarProps): JSX_2.Element;
|
|
1573
|
+
|
|
1574
|
+
export declare interface QLToolbarProps {
|
|
1575
|
+
period: string;
|
|
1576
|
+
seriesType: SeriesType;
|
|
1577
|
+
theme: ThemePreset;
|
|
1578
|
+
chartManager?: {
|
|
1579
|
+
getChart: () => any;
|
|
1580
|
+
} | null;
|
|
1581
|
+
chartRef?: React.RefObject<any>;
|
|
1582
|
+
containerRef?: React.RefObject<HTMLElement>;
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
/**
|
|
1586
|
+
* 实时K线数据格式(秒级时间戳,与LWC对齐)
|
|
1587
|
+
*/
|
|
1588
|
+
export declare interface RealtimeCandle {
|
|
1589
|
+
/** K线时间戳(秒级,与LWC一致) */
|
|
1590
|
+
time: number;
|
|
1591
|
+
open: number;
|
|
1592
|
+
high: number;
|
|
1593
|
+
low: number;
|
|
1594
|
+
close: number;
|
|
1595
|
+
volume?: number;
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
/** ★ Req1:实时K线数据格式(秒级时间戳,与LWC一致) */
|
|
1599
|
+
declare interface RealtimeCandle_2 {
|
|
1600
|
+
time: number;
|
|
1601
|
+
open: number;
|
|
1602
|
+
high: number;
|
|
1603
|
+
low: number;
|
|
1604
|
+
close: number;
|
|
1605
|
+
volume?: number;
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
/**
|
|
1609
|
+
* 实时数据馈送管理器
|
|
1610
|
+
*
|
|
1611
|
+
* 接收外部推送的增量K线数据,通过 LWC 的 series.update() 实时更新图表。
|
|
1612
|
+
*
|
|
1613
|
+
* LWC update() 自动判断:
|
|
1614
|
+
* - time === 最新K线time → 更新该K线
|
|
1615
|
+
* - time > 最新K线time → 追加新K线
|
|
1616
|
+
* - time < 最新K线time → 忽略
|
|
1617
|
+
*/
|
|
1618
|
+
export declare class RealtimeDataFeed {
|
|
1619
|
+
private mainSeries;
|
|
1620
|
+
private volumeSeries;
|
|
1621
|
+
private lastTime;
|
|
1622
|
+
/**
|
|
1623
|
+
* 绑定到图表序列
|
|
1624
|
+
*/
|
|
1625
|
+
attach(mainSeries: ISeriesApi<SeriesType_2>, volumeSeries?: ISeriesApi<SeriesType_2> | null): void;
|
|
1626
|
+
/**
|
|
1627
|
+
* 解绑
|
|
1628
|
+
*/
|
|
1629
|
+
detach(): void;
|
|
1630
|
+
/**
|
|
1631
|
+
* 推送单条增量数据
|
|
1632
|
+
*/
|
|
1633
|
+
push(data: RealtimeCandle): void;
|
|
1634
|
+
/**
|
|
1635
|
+
* 批量推送
|
|
1636
|
+
*/
|
|
1637
|
+
pushBatch(datas: RealtimeCandle[]): void;
|
|
1638
|
+
/**
|
|
1639
|
+
* 获取最后推送的time
|
|
1640
|
+
*/
|
|
1641
|
+
getLastTime(): number;
|
|
1642
|
+
/**
|
|
1643
|
+
* 更新绑定的series引用(chart重建后调用)
|
|
1644
|
+
*/
|
|
1645
|
+
updateSeries(mainSeries: ISeriesApi<SeriesType_2>, volumeSeries?: ISeriesApi<SeriesType_2> | null): void;
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
/** ★ Req1:实时数据订阅函数 */
|
|
1649
|
+
export declare interface RealtimeSubscribeFn {
|
|
1650
|
+
(params: {
|
|
1651
|
+
pairId: string;
|
|
1652
|
+
product: string;
|
|
1653
|
+
period: string;
|
|
1654
|
+
onUpdate: (data: RealtimeCandle_2) => void;
|
|
1655
|
+
}): (() => void) | void;
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
/** 砖形图数据(后端提供) */
|
|
1659
|
+
export declare interface RenkoData extends CustomData {
|
|
1660
|
+
/** 砖块开盘价 */
|
|
1661
|
+
open: number;
|
|
1662
|
+
/** 砖块收盘价 */
|
|
1663
|
+
close: number;
|
|
1664
|
+
/** 方向 */
|
|
1665
|
+
type: 'up' | 'down';
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
/** 砖形图 PaneView */
|
|
1669
|
+
export declare class RenkoSeries implements ICustomSeriesPaneView<unknown, RenkoData, CustomSeriesOptions> {
|
|
1670
|
+
private _renderer;
|
|
1671
|
+
defaultOptions(): CustomSeriesOptions;
|
|
1672
|
+
renderer(): ICustomSeriesPaneRenderer;
|
|
1673
|
+
update(data: PaneRendererCustomData<unknown, RenkoData>, _seriesOptions: CustomSeriesOptions): void;
|
|
1674
|
+
priceValueBuilder(plotRow: RenkoData): CustomSeriesPricePlotValues;
|
|
1675
|
+
isWhitespace(data: RenkoData | CustomSeriesWhitespaceData<unknown>): data is CustomSeriesWhitespaceData<unknown>;
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
export declare function ReplayController({ replay }: ReplayControllerProps): JSX_2.Element | null;
|
|
1679
|
+
|
|
1680
|
+
export declare interface ReplayControllerProps {
|
|
1681
|
+
replay: KlineReplay | null;
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
export declare interface ReplayState {
|
|
1685
|
+
/** 是否处于回放模式 */
|
|
1686
|
+
isReplayMode: boolean;
|
|
1687
|
+
/** 是否正在播放 */
|
|
1688
|
+
isPlaying: boolean;
|
|
1689
|
+
/** 播放速度 ms/根 */
|
|
1690
|
+
speed: number;
|
|
1691
|
+
/** 进度 */
|
|
1692
|
+
progress: {
|
|
1693
|
+
current: number;
|
|
1694
|
+
total: number;
|
|
1695
|
+
};
|
|
1696
|
+
/** 进入回放模式 */
|
|
1697
|
+
enterReplay: () => void;
|
|
1698
|
+
/** 退出回放模式 */
|
|
1699
|
+
exitReplay: () => void;
|
|
1700
|
+
/** 设置播放状态 */
|
|
1701
|
+
setPlaying: (playing: boolean) => void;
|
|
1702
|
+
/** 设置速度 */
|
|
1703
|
+
setSpeed: (ms: number) => void;
|
|
1704
|
+
/** 设置进度 */
|
|
1705
|
+
setProgress: (current: number, total: number) => void;
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
/**
|
|
1709
|
+
* 截图导出工具
|
|
1710
|
+
* 从 lightweight-charts v5 的 DOM 容器中获取 canvas 并导出
|
|
1711
|
+
*/
|
|
1712
|
+
export declare class ScreenshotUtil {
|
|
1713
|
+
/**
|
|
1714
|
+
* 从 chart 实例获取 canvas 元素
|
|
1715
|
+
* lightweight-charts v5 没有 takeScreenshot(),需要从 DOM 获取
|
|
1716
|
+
*/
|
|
1717
|
+
private static getChartCanvas;
|
|
1718
|
+
/**
|
|
1719
|
+
* 从 chart 容器 DOM 获取所有 canvas 并合并
|
|
1720
|
+
*/
|
|
1721
|
+
private static getCanvasFromContainer;
|
|
1722
|
+
/**
|
|
1723
|
+
* 截取图表为 PNG base64 data URL
|
|
1724
|
+
*/
|
|
1725
|
+
static toPng(chart: IChartApi, container?: HTMLElement): string;
|
|
1726
|
+
/**
|
|
1727
|
+
* 截取并下载为 PNG 文件
|
|
1728
|
+
*/
|
|
1729
|
+
static download(chart: IChartApi, container?: HTMLElement, filename?: string): void;
|
|
1730
|
+
/**
|
|
1731
|
+
* 截取并复制到剪贴板
|
|
1732
|
+
*/
|
|
1733
|
+
static copyToClipboard(chart: IChartApi, container?: HTMLElement): Promise<boolean>;
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
/**
|
|
1737
|
+
* 序列管理器
|
|
1738
|
+
* 管理图表上所有的序列(K线、指标、成交量等)
|
|
1739
|
+
*/
|
|
1740
|
+
export declare class SeriesManager {
|
|
1741
|
+
private seriesMap;
|
|
1742
|
+
private chart;
|
|
1743
|
+
private eventManager;
|
|
1744
|
+
constructor(chart: IChartApi, eventManager: EventManager);
|
|
1745
|
+
/** 更新chart实例(chart重建时调用) */
|
|
1746
|
+
setChart(chart: IChartApi): void;
|
|
1747
|
+
/** 添加主序列(K线等) */
|
|
1748
|
+
addMainSeries(type: SeriesType, options?: Record<string, unknown>): ISeriesApi<SeriesType_2> | null;
|
|
1749
|
+
/** 添加叠加序列(指标、成交量等) */
|
|
1750
|
+
addOverlaySeries(type: SeriesType, options?: Record<string, unknown>, priceScaleId?: string): ISeriesApi<SeriesType_2> | null;
|
|
1751
|
+
/** 设置序列数据 */
|
|
1752
|
+
setData(seriesId: string, data: unknown[]): void;
|
|
1753
|
+
/** 更新序列最新数据点 */
|
|
1754
|
+
update(seriesId: string, data: unknown): void;
|
|
1755
|
+
/** 移除序列 */
|
|
1756
|
+
removeSeries(seriesId: string): void;
|
|
1757
|
+
/** 切换序列类型 */
|
|
1758
|
+
switchType(seriesId: string, newType: SeriesType, data?: unknown[]): string | null;
|
|
1759
|
+
/** 获取序列 */
|
|
1760
|
+
getSeries(seriesId: string): ISeriesApi<SeriesType_2> | undefined;
|
|
1761
|
+
/** 获取第一个主序列(用于DrawingAdapter attach) */
|
|
1762
|
+
getFirstMainSeries(): ISeriesApi<SeriesType_2> | null;
|
|
1763
|
+
/** 获取第一个任何类型的序列 */
|
|
1764
|
+
getFirstSeries(): ISeriesApi<SeriesType_2> | null;
|
|
1765
|
+
/** 清除所有序列 */
|
|
1766
|
+
clearAll(): void;
|
|
1767
|
+
/** 添加叠加品种(对比模式) */
|
|
1768
|
+
addComparisonSeries(type: SeriesType, data: any[], options?: Record<string, unknown>): string | null;
|
|
1769
|
+
/** 移除所有对比序列 */
|
|
1770
|
+
clearComparisonSeries(): void;
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
/** 序列类型枚举 */
|
|
1774
|
+
export declare enum SeriesType {
|
|
1775
|
+
Candlestick = "candlestick",
|
|
1776
|
+
Bar = "bar",
|
|
1777
|
+
Line = "line",
|
|
1778
|
+
Area = "area",
|
|
1779
|
+
Baseline = "baseline",
|
|
1780
|
+
Histogram = "histogram",
|
|
1781
|
+
HollowCandlestick = "hollow-candlestick",
|
|
1782
|
+
VolumeCandlestick = "volume-candlestick",
|
|
1783
|
+
HeikinAshi = "heikin-ashi",
|
|
1784
|
+
Renko = "renko",
|
|
1785
|
+
LineBreak = "line-break"
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
/** 主题配置 */
|
|
1789
|
+
export declare interface ThemeConfig {
|
|
1790
|
+
name: ThemePreset;
|
|
1791
|
+
chart: ChartThemeOptions;
|
|
1792
|
+
/** 涨色 */
|
|
1793
|
+
upColor: string;
|
|
1794
|
+
/** 跌色 */
|
|
1795
|
+
downColor: string;
|
|
1796
|
+
/** 工具栏背景色 */
|
|
1797
|
+
toolbarBg: string;
|
|
1798
|
+
/** 工具栏文字色 */
|
|
1799
|
+
toolbarText: string;
|
|
1800
|
+
/** 工具栏按钮激活色 */
|
|
1801
|
+
toolbarActiveBg: string;
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
/**
|
|
1805
|
+
* 主题管理器
|
|
1806
|
+
* 管理图表主题的切换与配置
|
|
1807
|
+
*/
|
|
1808
|
+
export declare class ThemeManager {
|
|
1809
|
+
private currentTheme;
|
|
1810
|
+
private eventManager;
|
|
1811
|
+
private presets;
|
|
1812
|
+
constructor(eventManager: EventManager);
|
|
1813
|
+
/** 设置主题 */
|
|
1814
|
+
setTheme(theme: ThemePreset): void;
|
|
1815
|
+
/** 获取当前主题名称 */
|
|
1816
|
+
getCurrentTheme(): ThemePreset;
|
|
1817
|
+
/** 获取当前主题配置 */
|
|
1818
|
+
getCurrentConfig(): ThemeConfig;
|
|
1819
|
+
/** 获取映射到LWC的图表选项 */
|
|
1820
|
+
getChartOptions(theme?: ThemePreset): DeepPartial<ChartOptions_2>;
|
|
1821
|
+
/** 获取涨色 */
|
|
1822
|
+
getUpColor(): string;
|
|
1823
|
+
/** 获取跌色 */
|
|
1824
|
+
getDownColor(): string;
|
|
1825
|
+
/** 注册自定义主题预设 */
|
|
1826
|
+
registerPreset(name: ThemePreset, config: ThemeConfig): void;
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1829
|
+
/** 主题预设名称 */
|
|
1830
|
+
export declare type ThemePreset = 'dark' | 'light';
|
|
1831
|
+
|
|
1832
|
+
/**
|
|
1833
|
+
* 时间栏模块容器组件
|
|
1834
|
+
*
|
|
1835
|
+
* 通过 PanelRegistry 获取活跃面板的 chartManager,
|
|
1836
|
+
* 不再依赖 props 传递。
|
|
1837
|
+
*/
|
|
1838
|
+
export declare function TimeBarModule({ variant, className, }: TimeBarModuleProps): JSX_2.Element;
|
|
1839
|
+
|
|
1840
|
+
export declare interface TimeBarModuleProps {
|
|
1841
|
+
/** 样式变体 */
|
|
1842
|
+
variant?: 'toolbar' | 'standalone';
|
|
1843
|
+
/** 自定义 className */
|
|
1844
|
+
className?: string;
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
export declare interface TimeBarState {
|
|
1848
|
+
/** 当前选中的快捷范围标签 */
|
|
1849
|
+
activeRangeLabel: string | null;
|
|
1850
|
+
/** 自定义起始日期 */
|
|
1851
|
+
customStartDate: string;
|
|
1852
|
+
/** 自定义结束日期 */
|
|
1853
|
+
customEndDate: string;
|
|
1854
|
+
/** 是否显示日期选择器 */
|
|
1855
|
+
showDatePicker: boolean;
|
|
1856
|
+
setActiveRangeLabel: (label: string | null) => void;
|
|
1857
|
+
setCustomDateRange: (start: string, end: string) => void;
|
|
1858
|
+
setShowDatePicker: (show: boolean) => void;
|
|
1859
|
+
reset: () => void;
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1862
|
+
export declare function TimeRangeSelector({ chartManager }: TimeRangeSelectorProps): JSX_2.Element;
|
|
1863
|
+
|
|
1864
|
+
declare interface TimeRangeSelectorProps {
|
|
1865
|
+
chartManager?: {
|
|
1866
|
+
getChart: () => any;
|
|
1867
|
+
} | null;
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
/**
|
|
1871
|
+
* 将API返回的K线原始数据转换为LWC CandlestickData[]
|
|
1872
|
+
* 注意:time从毫秒转秒
|
|
1873
|
+
*/
|
|
1874
|
+
export declare function transformCandlestickData(apiData: CandlestickRawData[]): {
|
|
1875
|
+
time: UTCTimestamp;
|
|
1876
|
+
open: number;
|
|
1877
|
+
high: number;
|
|
1878
|
+
low: number;
|
|
1879
|
+
close: number;
|
|
1880
|
+
}[];
|
|
1881
|
+
|
|
1882
|
+
/**
|
|
1883
|
+
* 将API返回的指标数据转换为LWC LineData[]
|
|
1884
|
+
*/
|
|
1885
|
+
export declare function transformIndicatorData(apiData: IndicatorRawData[]): {
|
|
1886
|
+
time: UTCTimestamp;
|
|
1887
|
+
value: number;
|
|
1888
|
+
}[];
|
|
1889
|
+
|
|
1890
|
+
/**
|
|
1891
|
+
* 将API返回的K线数据转换为LWC HistogramData[](成交量)
|
|
1892
|
+
* 涨绿跌红
|
|
1893
|
+
*/
|
|
1894
|
+
export declare function transformVolumeData(apiData: CandlestickRawData[]): {
|
|
1895
|
+
time: UTCTimestamp;
|
|
1896
|
+
value: number;
|
|
1897
|
+
color: string;
|
|
1898
|
+
}[];
|
|
1899
|
+
|
|
1900
|
+
/**
|
|
1901
|
+
* 图表Hook
|
|
1902
|
+
* 创建ChartManager + SeriesManager,管理生命周期
|
|
1903
|
+
* 使用 useState 触发重渲染,确保下游 effects 能拿到非null的 managers
|
|
1904
|
+
*/
|
|
1905
|
+
export declare function useChart(): UseChartReturn;
|
|
1906
|
+
|
|
1907
|
+
export declare interface UseChartReturn {
|
|
1908
|
+
containerRef: React.RefObject<HTMLDivElement | null>;
|
|
1909
|
+
chartManager: ChartManager | null;
|
|
1910
|
+
seriesManager: SeriesManager | null;
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1913
|
+
export declare const useChartStore: UseBoundStore<StoreApi<ChartState>>;
|
|
1914
|
+
|
|
1915
|
+
/**
|
|
1916
|
+
* 多图表光标十字线联动 Hook
|
|
1917
|
+
* 监听每个 chart 的 crosshairMove 事件,同步到其他 chart
|
|
1918
|
+
*
|
|
1919
|
+
* 修复点:
|
|
1920
|
+
* 1. setCrosshairPosition 第三参数从 IChartApi 改为 ISeriesApi(通过 PanelRegistry 获取)
|
|
1921
|
+
* 2. 依赖数组增加 panelIds.join(','),面板变化时重新订阅
|
|
1922
|
+
*/
|
|
1923
|
+
export declare function useCrosshairSync(chartRefs: RefObject<(IChartApi | null)[]>, panelIds?: string[]): void;
|
|
1924
|
+
|
|
1925
|
+
export declare function useDrawingModule(options: UseDrawingModuleOptions): UseDrawingModuleReturn;
|
|
1926
|
+
|
|
1927
|
+
export declare interface UseDrawingModuleOptions {
|
|
1928
|
+
chartManager: ChartManager | null;
|
|
1929
|
+
seriesManager: SeriesManager | null;
|
|
1930
|
+
containerRef: React.RefObject<HTMLElement | null>;
|
|
1931
|
+
pairId: string;
|
|
1932
|
+
product: string;
|
|
1933
|
+
period: string;
|
|
1934
|
+
panelId?: string;
|
|
1935
|
+
panelIndex?: number;
|
|
1936
|
+
onChartCreated?: (chart: IChartApi | null, index: number) => void;
|
|
1937
|
+
dataLoaded: boolean;
|
|
1938
|
+
/** ★ V4: 指标渲染器 ref(用于副图绘图 pane 切换,实时读取避免闭包捕获) */
|
|
1939
|
+
indicatorRendererRef?: React.RefObject<IndicatorRenderer | null>;
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
export declare interface UseDrawingModuleReturn {
|
|
1943
|
+
drawingAdapterRef: React.RefObject<DrawingAdapter | null>;
|
|
1944
|
+
recentTools: DrawingToolType[];
|
|
1945
|
+
handleDrawingStyleChange: (id: string, style: Partial<DrawingStyleConfig>) => void;
|
|
1946
|
+
handleDeleteDrawing: () => void;
|
|
1947
|
+
handleContextMenuToolSelect: (tool: DrawingToolType) => void;
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
export declare const useDrawingStore: UseBoundStore<StoreApi<DrawingState>>;
|
|
1951
|
+
|
|
1952
|
+
export declare const useIndicatorStore: UseBoundStore<StoreApi<IndicatorState>>;
|
|
1953
|
+
|
|
1954
|
+
/** 获取配置 */
|
|
1955
|
+
export declare function useQLChartConfig(): QLChartConfig;
|
|
1956
|
+
|
|
1957
|
+
export declare const useReplayStore: UseBoundStore<StoreApi<ReplayState>>;
|
|
1958
|
+
|
|
1959
|
+
/**
|
|
1960
|
+
* 主题Hook
|
|
1961
|
+
*/
|
|
1962
|
+
export declare function useTheme(): UseThemeReturn;
|
|
1963
|
+
|
|
1964
|
+
export declare interface UseThemeReturn {
|
|
1965
|
+
theme: 'dark' | 'light';
|
|
1966
|
+
config: ThemeConfig;
|
|
1967
|
+
toggleTheme: () => void;
|
|
1968
|
+
setTheme: (theme: 'dark' | 'light') => void;
|
|
1969
|
+
}
|
|
1970
|
+
|
|
1971
|
+
export declare const useTimeBarStore: UseBoundStore<StoreApi<TimeBarState>>;
|
|
1972
|
+
|
|
1973
|
+
export { }
|