kline-charts-react 0.0.1 → 0.0.3
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/README.md +128 -29
- package/dist/SubPaneTitle-B2y5WQqq.js +2019 -0
- package/dist/SubPaneTitle-BAu9MdQQ.cjs +1 -0
- package/dist/components/IndicatorDisplay/IndicatorDisplay.d.ts +3 -2
- package/dist/hooks/useEcharts.d.ts +1 -1
- package/dist/hooks/useKlineData.d.ts +2 -2
- package/dist/index.cjs +7 -51
- package/dist/index.d.ts +2 -4
- package/dist/index.js +482 -26331
- package/dist/kline-charts-react.css +1 -1
- package/dist/types/props.d.ts +28 -23
- package/dist/types/theme.d.ts +4 -0
- package/dist/unstable.cjs +1 -0
- package/dist/unstable.d.ts +2 -0
- package/dist/unstable.js +53 -0
- package/dist/utils/controllable.d.ts +7 -0
- package/dist/utils/formatters.d.ts +4 -21
- package/dist/utils/indicatorMeta.d.ts +7 -0
- package/dist/utils/marketSessions.d.ts +2 -0
- package/dist/utils/optionBuilder.d.ts +20 -1
- package/package.json +32 -9
- package/dist/index.umd.js +0 -51
|
@@ -1 +1 @@
|
|
|
1
|
-
._container_119o2_1{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;min-height:200px;gap:12px}._spinner_119o2_11{display:flex;gap:6px}._dot_119o2_16{width:8px;height:8px;background-color:#1890ff;border-radius:50%;animation:_bounce_119o2_1 .6s infinite alternate}._dot_119o2_16:nth-child(2){animation-delay:.2s}._dot_119o2_16:nth-child(3){animation-delay:.4s}@keyframes _bounce_119o2_1{0%{transform:translateY(0);opacity:.4}to{transform:translateY(-10px);opacity:1}}._text_119o2_43{color:#999;font-size:13px}._container_1xu4v_1{display:flex;align-items:center;gap:16px;padding:8px 12px;border-bottom:1px solid var(--kline-border-color, #e8e8e8);background:var(--kline-bg-color, #fff)}._group_1xu4v_10{display:flex;gap:4px}._button_1xu4v_15{padding:4px 10px;font-size:13px;color:var(--kline-text-color, #333);background:transparent;border:none;border-radius:4px;cursor:pointer;transition:all .2s}._button_1xu4v_15:hover{background:var(--kline-hover-bg, #f5f5f5)}._button_1xu4v_15._active_1xu4v_30{color:#fff;background:var(--kline-active-color, #1890ff)}._container_1fbmi_1{display:flex;align-items:center;gap:8px;padding:8px 12px;border-top:1px solid var(--kline-border-color, #e8e8e8);background:var(--kline-bg-color, #fff);flex-wrap:wrap}._button_1fbmi_11{padding:4px 12px;font-size:12px;color:var(--kline-text-secondary, #666);background:var(--kline-tag-bg, #f0f0f0);border:1px solid transparent;border-radius:4px;cursor:pointer;transition:all .2s}._button_1fbmi_11:hover{border-color:var(--kline-active-color, #1890ff);color:var(--kline-active-color, #1890ff)}._button_1fbmi_11._active_1fbmi_27{color:var(--kline-active-color, #1890ff);background:#1890ff1a;border-color:var(--kline-active-color, #1890ff)}._divider_1fbmi_33{width:1px;height:20px;background:var(--kline-border-color, #e8e8e8);margin:0 4px}._container_2tswg_1{display:flex;align-items:center;gap:4px;padding:6px 12px;background:var(--kline-bg-color, #fff);border-bottom:1px solid var(--kline-border-color, #e8e8e8)}._group_2tswg_10{display:flex;align-items:center;gap:2px}._divider_2tswg_16{width:1px;height:16px;margin:0 8px;background:var(--kline-border-color, #e8e8e8)}._spacer_2tswg_23{flex:1}._iconButton_2tswg_27{display:flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;color:var(--kline-text-color, #333);background:transparent;border:none;border-radius:4px;cursor:pointer;transition:all .2s}._iconButton_2tswg_27:hover:not(:disabled){background:var(--kline-hover-bg, #f5f5f5)}._iconButton_2tswg_27:disabled{color:var(--kline-text-disabled, #ccc);cursor:not-allowed}._textButton_2tswg_51{padding:4px 8px;font-size:12px;color:var(--kline-text-secondary, #666);background:transparent;border:none;border-radius:4px;cursor:pointer;transition:all .2s}._textButton_2tswg_51:hover{background:var(--kline-hover-bg, #f5f5f5);color:var(--kline-text-color, #333)}._textButton_2tswg_51._active_2tswg_67{color:var(--kline-active-color, #1890ff);background:#1890ff1a}._container_1vdme_1{display:flex;align-items:center;gap:16px;padding:4px 8px;font-size:12px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;flex-wrap:wrap}._group_1vdme_11{display:flex;align-items:center;gap:12px;flex-wrap:wrap}._item_1vdme_18{font-weight:500;white-space:nowrap}._title_p093j_1{position:absolute;left:8px;z-index:10;display:flex;align-items:center;gap:8px;font-size:11px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;pointer-events:none;background:var(--kline-bg-color, rgba(255, 255, 255, .9));padding:2px 6px;border-radius:2px}._label_p093j_16{font-weight:600;color:var(--kline-text-color, #333)}._value_p093j_21{color:var(--kline-text-secondary, #666)}._container_o8wlo_1{display:flex;flex-direction:column;background:var(--kline-bg-color, #fff);border:1px solid var(--kline-border-color, #e8e8e8);border-radius:4px;overflow:hidden;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif}._fullscreen_o8wlo_12{position:fixed;top:0;left:0;right:0;bottom:0;z-index:9999;border-radius:0;border:none}._chartWrapper_o8wlo_23{flex:1;position:relative;min-height:200px}._chart_o8wlo_23{width:100%;height:100%}._error_o8wlo_34{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);display:flex;flex-direction:column;align-items:center;gap:12px;color:var(--kline-text-secondary, #999);font-size:14px}._error_o8wlo_34 button{padding:6px 16px;font-size:13px;color:#fff;background:var(--kline-active-color, #1890ff);border:none;border-radius:4px;cursor:pointer;transition:opacity .2s}._error_o8wlo_34 button:hover{opacity:.85}._timelineToolbar_o8wlo_63{display:flex;align-items:center;gap:12px;padding:8px 12px;border-bottom:1px solid var(--kline-border-color, #e8e8e8)}._timelineLabel_o8wlo_71{font-size:14px;font-weight:500;color:var(--kline-text-color, #333)}._refreshButton_o8wlo_77,._fullscreenButton_o8wlo_78{padding:4px 12px;font-size:12px;color:var(--kline-text-color, #333);background:var(--kline-tag-bg, #f0f0f0);border:1px solid var(--kline-border-color, #e8e8e8);border-radius:4px;cursor:pointer;transition:all .2s}._refreshButton_o8wlo_77:hover,._fullscreenButton_o8wlo_78:hover{background:var(--kline-hover-bg, #f5f5f5)}._refreshButton_o8wlo_77:disabled{opacity:.5;cursor:not-allowed}._refreshButton_o8wlo_77:not(:disabled):hover{border-color:var(--kline-active-color, #1890ff);color:var(--kline-active-color, #1890ff)}._fullscreenButton_o8wlo_78:hover{border-color:var(--kline-active-color, #1890ff);color:var(--kline-active-color, #1890ff)}:root{--kline-bg-color: #ffffff;--kline-text-color: #333333;--kline-text-secondary: #999999;--kline-border-color: #e8e8e8;--kline-active-color: #1890ff;--kline-hover-bg: #f5f5f5;--kline-tag-bg: #f0f0f0;--kline-text-disabled: #cccccc;--kline-up-color: #f5222d;--kline-down-color: #52c41a}.kline-dark{--kline-bg-color: #1a1a1a;--kline-text-color: #d1d1d1;--kline-text-secondary: #666666;--kline-border-color: #333333;--kline-hover-bg: #2a2a2a;--kline-tag-bg: #2a2a2a;--kline-text-disabled: #444444}
|
|
1
|
+
._container_119o2_1{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;min-height:200px;gap:12px}._spinner_119o2_11{display:flex;gap:6px}._dot_119o2_16{width:8px;height:8px;background-color:#1890ff;border-radius:50%;animation:_bounce_119o2_1 .6s infinite alternate}._dot_119o2_16:nth-child(2){animation-delay:.2s}._dot_119o2_16:nth-child(3){animation-delay:.4s}@keyframes _bounce_119o2_1{0%{transform:translateY(0);opacity:.4}to{transform:translateY(-10px);opacity:1}}._text_119o2_43{color:#999;font-size:13px}._container_1xu4v_1{display:flex;align-items:center;gap:16px;padding:8px 12px;border-bottom:1px solid var(--kline-border-color, #e8e8e8);background:var(--kline-bg-color, #fff)}._group_1xu4v_10{display:flex;gap:4px}._button_1xu4v_15{padding:4px 10px;font-size:13px;color:var(--kline-text-color, #333);background:transparent;border:none;border-radius:4px;cursor:pointer;transition:all .2s}._button_1xu4v_15:hover{background:var(--kline-hover-bg, #f5f5f5)}._button_1xu4v_15._active_1xu4v_30{color:#fff;background:var(--kline-active-color, #1890ff)}._container_1fbmi_1{display:flex;align-items:center;gap:8px;padding:8px 12px;border-top:1px solid var(--kline-border-color, #e8e8e8);background:var(--kline-bg-color, #fff);flex-wrap:wrap}._button_1fbmi_11{padding:4px 12px;font-size:12px;color:var(--kline-text-secondary, #666);background:var(--kline-tag-bg, #f0f0f0);border:1px solid transparent;border-radius:4px;cursor:pointer;transition:all .2s}._button_1fbmi_11:hover{border-color:var(--kline-active-color, #1890ff);color:var(--kline-active-color, #1890ff)}._button_1fbmi_11._active_1fbmi_27{color:var(--kline-active-color, #1890ff);background:#1890ff1a;border-color:var(--kline-active-color, #1890ff)}._divider_1fbmi_33{width:1px;height:20px;background:var(--kline-border-color, #e8e8e8);margin:0 4px}._container_2tswg_1{display:flex;align-items:center;gap:4px;padding:6px 12px;background:var(--kline-bg-color, #fff);border-bottom:1px solid var(--kline-border-color, #e8e8e8)}._group_2tswg_10{display:flex;align-items:center;gap:2px}._divider_2tswg_16{width:1px;height:16px;margin:0 8px;background:var(--kline-border-color, #e8e8e8)}._spacer_2tswg_23{flex:1}._iconButton_2tswg_27{display:flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;color:var(--kline-text-color, #333);background:transparent;border:none;border-radius:4px;cursor:pointer;transition:all .2s}._iconButton_2tswg_27:hover:not(:disabled){background:var(--kline-hover-bg, #f5f5f5)}._iconButton_2tswg_27:disabled{color:var(--kline-text-disabled, #ccc);cursor:not-allowed}._textButton_2tswg_51{padding:4px 8px;font-size:12px;color:var(--kline-text-secondary, #666);background:transparent;border:none;border-radius:4px;cursor:pointer;transition:all .2s}._textButton_2tswg_51:hover{background:var(--kline-hover-bg, #f5f5f5);color:var(--kline-text-color, #333)}._textButton_2tswg_51._active_2tswg_67{color:var(--kline-active-color, #1890ff);background:#1890ff1a}._container_1vdme_1{display:flex;align-items:center;gap:16px;padding:4px 8px;font-size:12px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;flex-wrap:wrap}._group_1vdme_11{display:flex;align-items:center;gap:12px;flex-wrap:wrap}._item_1vdme_18{font-weight:500;white-space:nowrap}._title_p093j_1{position:absolute;left:8px;z-index:10;display:flex;align-items:center;gap:8px;font-size:11px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;pointer-events:none;background:var(--kline-bg-color, rgba(255, 255, 255, .9));padding:2px 6px;border-radius:2px}._label_p093j_16{font-weight:600;color:var(--kline-text-color, #333)}._value_p093j_21{color:var(--kline-text-secondary, #666)}._container_o8wlo_1{display:flex;flex-direction:column;background:var(--kline-bg-color, #fff);border:1px solid var(--kline-border-color, #e8e8e8);border-radius:4px;overflow:hidden;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif}._fullscreen_o8wlo_12{position:fixed;top:0;left:0;right:0;bottom:0;z-index:9999;border-radius:0;border:none}._chartWrapper_o8wlo_23{flex:1;position:relative;min-height:200px}._chart_o8wlo_23{width:100%;height:100%}._error_o8wlo_34{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);display:flex;flex-direction:column;align-items:center;gap:12px;color:var(--kline-text-secondary, #999);font-size:14px}._error_o8wlo_34 button{padding:6px 16px;font-size:13px;color:#fff;background:var(--kline-active-color, #1890ff);border:none;border-radius:4px;cursor:pointer;transition:opacity .2s}._error_o8wlo_34 button:hover{opacity:.85}._timelineToolbar_o8wlo_63{display:flex;align-items:center;gap:12px;padding:8px 12px;border-bottom:1px solid var(--kline-border-color, #e8e8e8)}._timelineLabel_o8wlo_71{font-size:14px;font-weight:500;color:var(--kline-text-color, #333)}._refreshButton_o8wlo_77,._fullscreenButton_o8wlo_78{padding:4px 12px;font-size:12px;color:var(--kline-text-color, #333);background:var(--kline-tag-bg, #f0f0f0);border:1px solid var(--kline-border-color, #e8e8e8);border-radius:4px;cursor:pointer;transition:all .2s}._refreshButton_o8wlo_77:hover,._fullscreenButton_o8wlo_78:hover{background:var(--kline-hover-bg, #f5f5f5)}._refreshButton_o8wlo_77:disabled{opacity:.5;cursor:not-allowed}._refreshButton_o8wlo_77:not(:disabled):hover{border-color:var(--kline-active-color, #1890ff);color:var(--kline-active-color, #1890ff)}._fullscreenButton_o8wlo_78:hover{border-color:var(--kline-active-color, #1890ff);color:var(--kline-active-color, #1890ff)}:root{--kline-bg-color: #ffffff;--kline-text-color: #333333;--kline-text-secondary: #999999;--kline-border-color: #e8e8e8;--kline-active-color: #1890ff;--kline-hover-bg: #f5f5f5;--kline-tag-bg: #f0f0f0;--kline-text-disabled: #cccccc;--kline-up-color: #f5222d;--kline-down-color: #52c41a}.kline-dark{--kline-bg-color: #1a1a1a;--kline-text-color: #d1d1d1;--kline-text-secondary: #666666;--kline-border-color: #333333;--kline-hover-bg: #2a2a2a;--kline-tag-bg: #2a2a2a;--kline-text-disabled: #444444}._container_1906n_1{display:flex;align-items:center;gap:12px;padding:4px 8px;font-size:12px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;flex-wrap:wrap}._item_1906n_11{font-weight:500;white-space:nowrap}
|
package/dist/types/props.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { CSSProperties } from 'react';
|
|
2
2
|
import { EChartsOption } from 'echarts';
|
|
3
|
+
import { EChartsType } from 'echarts/core';
|
|
4
|
+
import { RequestClientOptions } from 'stock-sdk';
|
|
3
5
|
import { KlineData, TimelineData } from './data';
|
|
4
6
|
import { ThemeConfig } from './theme';
|
|
5
7
|
/**
|
|
@@ -173,15 +175,6 @@ export interface AutoRefreshOptions {
|
|
|
173
175
|
intervalMs?: number;
|
|
174
176
|
onlyTradingTime?: boolean;
|
|
175
177
|
}
|
|
176
|
-
/**
|
|
177
|
-
* 时间轴配置
|
|
178
|
-
*/
|
|
179
|
-
export type TimeAxisOptions = {
|
|
180
|
-
mode: 'trading';
|
|
181
|
-
sessionCompression?: boolean;
|
|
182
|
-
} | {
|
|
183
|
-
mode: 'continuous';
|
|
184
|
-
};
|
|
185
178
|
/**
|
|
186
179
|
* ECharts Option 合并配置
|
|
187
180
|
*/
|
|
@@ -189,6 +182,13 @@ export interface EChartsOptionMergeOptions {
|
|
|
189
182
|
mode?: 'safeMerge' | 'replace';
|
|
190
183
|
replaceMerge?: string[];
|
|
191
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* 当前可见范围
|
|
187
|
+
*/
|
|
188
|
+
export interface VisibleRange {
|
|
189
|
+
start: number;
|
|
190
|
+
end: number;
|
|
191
|
+
}
|
|
192
192
|
/**
|
|
193
193
|
* 面板配置
|
|
194
194
|
*/
|
|
@@ -197,14 +197,7 @@ export interface PaneConfig {
|
|
|
197
197
|
height?: number | string;
|
|
198
198
|
indicators: IndicatorType[];
|
|
199
199
|
}
|
|
200
|
-
|
|
201
|
-
* SDK 配置
|
|
202
|
-
*/
|
|
203
|
-
export interface SDKOptions {
|
|
204
|
-
baseUrl?: string;
|
|
205
|
-
timeout?: number;
|
|
206
|
-
headers?: Record<string, string>;
|
|
207
|
-
}
|
|
200
|
+
export type SDKOptions = RequestClientOptions;
|
|
208
201
|
/**
|
|
209
202
|
* KLineChart 组件 Props
|
|
210
203
|
*/
|
|
@@ -213,18 +206,24 @@ export interface KLineChartProps {
|
|
|
213
206
|
symbol: string;
|
|
214
207
|
/** 市场类型 */
|
|
215
208
|
market?: MarketType;
|
|
216
|
-
/** K
|
|
209
|
+
/** K 线周期(受控) */
|
|
217
210
|
period?: PeriodType;
|
|
218
|
-
/**
|
|
211
|
+
/** 非受控模式下的默认周期 */
|
|
212
|
+
defaultPeriod?: PeriodType;
|
|
213
|
+
/** 复权类型(受控) */
|
|
219
214
|
adjust?: AdjustType;
|
|
215
|
+
/** 非受控模式下的默认复权类型 */
|
|
216
|
+
defaultAdjust?: AdjustType;
|
|
220
217
|
/** 图表高度 */
|
|
221
218
|
height?: number | string;
|
|
222
219
|
/** 图表宽度 */
|
|
223
220
|
width?: number | string;
|
|
224
221
|
/** 主题 */
|
|
225
222
|
theme?: 'light' | 'dark' | ThemeConfig;
|
|
226
|
-
/**
|
|
223
|
+
/** 启用的技术指标(受控) */
|
|
227
224
|
indicators?: IndicatorType[];
|
|
225
|
+
/** 非受控模式下默认启用的技术指标 */
|
|
226
|
+
defaultIndicators?: IndicatorType[];
|
|
228
227
|
/** 指标参数配置 */
|
|
229
228
|
indicatorOptions?: IndicatorOptions;
|
|
230
229
|
/** 是否显示工具栏 */
|
|
@@ -241,6 +240,12 @@ export interface KLineChartProps {
|
|
|
241
240
|
onDataLoad?: (data: KlineData[]) => void;
|
|
242
241
|
/** 周期切换回调 */
|
|
243
242
|
onPeriodChange?: (period: PeriodType) => void;
|
|
243
|
+
/** 复权切换回调 */
|
|
244
|
+
onAdjustChange?: (adjust: AdjustType) => void;
|
|
245
|
+
/** 指标切换回调 */
|
|
246
|
+
onIndicatorsChange?: (indicators: IndicatorType[]) => void;
|
|
247
|
+
/** 可见范围变化回调 */
|
|
248
|
+
onVisibleRangeChange?: (range: VisibleRange) => void;
|
|
244
249
|
/** 错误回调 */
|
|
245
250
|
onError?: (error: Error) => void;
|
|
246
251
|
/** 数据源提供者 */
|
|
@@ -251,8 +256,6 @@ export interface KLineChartProps {
|
|
|
251
256
|
requestOptions?: RequestOptions;
|
|
252
257
|
/** 自动刷新配置 */
|
|
253
258
|
autoRefresh?: boolean | AutoRefreshOptions;
|
|
254
|
-
/** 时间轴配置 */
|
|
255
|
-
timeAxis?: TimeAxisOptions;
|
|
256
259
|
/** 自定义 ECharts 配置 */
|
|
257
260
|
echartsOption?: EChartsOption;
|
|
258
261
|
/** ECharts Option 合并策略 */
|
|
@@ -270,10 +273,12 @@ export interface KLineChartProps {
|
|
|
270
273
|
export interface KLineChartRef {
|
|
271
274
|
refresh(): Promise<void>;
|
|
272
275
|
setPeriod(period: PeriodType): void;
|
|
276
|
+
setAdjust(adjust: AdjustType): void;
|
|
273
277
|
setIndicators(indicators: IndicatorType[]): void;
|
|
274
278
|
zoomTo(start: number, end: number): void;
|
|
275
279
|
resetZoom(): void;
|
|
276
|
-
|
|
280
|
+
getVisibleRange(): VisibleRange;
|
|
281
|
+
getEchartsInstance(): EChartsType | null;
|
|
277
282
|
exportImage(type?: 'png' | 'jpeg'): string;
|
|
278
283
|
getData(): KlineData[];
|
|
279
284
|
}
|
package/dist/types/theme.d.ts
CHANGED
|
@@ -32,6 +32,10 @@ export interface ThemeConfig {
|
|
|
32
32
|
areaColor: string;
|
|
33
33
|
/** 选中高亮色 */
|
|
34
34
|
activeColor: string;
|
|
35
|
+
/** BOLL 指标颜色 [上轨, 中轨, 下轨] */
|
|
36
|
+
bollColors: [string, string, string];
|
|
37
|
+
/** KC 指标颜色 [上轨, 中轨, 下轨] */
|
|
38
|
+
kcColors: [string, string, string];
|
|
35
39
|
}
|
|
36
40
|
/**
|
|
37
41
|
* 浅色主题
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./SubPaneTitle-BAu9MdQQ.cjs"),l=require("react/jsx-runtime"),m=require("react"),d="_container_1906n_1",f="_item_1906n_11",u={container:d,item:f},b={ma5:"#f5a623",ma10:"#2196f3",ma20:"#e91e63",ma30:"#4caf50",ma60:"#9c27b0",ma120:"#00bcd4",ma250:"#ff5722"};function p(r){return r==null?"--":r.toFixed(2)}function S({data:r,hoverIndex:o}){const a=m.useMemo(()=>{const e=o??r.length-1,n=r[e];return!n||!n.ma?null:n},[r,o]);if(!a||!a.ma)return null;const s=Object.keys(a.ma).filter(e=>{var n,i;return e.startsWith("ma")&&((n=a.ma)==null?void 0:n[e])!==null&&((i=a.ma)==null?void 0:i[e])!==void 0});return s.length===0?null:l.jsx("div",{className:u.container,children:s.map(e=>{var c;const n=(c=a.ma)==null?void 0:c[e],i=b[e]??"#999";return l.jsxs("span",{className:u.item,style:{color:i},children:[e.toUpperCase(),": ",p(n)]},e)})})}exports.IndicatorDisplay=t.IndicatorDisplay;exports.IndicatorSelector=t.IndicatorSelector;exports.Loading=t.Loading;exports.PeriodSelector=t.PeriodSelector;exports.SubPaneTitle=t.SubPaneTitle;exports.Toolbar=t.Toolbar;exports.useEcharts=t.useEcharts;exports.useKlineData=t.useKlineData;exports.useZoomHistory=t.useZoomHistory;exports.MADisplay=S;
|
package/dist/unstable.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { I as P, h as g, L as j, P as y, S as L, T as M, b as O, u as T, c as A } from "./SubPaneTitle-B2y5WQqq.js";
|
|
2
|
+
import { jsx as m, jsxs as l } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo as u } from "react";
|
|
4
|
+
const f = "_container_1906n_1", p = "_item_1906n_11", c = {
|
|
5
|
+
container: f,
|
|
6
|
+
item: p
|
|
7
|
+
}, d = {
|
|
8
|
+
ma5: "#f5a623",
|
|
9
|
+
ma10: "#2196f3",
|
|
10
|
+
ma20: "#e91e63",
|
|
11
|
+
ma30: "#4caf50",
|
|
12
|
+
ma60: "#9c27b0",
|
|
13
|
+
ma120: "#00bcd4",
|
|
14
|
+
ma250: "#ff5722"
|
|
15
|
+
};
|
|
16
|
+
function _(n) {
|
|
17
|
+
return n == null ? "--" : n.toFixed(2);
|
|
18
|
+
}
|
|
19
|
+
function x({ data: n, hoverIndex: r }) {
|
|
20
|
+
const s = u(() => {
|
|
21
|
+
const t = r ?? n.length - 1, a = n[t];
|
|
22
|
+
return !a || !a.ma ? null : a;
|
|
23
|
+
}, [n, r]);
|
|
24
|
+
if (!s || !s.ma)
|
|
25
|
+
return null;
|
|
26
|
+
const o = Object.keys(s.ma).filter(
|
|
27
|
+
(t) => {
|
|
28
|
+
var a, e;
|
|
29
|
+
return t.startsWith("ma") && ((a = s.ma) == null ? void 0 : a[t]) !== null && ((e = s.ma) == null ? void 0 : e[t]) !== void 0;
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
return o.length === 0 ? null : /* @__PURE__ */ m("div", { className: c.container, children: o.map((t) => {
|
|
33
|
+
var i;
|
|
34
|
+
const a = (i = s.ma) == null ? void 0 : i[t], e = d[t] ?? "#999";
|
|
35
|
+
return /* @__PURE__ */ l("span", { className: c.item, style: { color: e }, children: [
|
|
36
|
+
t.toUpperCase(),
|
|
37
|
+
": ",
|
|
38
|
+
_(a)
|
|
39
|
+
] }, t);
|
|
40
|
+
}) });
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
P as IndicatorDisplay,
|
|
44
|
+
g as IndicatorSelector,
|
|
45
|
+
j as Loading,
|
|
46
|
+
x as MADisplay,
|
|
47
|
+
y as PeriodSelector,
|
|
48
|
+
L as SubPaneTitle,
|
|
49
|
+
M as Toolbar,
|
|
50
|
+
O as useEcharts,
|
|
51
|
+
T as useKlineData,
|
|
52
|
+
A as useZoomHistory
|
|
53
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface UseControllableValueParams<T> {
|
|
2
|
+
value: T | undefined;
|
|
3
|
+
defaultValue: T;
|
|
4
|
+
onChange?: (value: T) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare function useControllableValue<T>({ value, defaultValue, onChange, }: UseControllableValueParams<T>): readonly [T, (nextValue: T) => void];
|
|
7
|
+
export {};
|
|
@@ -44,13 +44,7 @@ export interface TooltipData {
|
|
|
44
44
|
turnoverRate?: number | null;
|
|
45
45
|
amplitude?: number | null;
|
|
46
46
|
indicators?: string[];
|
|
47
|
-
ma?:
|
|
48
|
-
ma5?: number | null;
|
|
49
|
-
ma10?: number | null;
|
|
50
|
-
ma20?: number | null;
|
|
51
|
-
ma30?: number | null;
|
|
52
|
-
ma60?: number | null;
|
|
53
|
-
};
|
|
47
|
+
ma?: Record<string, number | null | undefined>;
|
|
54
48
|
boll?: {
|
|
55
49
|
upper: number | null;
|
|
56
50
|
mid: number | null;
|
|
@@ -75,20 +69,9 @@ export interface TooltipData {
|
|
|
75
69
|
d: number | null;
|
|
76
70
|
j: number | null;
|
|
77
71
|
};
|
|
78
|
-
rsi?:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
rsi24?: number | null;
|
|
82
|
-
};
|
|
83
|
-
wr?: {
|
|
84
|
-
wr6?: number | null;
|
|
85
|
-
wr10?: number | null;
|
|
86
|
-
};
|
|
87
|
-
bias?: {
|
|
88
|
-
bias6?: number | null;
|
|
89
|
-
bias12?: number | null;
|
|
90
|
-
bias24?: number | null;
|
|
91
|
-
};
|
|
72
|
+
rsi?: Record<string, number | null | undefined>;
|
|
73
|
+
wr?: Record<string, number | null | undefined>;
|
|
74
|
+
bias?: Record<string, number | null | undefined>;
|
|
92
75
|
cci?: {
|
|
93
76
|
cci: number | null;
|
|
94
77
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BIASOptions, MAOptions, RSIOptions, WROptions } from '../types';
|
|
2
|
+
export declare function getMAPeriods(options?: MAOptions | boolean): number[];
|
|
3
|
+
export declare function getRSIPeriods(options?: RSIOptions | boolean): number[];
|
|
4
|
+
export declare function getWRPeriods(options?: WROptions | boolean): number[];
|
|
5
|
+
export declare function getBIASPeriods(options?: BIASOptions | boolean): number[];
|
|
6
|
+
export declare function getMetricEntries(record: Record<string, number | null | undefined> | undefined, prefix: string): Array<[string, number | null | undefined]>;
|
|
7
|
+
export declare function formatMetricLabel(key: string): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EChartsOption } from 'echarts';
|
|
2
|
-
import { KlineWithIndicators, ThemeConfig, IndicatorType, PaneConfig } from '../types';
|
|
2
|
+
import { KlineWithIndicators, ThemeConfig, IndicatorType, PaneConfig, IndicatorOptions } from '../types';
|
|
3
3
|
export declare const DATA_ZOOM_INSIDE_ID = "kline-zoom-inside";
|
|
4
4
|
export declare const DATA_ZOOM_SLIDER_ID = "kline-zoom-slider";
|
|
5
5
|
/**
|
|
@@ -14,6 +14,24 @@ interface GetDefaultPanesOptions {
|
|
|
14
14
|
* 每个副图指标独立一个面板
|
|
15
15
|
*/
|
|
16
16
|
export declare function getDefaultPanes(indicators: IndicatorType[], options?: GetDefaultPanesOptions): PaneConfig[];
|
|
17
|
+
/** 布局常量 */
|
|
18
|
+
export declare const LAYOUT: {
|
|
19
|
+
readonly gap: 25;
|
|
20
|
+
readonly topMargin: 50;
|
|
21
|
+
readonly bottomMargin: 55;
|
|
22
|
+
readonly leftMargin: 60;
|
|
23
|
+
readonly rightMargin: 60;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* 计算 Grid 布局
|
|
27
|
+
*/
|
|
28
|
+
export declare function calculateGridLayout(panes: PaneConfig[], containerHeight: number): {
|
|
29
|
+
id: string;
|
|
30
|
+
left: number;
|
|
31
|
+
right: number;
|
|
32
|
+
top: number;
|
|
33
|
+
height: number;
|
|
34
|
+
}[];
|
|
17
35
|
/**
|
|
18
36
|
* 构建 ECharts Option
|
|
19
37
|
*/
|
|
@@ -24,6 +42,7 @@ export declare function buildOption(params: {
|
|
|
24
42
|
panes?: PaneConfig[];
|
|
25
43
|
visibleCount?: number;
|
|
26
44
|
containerHeight?: number;
|
|
45
|
+
indicatorOptions?: IndicatorOptions;
|
|
27
46
|
}): EChartsOption;
|
|
28
47
|
/**
|
|
29
48
|
* 合并 ECharts Option
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kline-charts-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Professional stock K-line chart React component with built-in data source, powered by ECharts and stock-sdk",
|
|
5
5
|
"author": "chengzuopeng",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,11 +14,17 @@
|
|
|
14
14
|
"import": "./dist/index.js",
|
|
15
15
|
"require": "./dist/index.cjs"
|
|
16
16
|
},
|
|
17
|
+
"./unstable": {
|
|
18
|
+
"types": "./dist/unstable.d.ts",
|
|
19
|
+
"import": "./dist/unstable.js",
|
|
20
|
+
"require": "./dist/unstable.cjs"
|
|
21
|
+
},
|
|
17
22
|
"./style.css": "./dist/kline-charts-react.css"
|
|
18
23
|
},
|
|
19
24
|
"files": [
|
|
20
25
|
"dist",
|
|
21
|
-
"README.md"
|
|
26
|
+
"README.md",
|
|
27
|
+
"LICENSE"
|
|
22
28
|
],
|
|
23
29
|
"sideEffects": [
|
|
24
30
|
"*.css"
|
|
@@ -28,13 +34,18 @@
|
|
|
28
34
|
"build": "tsc -b && vite build",
|
|
29
35
|
"build:lib": "tsc -b && vite build",
|
|
30
36
|
"build:playground": "yarn --cwd playground build",
|
|
37
|
+
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p playground/tsconfig.json",
|
|
31
38
|
"lint": "eslint .",
|
|
39
|
+
"test": "vitest",
|
|
40
|
+
"test:run": "vitest run",
|
|
41
|
+
"pack:check": "npm pack --dry-run",
|
|
32
42
|
"preview": "yarn --cwd playground preview",
|
|
33
43
|
"prepublishOnly": "yarn build"
|
|
34
44
|
},
|
|
35
45
|
"peerDependencies": {
|
|
36
46
|
"react": ">=17.0.0",
|
|
37
|
-
"react-dom": ">=17.0.0"
|
|
47
|
+
"react-dom": ">=17.0.0",
|
|
48
|
+
"echarts": ">=5.4.0"
|
|
38
49
|
},
|
|
39
50
|
"peerDependenciesMeta": {
|
|
40
51
|
"react": {
|
|
@@ -42,23 +53,35 @@
|
|
|
42
53
|
},
|
|
43
54
|
"react-dom": {
|
|
44
55
|
"optional": false
|
|
56
|
+
},
|
|
57
|
+
"echarts": {
|
|
58
|
+
"optional": false
|
|
45
59
|
}
|
|
46
60
|
},
|
|
47
61
|
"dependencies": {
|
|
48
|
-
"
|
|
49
|
-
"stock-sdk": "^1.6.1"
|
|
62
|
+
"stock-sdk": "^1.8.0"
|
|
50
63
|
},
|
|
51
64
|
"devDependencies": {
|
|
65
|
+
"@eslint/js": "^9.39.1",
|
|
66
|
+
"@testing-library/dom": "^10.4.1",
|
|
67
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
68
|
+
"@testing-library/react": "^16.3.0",
|
|
52
69
|
"@types/node": "^22.0.0",
|
|
53
70
|
"@types/react": "^18.3.18",
|
|
54
71
|
"@types/react-dom": "^18.3.5",
|
|
55
72
|
"@vitejs/plugin-react": "^4.3.4",
|
|
73
|
+
"echarts": "^5.5.0",
|
|
56
74
|
"eslint": "^9.17.0",
|
|
75
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
76
|
+
"globals": "^16.4.0",
|
|
77
|
+
"jsdom": "^27.0.1",
|
|
57
78
|
"react": "^18.3.1",
|
|
58
79
|
"react-dom": "^18.3.1",
|
|
59
80
|
"typescript": "~5.6.2",
|
|
81
|
+
"typescript-eslint": "^8.46.2",
|
|
60
82
|
"vite": "^6.0.5",
|
|
61
|
-
"vite-plugin-dts": "^4.4.0"
|
|
83
|
+
"vite-plugin-dts": "^4.4.0",
|
|
84
|
+
"vitest": "^3.2.4"
|
|
62
85
|
},
|
|
63
86
|
"keywords": [
|
|
64
87
|
"kline",
|
|
@@ -82,12 +105,12 @@
|
|
|
82
105
|
],
|
|
83
106
|
"repository": {
|
|
84
107
|
"type": "git",
|
|
85
|
-
"url": "https://github.com/chengzuopeng/kline-charts.git"
|
|
108
|
+
"url": "https://github.com/chengzuopeng/kline-charts-react.git"
|
|
86
109
|
},
|
|
87
110
|
"bugs": {
|
|
88
|
-
"url": "https://github.com/chengzuopeng/kline-charts/issues"
|
|
111
|
+
"url": "https://github.com/chengzuopeng/kline-charts-react/issues"
|
|
89
112
|
},
|
|
90
|
-
"homepage": "https://github.com/chengzuopeng/kline-charts#readme",
|
|
113
|
+
"homepage": "https://github.com/chengzuopeng/kline-charts-react#readme",
|
|
91
114
|
"engines": {
|
|
92
115
|
"node": ">=18.0.0"
|
|
93
116
|
},
|