kline-charts-react 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.
Files changed (38) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +388 -0
  3. package/dist/KLineChart.d.ts +5 -0
  4. package/dist/components/IndicatorDisplay/IndicatorDisplay.d.ts +12 -0
  5. package/dist/components/IndicatorDisplay/index.d.ts +1 -0
  6. package/dist/components/IndicatorSelector/IndicatorSelector.d.ts +12 -0
  7. package/dist/components/IndicatorSelector/index.d.ts +1 -0
  8. package/dist/components/Loading/Loading.d.ts +8 -0
  9. package/dist/components/Loading/index.d.ts +1 -0
  10. package/dist/components/MADisplay/MADisplay.d.ts +10 -0
  11. package/dist/components/MADisplay/index.d.ts +1 -0
  12. package/dist/components/PeriodSelector/PeriodSelector.d.ts +10 -0
  13. package/dist/components/PeriodSelector/index.d.ts +1 -0
  14. package/dist/components/SubPaneTitle/SubPaneTitle.d.ts +13 -0
  15. package/dist/components/SubPaneTitle/index.d.ts +1 -0
  16. package/dist/components/Toolbar/Toolbar.d.ts +20 -0
  17. package/dist/components/Toolbar/index.d.ts +1 -0
  18. package/dist/components/index.d.ts +7 -0
  19. package/dist/hooks/index.d.ts +3 -0
  20. package/dist/hooks/useEcharts.d.ts +26 -0
  21. package/dist/hooks/useKlineData.d.ts +24 -0
  22. package/dist/hooks/useZoomHistory.d.ts +18 -0
  23. package/dist/index.cjs +51 -0
  24. package/dist/index.d.ts +7 -0
  25. package/dist/index.js +26563 -0
  26. package/dist/index.umd.js +51 -0
  27. package/dist/kline-charts-react.css +1 -0
  28. package/dist/types/data.d.ts +207 -0
  29. package/dist/types/index.d.ts +3 -0
  30. package/dist/types/props.d.ts +279 -0
  31. package/dist/types/theme.d.ts +47 -0
  32. package/dist/utils/cache.d.ts +56 -0
  33. package/dist/utils/formatters.d.ts +115 -0
  34. package/dist/utils/index.d.ts +5 -0
  35. package/dist/utils/indicators.d.ts +109 -0
  36. package/dist/utils/optionBuilder.d.ts +32 -0
  37. package/dist/utils/timelineBuilder.d.ts +11 -0
  38. package/package.json +95 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 kline-charts contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,388 @@
1
+ # KLine Charts
2
+
3
+ <p align="center">
4
+ <strong>📈 专业级股票 K 线图表 React 组件</strong>
5
+ </p>
6
+
7
+ <p align="center">
8
+ 基于 ECharts,内置 stock-sdk 数据源,开箱即用
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="#安装">安装</a> •
13
+ <a href="#快速开始">快速开始</a> •
14
+ <a href="#功能特性">功能特性</a> •
15
+ <a href="#api-文档">API 文档</a> •
16
+ <a href="#主题定制">主题定制</a>
17
+ </p>
18
+
19
+ ---
20
+
21
+ ## 功能特性
22
+
23
+ - 🚀 **零配置数据** - 内置 stock-sdk,传入股票代码自动获取数据
24
+ - 🔌 **可插拔数据源** - 支持自定义 DataProvider(解决跨域/接入自有行情源/SSR)
25
+ - 🌍 **多市场支持** - A 股、港股、美股
26
+ - 📊 **丰富周期** - 分时、五日、日 K、周 K、月 K、分钟级 K 线
27
+ - 📈 **技术指标** - MA/MACD/BOLL/KDJ/RSI/WR/BIAS/CCI/ATR/OBV/ROC/DMI/SAR/KC
28
+ - 🎯 **交互完善** - 缩放、平移、十字准线、Tooltip、撤销/重做
29
+ - 🖥️ **全屏模式** - 一键全屏展示
30
+ - 🔄 **自动刷新** - 分时模式支持自动刷新数据
31
+ - 🎨 **高度可定制** - 主题、颜色、指标参数均可配置
32
+ - 📱 **响应式设计** - 自适应容器尺寸
33
+ - 📦 **轻量体积** - Tree-shaking 友好,按需引入 ECharts 组件
34
+
35
+ ## 安装
36
+
37
+ ```bash
38
+ npm install kline-charts-react
39
+
40
+ # 或使用 yarn
41
+ yarn add kline-charts-react
42
+
43
+ # 或使用 pnpm
44
+ pnpm add kline-charts-react
45
+ ```
46
+
47
+ ### Peer Dependencies
48
+
49
+ ```bash
50
+ npm install react react-dom
51
+ ```
52
+
53
+ ## 快速开始
54
+
55
+ ```tsx
56
+ import { KLineChart } from 'kline-charts-react';
57
+ import 'kline-charts-react/style.css';
58
+
59
+ function App() {
60
+ return (
61
+ <KLineChart
62
+ symbol="sh600519" // 贵州茅台
63
+ height={600}
64
+ />
65
+ );
66
+ }
67
+ ```
68
+
69
+ ## 基础用法
70
+
71
+ ### 切换股票
72
+
73
+ ```tsx
74
+ <KLineChart
75
+ symbol="sz000001" // 平安银行
76
+ market="A" // A 股(默认)
77
+ />
78
+ ```
79
+
80
+ ### 指定周期
81
+
82
+ ```tsx
83
+ <KLineChart
84
+ symbol="sh600519"
85
+ period="weekly" // 周 K 线
86
+ />
87
+ ```
88
+
89
+ 可选周期:`timeline` | `timeline5` | `1` | `5` | `15` | `30` | `60` | `daily` | `weekly` | `monthly`
90
+
91
+ ### 配置技术指标
92
+
93
+ ```tsx
94
+ <KLineChart
95
+ symbol="sh600519"
96
+ indicators={['ma', 'volume', 'macd', 'kdj']}
97
+ indicatorOptions={{
98
+ ma: { periods: [5, 10, 20, 60] },
99
+ macd: { short: 12, long: 26, signal: 9 },
100
+ }}
101
+ />
102
+ ```
103
+
104
+ ### 深色主题
105
+
106
+ ```tsx
107
+ <KLineChart
108
+ symbol="sh600519"
109
+ theme="dark"
110
+ />
111
+ ```
112
+
113
+ ### 自动刷新(分时模式)
114
+
115
+ ```tsx
116
+ <KLineChart
117
+ symbol="sh600519"
118
+ period="timeline"
119
+ autoRefresh={{ intervalMs: 5000, onlyTradingTime: true }}
120
+ />
121
+ ```
122
+
123
+ ### 自定义数据源
124
+
125
+ 解决跨域问题或接入自有行情源:
126
+
127
+ ```tsx
128
+ import { KLineChart, type KLineDataProvider } from 'kline-charts-react';
129
+
130
+ const customProvider: KLineDataProvider = {
131
+ getKline: async (params, signal) => {
132
+ const res = await fetch(`/api/kline?symbol=${params.symbol}`, { signal });
133
+ return res.json();
134
+ },
135
+ getTimeline: async (params, signal) => {
136
+ const res = await fetch(`/api/timeline?symbol=${params.symbol}`, { signal });
137
+ return res.json();
138
+ },
139
+ };
140
+
141
+ <KLineChart
142
+ symbol="sh600519"
143
+ dataProvider={customProvider}
144
+ />
145
+ ```
146
+
147
+ ### 使用 Ref 控制图表
148
+
149
+ ```tsx
150
+ import { useRef } from 'react';
151
+ import { KLineChart, type KLineChartRef } from 'kline-charts-react';
152
+
153
+ function App() {
154
+ const chartRef = useRef<KLineChartRef>(null);
155
+
156
+ const handleRefresh = () => {
157
+ chartRef.current?.refresh();
158
+ };
159
+
160
+ const handleExport = () => {
161
+ const dataUrl = chartRef.current?.exportImage('png');
162
+ // 下载图片...
163
+ };
164
+
165
+ return (
166
+ <>
167
+ <button onClick={handleRefresh}>刷新</button>
168
+ <button onClick={handleExport}>导出图片</button>
169
+ <KLineChart ref={chartRef} symbol="sh600519" />
170
+ </>
171
+ );
172
+ }
173
+ ```
174
+
175
+ ## API 文档
176
+
177
+ ### KLineChartProps
178
+
179
+ | 属性 | 类型 | 默认值 | 说明 |
180
+ |------|------|--------|------|
181
+ | `symbol` | `string` | **必填** | 股票代码,如 `sh600519`、`sz000001` |
182
+ | `market` | `'A' \| 'HK' \| 'US'` | `'A'` | 市场类型 |
183
+ | `period` | `PeriodType` | `'daily'` | K 线周期 |
184
+ | `adjust` | `'' \| 'qfq' \| 'hfq'` | `'qfq'` | 复权类型(前复权) |
185
+ | `height` | `number \| string` | `500` | 图表高度 |
186
+ | `width` | `number \| string` | `'100%'` | 图表宽度 |
187
+ | `theme` | `'light' \| 'dark' \| ThemeConfig` | `'light'` | 主题配置 |
188
+ | `indicators` | `IndicatorType[]` | `['ma', 'volume', 'macd']` | 启用的技术指标 |
189
+ | `indicatorOptions` | `IndicatorOptions` | - | 指标参数配置 |
190
+ | `showToolbar` | `boolean` | `true` | 是否显示工具栏 |
191
+ | `showPeriodSelector` | `boolean` | `true` | 是否显示周期切换 |
192
+ | `showIndicatorSelector` | `boolean` | `true` | 是否显示指标切换 |
193
+ | `maxSubPanes` | `number` | `3` | 最多显示几个副图,0 表示不显示副图 |
194
+ | `visibleCount` | `number` | `60` | 初始可见 K 线数量 |
195
+ | `dataProvider` | `KLineDataProvider` | - | 自定义数据源 |
196
+ | `sdkOptions` | `SDKOptions` | - | stock-sdk 配置 |
197
+ | `requestOptions` | `RequestOptions` | - | 请求控制配置 |
198
+ | `autoRefresh` | `boolean \| AutoRefreshOptions` | - | 自动刷新配置 |
199
+ | `echartsOption` | `EChartsOption` | - | 自定义 ECharts 配置 |
200
+ | `onDataLoad` | `(data: KlineData[]) => void` | - | 数据加载回调 |
201
+ | `onPeriodChange` | `(period: PeriodType) => void` | - | 周期切换回调 |
202
+ | `onError` | `(error: Error) => void` | - | 错误回调 |
203
+
204
+ ### KLineChartRef
205
+
206
+ | 方法 | 说明 |
207
+ |------|------|
208
+ | `refresh()` | 刷新数据 |
209
+ | `setPeriod(period)` | 切换周期 |
210
+ | `setIndicators(indicators)` | 切换指标 |
211
+ | `zoomTo(start, end)` | 缩放到指定范围 |
212
+ | `resetZoom()` | 重置缩放 |
213
+ | `getEchartsInstance()` | 获取 ECharts 实例 |
214
+ | `exportImage(type?)` | 导出图片(png/jpeg) |
215
+ | `getData()` | 获取当前数据 |
216
+
217
+ ### PeriodType
218
+
219
+ ```ts
220
+ type PeriodType =
221
+ | 'timeline' // 分时
222
+ | 'timeline5' // 五日分时
223
+ | '1' // 1分钟
224
+ | '5' // 5分钟
225
+ | '15' // 15分钟
226
+ | '30' // 30分钟
227
+ | '60' // 60分钟
228
+ | 'daily' // 日K
229
+ | 'weekly' // 周K
230
+ | 'monthly'; // 月K
231
+ ```
232
+
233
+ ### IndicatorType
234
+
235
+ ```ts
236
+ type IndicatorType =
237
+ // 主图指标
238
+ | 'ma' // 移动平均线
239
+ | 'boll' // 布林带
240
+ | 'sar' // 抛物线转向(SAR)
241
+ | 'kc' // 肯特纳通道(KC)
242
+ // 副图指标
243
+ | 'volume' // 成交量
244
+ | 'macd' // MACD
245
+ | 'kdj' // KDJ
246
+ | 'rsi' // RSI
247
+ | 'wr' // WR(威廉指标)
248
+ | 'bias' // BIAS(乖离率)
249
+ | 'cci' // CCI(顺势指标)
250
+ | 'atr' // ATR(平均真实波幅)
251
+ | 'obv' // OBV(能量潮)
252
+ | 'roc' // ROC(变动率)
253
+ | 'dmi'; // DMI(趋向指标)
254
+ ```
255
+
256
+ **主图指标说明**:
257
+ - **MA** - 移动平均线,显示不同周期的均线
258
+ - **BOLL** - 布林带,由上轨、中轨、下轨组成的通道
259
+ - **SAR** - 抛物线转向,以点状显示趋势反转信号
260
+ - **KC** - 肯特纳通道,基于 EMA 和 ATR 的通道指标
261
+
262
+ **副图指标说明**:
263
+ - **OBV** - 能量潮,通过成交量变化预测价格趋势
264
+ - **ROC** - 变动率,衡量价格变化的速度
265
+ - **DMI** - 趋向指标,包含 +DI、-DI、ADX、ADXR 四条线
266
+
267
+ ## 主题定制
268
+
269
+ ### 内置主题
270
+
271
+ ```tsx
272
+ // 浅色主题(默认)
273
+ <KLineChart theme="light" />
274
+
275
+ // 深色主题
276
+ <KLineChart theme="dark" />
277
+ ```
278
+
279
+ ### 自定义主题
280
+
281
+ ```tsx
282
+ <KLineChart
283
+ theme={{
284
+ backgroundColor: '#1a1a2e',
285
+ textColor: '#eaeaea',
286
+ upColor: '#26a69a',
287
+ downColor: '#ef5350',
288
+ gridLineColor: '#2a2a4a',
289
+ // ... 更多配置
290
+ }}
291
+ />
292
+ ```
293
+
294
+ ## 处理跨域
295
+
296
+ 由于 stock-sdk 默认请求腾讯财经接口,浏览器环境可能遇到跨域问题。推荐解决方案:
297
+
298
+ ### 方案 1:配置代理(开发环境)
299
+
300
+ ```ts
301
+ // vite.config.ts
302
+ export default {
303
+ server: {
304
+ proxy: {
305
+ '/qt': {
306
+ target: 'https://qt.gtimg.cn',
307
+ changeOrigin: true,
308
+ rewrite: (path) => path.replace(/^\/qt/, ''),
309
+ },
310
+ },
311
+ },
312
+ };
313
+ ```
314
+
315
+ ```tsx
316
+ <KLineChart
317
+ symbol="sh600519"
318
+ sdkOptions={{ baseUrl: '/qt' }}
319
+ />
320
+ ```
321
+
322
+ ### 方案 2:自定义 DataProvider
323
+
324
+ 使用自己的后端接口代理数据:
325
+
326
+ ```tsx
327
+ <KLineChart
328
+ symbol="sh600519"
329
+ dataProvider={myDataProvider}
330
+ />
331
+ ```
332
+
333
+ ## 目录结构
334
+
335
+ ```
336
+ kline-charts-react/
337
+ ├── src/
338
+ │ ├── components/ # 子组件
339
+ │ │ ├── Loading/
340
+ │ │ ├── PeriodSelector/
341
+ │ │ ├── IndicatorSelector/
342
+ │ │ ├── Toolbar/
343
+ │ │ └── MADisplay/
344
+ │ ├── hooks/ # React Hooks
345
+ │ │ ├── useKlineData.ts
346
+ │ │ ├── useEcharts.ts
347
+ │ │ └── useZoomHistory.ts
348
+ │ ├── utils/ # 工具函数
349
+ │ │ ├── indicators.ts
350
+ │ │ ├── optionBuilder.ts
351
+ │ │ └── timelineBuilder.ts
352
+ │ ├── types/ # 类型定义
353
+ │ ├── KLineChart.tsx # 主组件
354
+ │ └── index.ts # 入口
355
+ ├── playground/ # 调试环境
356
+ └── dist/ # 构建产物
357
+ ```
358
+
359
+ ## 开发
360
+
361
+ ```bash
362
+ # 安装依赖
363
+ yarn install
364
+
365
+ # 启动开发调试(直连本地源码,支持热更新)
366
+ yarn dev
367
+
368
+ # 构建组件库
369
+ yarn build
370
+
371
+ # 构建 playground 生产版本(使用 npm 包)
372
+ yarn build:playground
373
+
374
+ # 代码检查
375
+ yarn lint
376
+ ```
377
+
378
+ **开发模式说明**:
379
+ - `yarn dev` 会启动 playground,直接引用 `src/` 下的源码,修改源码后自动热更新
380
+ - 生产构建时,playground 会使用 npm 上发布的 `kline-charts-react` 包
381
+
382
+ ## 已知限制
383
+
384
+ - **导出图片**:`exportImage()` 方法导出的图片仅包含 ECharts 图表内容,不包含左上角的指标数值文字(这部分是用 React 渲染在图表外部的)
385
+
386
+ ## License
387
+
388
+ MIT © 2025
@@ -0,0 +1,5 @@
1
+ import { KLineChartProps, KLineChartRef } from './types';
2
+ /**
3
+ * K 线图表组件
4
+ */
5
+ export declare const KLineChart: import('react').ForwardRefExoticComponent<KLineChartProps & import('react').RefAttributes<KLineChartRef>>;
@@ -0,0 +1,12 @@
1
+ import { KlineWithIndicators, IndicatorType } from '../../types';
2
+ interface IndicatorDisplayProps {
3
+ data: KlineWithIndicators[];
4
+ indicators: IndicatorType[];
5
+ hoverIndex?: number | null;
6
+ }
7
+ /**
8
+ * 主图指标数值显示组件
9
+ * 支持 MA、BOLL、SAR、KC 指标
10
+ */
11
+ export declare function IndicatorDisplay({ data, indicators, hoverIndex }: IndicatorDisplayProps): import("react/jsx-runtime").JSX.Element | null;
12
+ export {};
@@ -0,0 +1 @@
1
+ export { IndicatorDisplay } from './IndicatorDisplay';
@@ -0,0 +1,12 @@
1
+ import { IndicatorType } from '../../types';
2
+ interface IndicatorSelectorProps {
3
+ value: IndicatorType[];
4
+ onChange: (indicators: IndicatorType[]) => void;
5
+ maxSubPanes?: number;
6
+ maxMainIndicators?: number;
7
+ }
8
+ /**
9
+ * 指标选择器组件
10
+ */
11
+ export declare function IndicatorSelector({ value, onChange, maxSubPanes, maxMainIndicators, }: IndicatorSelectorProps): import("react/jsx-runtime").JSX.Element;
12
+ export {};
@@ -0,0 +1 @@
1
+ export { IndicatorSelector } from './IndicatorSelector';
@@ -0,0 +1,8 @@
1
+ interface LoadingProps {
2
+ text?: string;
3
+ }
4
+ /**
5
+ * 加载状态组件
6
+ */
7
+ export declare function Loading({ text }: LoadingProps): import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -0,0 +1 @@
1
+ export { Loading } from './Loading';
@@ -0,0 +1,10 @@
1
+ import { KlineWithIndicators } from '../../types';
2
+ interface MADisplayProps {
3
+ data: KlineWithIndicators[];
4
+ hoverIndex?: number | null;
5
+ }
6
+ /**
7
+ * MA 数值显示组件
8
+ */
9
+ export declare function MADisplay({ data, hoverIndex }: MADisplayProps): import("react/jsx-runtime").JSX.Element | null;
10
+ export {};
@@ -0,0 +1 @@
1
+ export { MADisplay } from './MADisplay';
@@ -0,0 +1,10 @@
1
+ import { PeriodType } from '../../types';
2
+ interface PeriodSelectorProps {
3
+ value: PeriodType;
4
+ onChange: (period: PeriodType) => void;
5
+ }
6
+ /**
7
+ * 周期选择器组件
8
+ */
9
+ export declare function PeriodSelector({ value, onChange }: PeriodSelectorProps): import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1 @@
1
+ export { PeriodSelector } from './PeriodSelector';
@@ -0,0 +1,13 @@
1
+ import { KlineWithIndicators, PaneConfig } from '../../types';
2
+ interface SubPaneTitleProps {
3
+ panes: PaneConfig[];
4
+ data: KlineWithIndicators[];
5
+ hoverIndex?: number | null;
6
+ containerHeight: number;
7
+ }
8
+ /**
9
+ * 副图标题组件
10
+ * 显示在每个副图的左上角
11
+ */
12
+ export declare function SubPaneTitle({ panes, data, hoverIndex, containerHeight }: SubPaneTitleProps): import("react/jsx-runtime").JSX.Element | null;
13
+ export {};
@@ -0,0 +1 @@
1
+ export { SubPaneTitle } from './SubPaneTitle';
@@ -0,0 +1,20 @@
1
+ import { AdjustType } from '../../types';
2
+ interface ToolbarProps {
3
+ adjust: AdjustType;
4
+ onAdjustChange: (adjust: AdjustType) => void;
5
+ canUndo: boolean;
6
+ canRedo: boolean;
7
+ onUndo: () => void;
8
+ onRedo: () => void;
9
+ onZoomIn: () => void;
10
+ onZoomOut: () => void;
11
+ onPanLeft: () => void;
12
+ onPanRight: () => void;
13
+ onReset: () => void;
14
+ onFullscreen?: () => void;
15
+ }
16
+ /**
17
+ * 工具栏组件
18
+ */
19
+ export declare function Toolbar({ adjust, onAdjustChange, canUndo, canRedo, onUndo, onRedo, onZoomIn, onZoomOut, onPanLeft, onPanRight, onReset, onFullscreen, }: ToolbarProps): import("react/jsx-runtime").JSX.Element;
20
+ export {};
@@ -0,0 +1 @@
1
+ export { Toolbar } from './Toolbar';
@@ -0,0 +1,7 @@
1
+ export { Loading } from './Loading';
2
+ export { PeriodSelector } from './PeriodSelector';
3
+ export { IndicatorSelector } from './IndicatorSelector';
4
+ export { Toolbar } from './Toolbar';
5
+ export { MADisplay } from './MADisplay';
6
+ export { IndicatorDisplay } from './IndicatorDisplay';
7
+ export { SubPaneTitle } from './SubPaneTitle';
@@ -0,0 +1,3 @@
1
+ export { useKlineData } from './useKlineData';
2
+ export { useEcharts } from './useEcharts';
3
+ export { useZoomHistory } from './useZoomHistory';
@@ -0,0 +1,26 @@
1
+ import { EChartsOption } from 'echarts';
2
+ import * as echarts from 'echarts/core';
3
+ export type EChartsInstance = echarts.ECharts;
4
+ interface SetOptionOpts {
5
+ notMerge?: boolean;
6
+ lazyUpdate?: boolean;
7
+ replaceMerge?: string[];
8
+ }
9
+ interface UseEchartsResult {
10
+ chartRef: React.RefObject<HTMLDivElement | null>;
11
+ chartInstance: EChartsInstance | null;
12
+ setOption: (option: EChartsOption, opts?: boolean | SetOptionOpts, lazyUpdate?: boolean) => void;
13
+ resize: () => void;
14
+ dispose: () => void;
15
+ getDataURL: (opts?: {
16
+ type?: 'png' | 'jpeg';
17
+ pixelRatio?: number;
18
+ backgroundColor?: string;
19
+ }) => string;
20
+ bindEvent: (eventName: string, handler: (params: unknown) => void) => () => void;
21
+ }
22
+ /**
23
+ * ECharts 实例管理 Hook
24
+ */
25
+ export declare function useEcharts(): UseEchartsResult;
26
+ export {};
@@ -0,0 +1,24 @@
1
+ import { KlineWithIndicators, TimelineData, PeriodType, MarketType, AdjustType, KLineDataProvider, SDKOptions, RequestOptions, IndicatorOptions } from '../types';
2
+ interface UseKlineDataParams {
3
+ symbol: string;
4
+ market: MarketType;
5
+ period: PeriodType;
6
+ adjust: AdjustType;
7
+ dataProvider?: KLineDataProvider;
8
+ sdkOptions?: SDKOptions;
9
+ requestOptions?: RequestOptions;
10
+ indicatorOptions?: IndicatorOptions;
11
+ indicators?: string[];
12
+ }
13
+ interface UseKlineDataResult {
14
+ data: KlineWithIndicators[];
15
+ timelineData: TimelineData[];
16
+ loading: boolean;
17
+ error: Error | null;
18
+ refresh: () => Promise<void>;
19
+ }
20
+ /**
21
+ * K 线数据获取 Hook
22
+ */
23
+ export declare function useKlineData(params: UseKlineDataParams): UseKlineDataResult;
24
+ export {};
@@ -0,0 +1,18 @@
1
+ interface ZoomState {
2
+ start: number;
3
+ end: number;
4
+ }
5
+ interface UseZoomHistoryResult {
6
+ canUndo: boolean;
7
+ canRedo: boolean;
8
+ currentState: ZoomState;
9
+ pushState: (state: ZoomState) => void;
10
+ undo: () => ZoomState | null;
11
+ redo: () => ZoomState | null;
12
+ reset: (state?: ZoomState) => void;
13
+ }
14
+ /**
15
+ * 缩放历史管理 Hook(支持撤销/重做)
16
+ */
17
+ export declare function useZoomHistory(initialState?: ZoomState): UseZoomHistoryResult;
18
+ export {};