@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
|
@@ -0,0 +1,684 @@
|
|
|
1
|
+
import type { DrawingToolType, DrawingToolConfig } from '../../types/index.js';
|
|
2
|
+
import { DrawingToolCategory } from '../../types/index.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 绘图工具注册表
|
|
6
|
+
* 从 lightweight-charts-drawing 的 68 种工具中筛选出我们需要的 21 种
|
|
7
|
+
*/
|
|
8
|
+
export const DRAWING_TOOLS: DrawingToolConfig[] = [
|
|
9
|
+
// ── P0 必须工具 (priority: 0) ──
|
|
10
|
+
{
|
|
11
|
+
type: 'trend-line',
|
|
12
|
+
label: '趋势线',
|
|
13
|
+
icon: '📈',
|
|
14
|
+
category: DrawingToolCategory.Lines,
|
|
15
|
+
anchorCount: 2,
|
|
16
|
+
priority: 0,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
type: 'horizontal-line',
|
|
20
|
+
label: '水平线',
|
|
21
|
+
icon: '➖',
|
|
22
|
+
category: DrawingToolCategory.Lines,
|
|
23
|
+
anchorCount: 1,
|
|
24
|
+
priority: 0,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
type: 'vertical-line',
|
|
28
|
+
label: '垂直线',
|
|
29
|
+
icon: '↕️',
|
|
30
|
+
category: DrawingToolCategory.Lines,
|
|
31
|
+
anchorCount: 1,
|
|
32
|
+
priority: 0,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
type: 'ray',
|
|
36
|
+
label: '射线',
|
|
37
|
+
icon: '↗️',
|
|
38
|
+
category: DrawingToolCategory.Lines,
|
|
39
|
+
anchorCount: 2,
|
|
40
|
+
priority: 0,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: 'rectangle',
|
|
44
|
+
label: '矩形',
|
|
45
|
+
icon: '⬜',
|
|
46
|
+
category: DrawingToolCategory.Shapes,
|
|
47
|
+
anchorCount: 2,
|
|
48
|
+
priority: 0,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: 'fib-retracement',
|
|
52
|
+
label: '斐波那契回撤',
|
|
53
|
+
icon: '📐',
|
|
54
|
+
category: DrawingToolCategory.Fibonacci,
|
|
55
|
+
anchorCount: 2,
|
|
56
|
+
priority: 0,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
type: 'path',
|
|
60
|
+
label: '路径',
|
|
61
|
+
icon: '✏️',
|
|
62
|
+
category: DrawingToolCategory.Annotations,
|
|
63
|
+
anchorCount: -1, // 动态锚点
|
|
64
|
+
priority: 0,
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
// ── P1 重要工具 (priority: 1) ──
|
|
68
|
+
{
|
|
69
|
+
type: 'parallel-channel',
|
|
70
|
+
label: '平行通道',
|
|
71
|
+
icon: '📊',
|
|
72
|
+
category: DrawingToolCategory.Channels,
|
|
73
|
+
anchorCount: 3,
|
|
74
|
+
priority: 1,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
type: 'circle',
|
|
78
|
+
label: '圆形',
|
|
79
|
+
icon: '⭕',
|
|
80
|
+
category: DrawingToolCategory.Shapes,
|
|
81
|
+
anchorCount: 2,
|
|
82
|
+
priority: 1,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
type: 'ellipse',
|
|
86
|
+
label: '椭圆',
|
|
87
|
+
icon: '🔵',
|
|
88
|
+
category: DrawingToolCategory.Shapes,
|
|
89
|
+
anchorCount: 2,
|
|
90
|
+
priority: 1,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
type: 'triangle',
|
|
94
|
+
label: '三角形',
|
|
95
|
+
icon: '🔺',
|
|
96
|
+
category: DrawingToolCategory.Shapes,
|
|
97
|
+
anchorCount: 3,
|
|
98
|
+
priority: 1,
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
type: 'fib-extension',
|
|
102
|
+
label: '斐波那契扩展',
|
|
103
|
+
icon: '📏',
|
|
104
|
+
category: DrawingToolCategory.Fibonacci,
|
|
105
|
+
anchorCount: 3,
|
|
106
|
+
priority: 1,
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
type: 'arrow',
|
|
110
|
+
label: '箭头',
|
|
111
|
+
icon: '➡️',
|
|
112
|
+
category: DrawingToolCategory.Annotations,
|
|
113
|
+
anchorCount: 2,
|
|
114
|
+
priority: 1,
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
type: 'brush',
|
|
118
|
+
label: '画笔',
|
|
119
|
+
icon: '🖌️',
|
|
120
|
+
category: DrawingToolCategory.Annotations,
|
|
121
|
+
anchorCount: -1, // 动态锚点
|
|
122
|
+
priority: 1,
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
// ── P2 扩展工具 (priority: 2) ──
|
|
126
|
+
{
|
|
127
|
+
type: 'cross-line',
|
|
128
|
+
label: '十字线',
|
|
129
|
+
icon: '✚',
|
|
130
|
+
category: DrawingToolCategory.Lines,
|
|
131
|
+
anchorCount: 1,
|
|
132
|
+
priority: 2,
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
type: 'callout',
|
|
136
|
+
label: '标注',
|
|
137
|
+
icon: '💬',
|
|
138
|
+
category: DrawingToolCategory.Annotations,
|
|
139
|
+
anchorCount: 2,
|
|
140
|
+
priority: 2,
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
type: 'long-position',
|
|
144
|
+
label: '多头仓位',
|
|
145
|
+
icon: '🟢',
|
|
146
|
+
category: DrawingToolCategory.Positions,
|
|
147
|
+
anchorCount: 3,
|
|
148
|
+
priority: 2,
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
type: 'short-position',
|
|
152
|
+
label: '空头仓位',
|
|
153
|
+
icon: '🔴',
|
|
154
|
+
category: DrawingToolCategory.Positions,
|
|
155
|
+
anchorCount: 3,
|
|
156
|
+
priority: 2,
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
type: 'fib-fan',
|
|
160
|
+
label: '斐波那契扇形',
|
|
161
|
+
icon: '🌀',
|
|
162
|
+
category: DrawingToolCategory.Fibonacci,
|
|
163
|
+
anchorCount: 2,
|
|
164
|
+
priority: 2,
|
|
165
|
+
},
|
|
166
|
+
// ── 新增工具 ──
|
|
167
|
+
{
|
|
168
|
+
type: 'date-price-range',
|
|
169
|
+
label: '测量器',
|
|
170
|
+
icon: '📐',
|
|
171
|
+
category: DrawingToolCategory.Measure,
|
|
172
|
+
anchorCount: 2,
|
|
173
|
+
priority: 1,
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
type: 'fib-circles',
|
|
177
|
+
label: '斐波那契圆形',
|
|
178
|
+
icon: '🎯',
|
|
179
|
+
category: DrawingToolCategory.Fibonacci,
|
|
180
|
+
anchorCount: 2,
|
|
181
|
+
priority: 1,
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
type: 'fib-time-zone',
|
|
185
|
+
label: '斐波那契时区',
|
|
186
|
+
icon: '⏱️',
|
|
187
|
+
category: DrawingToolCategory.Fibonacci,
|
|
188
|
+
anchorCount: 2,
|
|
189
|
+
priority: 1,
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
type: 'rotated-rectangle',
|
|
193
|
+
label: '旋转矩形',
|
|
194
|
+
icon: '🔷',
|
|
195
|
+
category: DrawingToolCategory.Shapes,
|
|
196
|
+
anchorCount: 3,
|
|
197
|
+
priority: 1,
|
|
198
|
+
},
|
|
199
|
+
// ── 形态工具组 ──
|
|
200
|
+
{
|
|
201
|
+
type: 'pattern-abcd',
|
|
202
|
+
label: 'ABCD形态',
|
|
203
|
+
icon: '🔤',
|
|
204
|
+
category: DrawingToolCategory.Patterns,
|
|
205
|
+
anchorCount: 4,
|
|
206
|
+
priority: 1,
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
type: 'pattern-xabcd',
|
|
210
|
+
label: 'XABCD形态',
|
|
211
|
+
icon: '🔠',
|
|
212
|
+
category: DrawingToolCategory.Patterns,
|
|
213
|
+
anchorCount: 5,
|
|
214
|
+
priority: 1,
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
type: 'pattern-head-shoulders',
|
|
218
|
+
label: '头肩顶/底',
|
|
219
|
+
icon: '👤',
|
|
220
|
+
category: DrawingToolCategory.Patterns,
|
|
221
|
+
anchorCount: 5,
|
|
222
|
+
priority: 1,
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
type: 'pattern-triangle',
|
|
226
|
+
label: '三角形',
|
|
227
|
+
icon: '📐',
|
|
228
|
+
category: DrawingToolCategory.Patterns,
|
|
229
|
+
anchorCount: 4,
|
|
230
|
+
priority: 1,
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
type: 'pattern-cypher',
|
|
234
|
+
label: '赛福形态',
|
|
235
|
+
icon: '🌀',
|
|
236
|
+
category: DrawingToolCategory.Patterns,
|
|
237
|
+
anchorCount: 5,
|
|
238
|
+
priority: 1,
|
|
239
|
+
},
|
|
240
|
+
|
|
241
|
+
// ═══════════════════════════════════════════
|
|
242
|
+
// ★ 新增工具(约40种)
|
|
243
|
+
// ═══════════════════════════════════════════
|
|
244
|
+
|
|
245
|
+
// ── 线条扩展 ──
|
|
246
|
+
{
|
|
247
|
+
type: 'info-line',
|
|
248
|
+
label: '信息线',
|
|
249
|
+
icon: 'ℹ️',
|
|
250
|
+
category: DrawingToolCategory.Lines,
|
|
251
|
+
anchorCount: 2,
|
|
252
|
+
priority: 1,
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
type: 'extended-line',
|
|
256
|
+
label: '延长线',
|
|
257
|
+
icon: '↔️',
|
|
258
|
+
category: DrawingToolCategory.Lines,
|
|
259
|
+
anchorCount: 2,
|
|
260
|
+
priority: 1,
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
type: 'trend-angle',
|
|
264
|
+
label: '趋势角',
|
|
265
|
+
icon: '📐',
|
|
266
|
+
category: DrawingToolCategory.Lines,
|
|
267
|
+
anchorCount: 2,
|
|
268
|
+
priority: 2,
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
type: 'horizontal-ray',
|
|
272
|
+
label: '水平射线',
|
|
273
|
+
icon: '➡️',
|
|
274
|
+
category: DrawingToolCategory.Lines,
|
|
275
|
+
anchorCount: 1,
|
|
276
|
+
priority: 1,
|
|
277
|
+
},
|
|
278
|
+
|
|
279
|
+
// ── 通道扩展 ──
|
|
280
|
+
{
|
|
281
|
+
type: 'regression-trend',
|
|
282
|
+
label: '回归趋势',
|
|
283
|
+
icon: '📈',
|
|
284
|
+
category: DrawingToolCategory.Channels,
|
|
285
|
+
anchorCount: 2,
|
|
286
|
+
priority: 2,
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
type: 'flat-top-bottom',
|
|
290
|
+
label: '平底/平顶',
|
|
291
|
+
icon: '〰️',
|
|
292
|
+
category: DrawingToolCategory.Channels,
|
|
293
|
+
anchorCount: 3,
|
|
294
|
+
priority: 2,
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
type: 'disjoint-channel',
|
|
298
|
+
label: '分离通道',
|
|
299
|
+
icon: '↕️',
|
|
300
|
+
category: DrawingToolCategory.Channels,
|
|
301
|
+
anchorCount: 4,
|
|
302
|
+
priority: 2,
|
|
303
|
+
},
|
|
304
|
+
|
|
305
|
+
// ── 螺叉 ──
|
|
306
|
+
{
|
|
307
|
+
type: 'andrews-pitchfork',
|
|
308
|
+
label: '安德鲁斯螺叉',
|
|
309
|
+
icon: '🔱',
|
|
310
|
+
category: DrawingToolCategory.Lines,
|
|
311
|
+
anchorCount: 3,
|
|
312
|
+
priority: 2,
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
type: 'schiff-pitchfork',
|
|
316
|
+
label: '席夫螺叉',
|
|
317
|
+
icon: '🔱',
|
|
318
|
+
category: DrawingToolCategory.Lines,
|
|
319
|
+
anchorCount: 3,
|
|
320
|
+
priority: 2,
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
type: 'modified-schiff-pitchfork',
|
|
324
|
+
label: '修正席夫螺叉',
|
|
325
|
+
icon: '🔱',
|
|
326
|
+
category: DrawingToolCategory.Lines,
|
|
327
|
+
anchorCount: 3,
|
|
328
|
+
priority: 2,
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
type: 'inside-pitchfork',
|
|
332
|
+
label: '内部螺叉',
|
|
333
|
+
icon: '🔱',
|
|
334
|
+
category: DrawingToolCategory.Lines,
|
|
335
|
+
anchorCount: 3,
|
|
336
|
+
priority: 2,
|
|
337
|
+
},
|
|
338
|
+
|
|
339
|
+
// ── 斐波那契扩展 ──
|
|
340
|
+
{
|
|
341
|
+
type: 'fib-channel',
|
|
342
|
+
label: '斐波那契通道',
|
|
343
|
+
icon: '📊',
|
|
344
|
+
category: DrawingToolCategory.Fibonacci,
|
|
345
|
+
anchorCount: 3,
|
|
346
|
+
priority: 2,
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
type: 'fib-time-extension',
|
|
350
|
+
label: '斐波那契时间扩展',
|
|
351
|
+
icon: '⏰',
|
|
352
|
+
category: DrawingToolCategory.Fibonacci,
|
|
353
|
+
anchorCount: 3,
|
|
354
|
+
priority: 2,
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
type: 'fib-spiral',
|
|
358
|
+
label: '斐波那契螺旋',
|
|
359
|
+
icon: '🌀',
|
|
360
|
+
category: DrawingToolCategory.Fibonacci,
|
|
361
|
+
anchorCount: 2,
|
|
362
|
+
priority: 2,
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
type: 'fib-arcs',
|
|
366
|
+
label: '斐波那契弧线',
|
|
367
|
+
icon: '🌗',
|
|
368
|
+
category: DrawingToolCategory.Fibonacci,
|
|
369
|
+
anchorCount: 2,
|
|
370
|
+
priority: 2,
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
type: 'fib-wedge',
|
|
374
|
+
label: '斐波那契楔形',
|
|
375
|
+
icon: '🔻',
|
|
376
|
+
category: DrawingToolCategory.Fibonacci,
|
|
377
|
+
anchorCount: 3,
|
|
378
|
+
priority: 2,
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
type: 'pitchfan',
|
|
382
|
+
label: '螺叉扇形',
|
|
383
|
+
icon: '🌀',
|
|
384
|
+
category: DrawingToolCategory.Fibonacci,
|
|
385
|
+
anchorCount: 3,
|
|
386
|
+
priority: 2,
|
|
387
|
+
},
|
|
388
|
+
|
|
389
|
+
// ── 江恩 ──
|
|
390
|
+
{
|
|
391
|
+
type: 'gann-box',
|
|
392
|
+
label: '江恩方块',
|
|
393
|
+
icon: '⬛',
|
|
394
|
+
category: DrawingToolCategory.Measure,
|
|
395
|
+
anchorCount: 2,
|
|
396
|
+
priority: 2,
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
type: 'gann-fan',
|
|
400
|
+
label: '江恩扇形',
|
|
401
|
+
icon: '✳️',
|
|
402
|
+
category: DrawingToolCategory.Measure,
|
|
403
|
+
anchorCount: 2,
|
|
404
|
+
priority: 2,
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
type: 'gann-square-fixed',
|
|
408
|
+
label: '江恩方形(固定)',
|
|
409
|
+
icon: '🔲',
|
|
410
|
+
category: DrawingToolCategory.Measure,
|
|
411
|
+
anchorCount: 1,
|
|
412
|
+
priority: 2,
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
type: 'gann-square',
|
|
416
|
+
label: '江恩方形',
|
|
417
|
+
icon: '🔲',
|
|
418
|
+
category: DrawingToolCategory.Measure,
|
|
419
|
+
anchorCount: 2,
|
|
420
|
+
priority: 2,
|
|
421
|
+
},
|
|
422
|
+
|
|
423
|
+
// ── 预测扩展 ──
|
|
424
|
+
{
|
|
425
|
+
type: 'forecast',
|
|
426
|
+
label: '预测',
|
|
427
|
+
icon: '🔮',
|
|
428
|
+
category: DrawingToolCategory.Positions,
|
|
429
|
+
anchorCount: 2,
|
|
430
|
+
priority: 2,
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
type: 'bars-pattern',
|
|
434
|
+
label: 'K线形态',
|
|
435
|
+
icon: '📊',
|
|
436
|
+
category: DrawingToolCategory.Patterns,
|
|
437
|
+
anchorCount: 3,
|
|
438
|
+
priority: 2,
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
type: 'projection',
|
|
442
|
+
label: '投影',
|
|
443
|
+
icon: '📐',
|
|
444
|
+
category: DrawingToolCategory.Positions,
|
|
445
|
+
anchorCount: 3,
|
|
446
|
+
priority: 2,
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
type: 'price-range',
|
|
450
|
+
label: '价格范围',
|
|
451
|
+
icon: '📏',
|
|
452
|
+
category: DrawingToolCategory.Measure,
|
|
453
|
+
anchorCount: 2,
|
|
454
|
+
priority: 1,
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
type: 'date-range',
|
|
458
|
+
label: '日期范围',
|
|
459
|
+
icon: '📅',
|
|
460
|
+
category: DrawingToolCategory.Measure,
|
|
461
|
+
anchorCount: 2,
|
|
462
|
+
priority: 1,
|
|
463
|
+
},
|
|
464
|
+
|
|
465
|
+
// ── 形状扩展 ──
|
|
466
|
+
{
|
|
467
|
+
type: 'polyline',
|
|
468
|
+
label: '多段线',
|
|
469
|
+
icon: '〰️',
|
|
470
|
+
category: DrawingToolCategory.Shapes,
|
|
471
|
+
anchorCount: -1,
|
|
472
|
+
priority: 1,
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
type: 'curve',
|
|
476
|
+
label: '曲线',
|
|
477
|
+
icon: '〰️',
|
|
478
|
+
category: DrawingToolCategory.Shapes,
|
|
479
|
+
anchorCount: 4,
|
|
480
|
+
priority: 2,
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
type: 'double-curve',
|
|
484
|
+
label: '双曲线',
|
|
485
|
+
icon: '≈',
|
|
486
|
+
category: DrawingToolCategory.Shapes,
|
|
487
|
+
anchorCount: 3,
|
|
488
|
+
priority: 2,
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
type: 'arc',
|
|
492
|
+
label: '弧形',
|
|
493
|
+
icon: '⌒',
|
|
494
|
+
category: DrawingToolCategory.Shapes,
|
|
495
|
+
anchorCount: 3,
|
|
496
|
+
priority: 2,
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
type: 'polygon',
|
|
500
|
+
label: '多边形',
|
|
501
|
+
icon: '⬡',
|
|
502
|
+
category: DrawingToolCategory.Shapes,
|
|
503
|
+
anchorCount: -1,
|
|
504
|
+
priority: 2,
|
|
505
|
+
},
|
|
506
|
+
|
|
507
|
+
// ── 标注 ──
|
|
508
|
+
{
|
|
509
|
+
type: 'text',
|
|
510
|
+
label: '文字',
|
|
511
|
+
icon: '📝',
|
|
512
|
+
category: DrawingToolCategory.Annotations,
|
|
513
|
+
anchorCount: 1,
|
|
514
|
+
priority: 0,
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
type: 'text-annotation',
|
|
518
|
+
label: '文字标注',
|
|
519
|
+
icon: '📝',
|
|
520
|
+
category: DrawingToolCategory.Annotations,
|
|
521
|
+
anchorCount: 2,
|
|
522
|
+
priority: 1,
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
type: 'anchored-text',
|
|
526
|
+
label: '锚定文字',
|
|
527
|
+
icon: '📌',
|
|
528
|
+
category: DrawingToolCategory.Annotations,
|
|
529
|
+
anchorCount: 2,
|
|
530
|
+
priority: 1,
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
type: 'note',
|
|
534
|
+
label: '便签',
|
|
535
|
+
icon: '🗒️',
|
|
536
|
+
category: DrawingToolCategory.Annotations,
|
|
537
|
+
anchorCount: 1,
|
|
538
|
+
priority: 1,
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
type: 'price-note',
|
|
542
|
+
label: '价格标签',
|
|
543
|
+
icon: '🏷️',
|
|
544
|
+
category: DrawingToolCategory.Annotations,
|
|
545
|
+
anchorCount: 1,
|
|
546
|
+
priority: 1,
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
type: 'price-label',
|
|
550
|
+
label: '价格标注',
|
|
551
|
+
icon: '💲',
|
|
552
|
+
category: DrawingToolCategory.Annotations,
|
|
553
|
+
anchorCount: 1,
|
|
554
|
+
priority: 1,
|
|
555
|
+
},
|
|
556
|
+
{
|
|
557
|
+
type: 'flag-mark',
|
|
558
|
+
label: '旗标',
|
|
559
|
+
icon: '🚩',
|
|
560
|
+
category: DrawingToolCategory.Annotations,
|
|
561
|
+
anchorCount: 1,
|
|
562
|
+
priority: 2,
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
type: 'pin',
|
|
566
|
+
label: '图钉',
|
|
567
|
+
icon: '📍',
|
|
568
|
+
category: DrawingToolCategory.Annotations,
|
|
569
|
+
anchorCount: 1,
|
|
570
|
+
priority: 2,
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
type: 'comment',
|
|
574
|
+
label: '评论',
|
|
575
|
+
icon: '💬',
|
|
576
|
+
category: DrawingToolCategory.Annotations,
|
|
577
|
+
anchorCount: 1,
|
|
578
|
+
priority: 2,
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
type: 'signpost',
|
|
582
|
+
label: '路标',
|
|
583
|
+
icon: '🪧',
|
|
584
|
+
category: DrawingToolCategory.Annotations,
|
|
585
|
+
anchorCount: 1,
|
|
586
|
+
priority: 2,
|
|
587
|
+
},
|
|
588
|
+
{
|
|
589
|
+
type: 'table',
|
|
590
|
+
label: '表格',
|
|
591
|
+
icon: '📋',
|
|
592
|
+
category: DrawingToolCategory.Annotations,
|
|
593
|
+
anchorCount: 1,
|
|
594
|
+
priority: 2,
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
type: 'highlighter',
|
|
598
|
+
label: '高亮笔',
|
|
599
|
+
icon: '🖍️',
|
|
600
|
+
category: DrawingToolCategory.Annotations,
|
|
601
|
+
anchorCount: -1,
|
|
602
|
+
priority: 1,
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
type: 'arrow-marker',
|
|
606
|
+
label: '箭头标记',
|
|
607
|
+
icon: '📌',
|
|
608
|
+
category: DrawingToolCategory.Annotations,
|
|
609
|
+
anchorCount: 1,
|
|
610
|
+
priority: 1,
|
|
611
|
+
},
|
|
612
|
+
{
|
|
613
|
+
type: 'arrow-mark-up',
|
|
614
|
+
label: '上涨标记',
|
|
615
|
+
icon: '🔼',
|
|
616
|
+
category: DrawingToolCategory.Annotations,
|
|
617
|
+
anchorCount: 1,
|
|
618
|
+
priority: 2,
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
type: 'arrow-mark-down',
|
|
622
|
+
label: '下跌标记',
|
|
623
|
+
icon: '🔽',
|
|
624
|
+
category: DrawingToolCategory.Annotations,
|
|
625
|
+
anchorCount: 1,
|
|
626
|
+
priority: 2,
|
|
627
|
+
},
|
|
628
|
+
];
|
|
629
|
+
|
|
630
|
+
/** 获取按分类分组的工具 */
|
|
631
|
+
export function getToolsByCategory(): Map<DrawingToolCategory, DrawingToolConfig[]> {
|
|
632
|
+
const map = new Map<DrawingToolCategory, DrawingToolConfig[]>();
|
|
633
|
+
for (const tool of DRAWING_TOOLS) {
|
|
634
|
+
const list = map.get(tool.category) ?? [];
|
|
635
|
+
list.push(tool);
|
|
636
|
+
map.set(tool.category, list);
|
|
637
|
+
}
|
|
638
|
+
return map;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
/** 获取按优先级分组的工具 */
|
|
642
|
+
export function getToolsByPriority(priority: number): DrawingToolConfig[] {
|
|
643
|
+
return DRAWING_TOOLS.filter((t) => t.priority === priority);
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
/** 获取工具配置 */
|
|
647
|
+
export function getToolConfig(type: DrawingToolType): DrawingToolConfig | undefined {
|
|
648
|
+
return DRAWING_TOOLS.find((t) => t.type === type);
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/** 分类中文标签 */
|
|
652
|
+
export const CATEGORY_LABELS: Record<DrawingToolCategory, string> = {
|
|
653
|
+
[DrawingToolCategory.Lines]: '线条',
|
|
654
|
+
[DrawingToolCategory.Channels]: '通道',
|
|
655
|
+
[DrawingToolCategory.Fibonacci]: '斐波那契',
|
|
656
|
+
[DrawingToolCategory.Shapes]: '形状',
|
|
657
|
+
[DrawingToolCategory.Annotations]: '标注',
|
|
658
|
+
[DrawingToolCategory.Positions]: '仓位',
|
|
659
|
+
[DrawingToolCategory.Measure]: '测量',
|
|
660
|
+
[DrawingToolCategory.Patterns]: '形态',
|
|
661
|
+
[DrawingToolCategory.VolumeProfile]: '成交量',
|
|
662
|
+
};
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
* 工具类型映射:将我们的 DrawingToolType 映射到库的 tool type string
|
|
666
|
+
* 注意:fib-fan 在库中是 fib-speed-fan
|
|
667
|
+
*/
|
|
668
|
+
export function mapToolTypeToLib(type: DrawingToolType): string | null {
|
|
669
|
+
if (type === 'cursor') return null;
|
|
670
|
+
if (type === 'fib-fan') return 'fib-speed-fan';
|
|
671
|
+
// 形态工具使用 path 作为底层渲染
|
|
672
|
+
if (type.startsWith('pattern-')) return 'path';
|
|
673
|
+
// 新增工具直接透传
|
|
674
|
+
return type;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* 从库的 tool type 映射回我们的 DrawingToolType
|
|
679
|
+
*/
|
|
680
|
+
export function mapLibTypeToOurs(libType: string): DrawingToolType | null {
|
|
681
|
+
if (libType === 'fib-speed-fan') return 'fib-fan';
|
|
682
|
+
const found = DRAWING_TOOLS.find((t) => t.type === libType);
|
|
683
|
+
return found ? found.type : null;
|
|
684
|
+
}
|