@363045841yyt/klinechart 0.5.4 → 0.5.5
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 +142 -141
- package/dist/index.cjs +9 -9
- package/dist/index.js +2782 -2428
- package/dist/klinechart.css +1 -1
- package/dist/mock-stock-data.json +1 -0
- package/dist/src/components/KLineChart.vue.d.ts +34 -0
- package/dist/src/components/LeftToolbar.vue.d.ts +8 -2
- package/dist/src/config/chartSettings.d.ts +13 -0
- package/dist/src/core/chart.d.ts +4 -0
- package/dist/src/core/drawing/interaction.d.ts +1 -0
- package/dist/src/plugin/types.d.ts +74 -0
- package/dist/src/utils/kLineDraw/axis.d.ts +37 -0
- package/package.json +29 -1
|
@@ -139,6 +139,57 @@ export declare function wrapPaneInfo(pane: {
|
|
|
139
139
|
yAxis: PaneInfo['yAxis'];
|
|
140
140
|
priceRange: PaneInfo['priceRange'];
|
|
141
141
|
}): Readonly<PaneInfo>;
|
|
142
|
+
/** Y轴标签(价格标签) */
|
|
143
|
+
export interface YAxisLabel {
|
|
144
|
+
/** 关联的数据索引 */
|
|
145
|
+
dataIndex: number;
|
|
146
|
+
/** 价格值 */
|
|
147
|
+
price: number;
|
|
148
|
+
/** 标签在轴上的Y坐标(世界坐标,相对pane) */
|
|
149
|
+
y: number;
|
|
150
|
+
/** 标签样式覆盖 */
|
|
151
|
+
style?: {
|
|
152
|
+
bgColor?: string;
|
|
153
|
+
borderColor?: string;
|
|
154
|
+
textColor?: string;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
/** X轴标签(时间标签) */
|
|
158
|
+
export interface XAxisLabel {
|
|
159
|
+
/** 关联的数据索引 */
|
|
160
|
+
dataIndex: number;
|
|
161
|
+
/** 时间戳(毫秒) */
|
|
162
|
+
timestamp: number;
|
|
163
|
+
/** 标签在轴上的X坐标(世界坐标,未减去scrollLeft) */
|
|
164
|
+
x: number;
|
|
165
|
+
/** 标签样式覆盖 */
|
|
166
|
+
style?: {
|
|
167
|
+
bgColor?: string;
|
|
168
|
+
textColor?: string;
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
/** Y轴范围带(半透明填充区域) */
|
|
172
|
+
export interface YAxisRange {
|
|
173
|
+
/** 范围上界Y坐标(相对pane,canvas方向:小值=上方) */
|
|
174
|
+
topY: number;
|
|
175
|
+
/** 范围下界Y坐标(相对pane,canvas方向:大值=下方) */
|
|
176
|
+
bottomY: number;
|
|
177
|
+
/** 填充颜色(hex 或 rgba) */
|
|
178
|
+
color: string;
|
|
179
|
+
/** 填充不透明度 */
|
|
180
|
+
opacity: number;
|
|
181
|
+
}
|
|
182
|
+
/** X轴范围带(半透明填充区域) */
|
|
183
|
+
export interface XAxisRange {
|
|
184
|
+
/** 范围左界X坐标(世界坐标,未减去scrollLeft) */
|
|
185
|
+
leftX: number;
|
|
186
|
+
/** 范围右界X坐标(世界坐标,未减去scrollLeft) */
|
|
187
|
+
rightX: number;
|
|
188
|
+
/** 填充颜色(hex 或 rgba) */
|
|
189
|
+
color: string;
|
|
190
|
+
/** 填充不透明度 */
|
|
191
|
+
opacity: number;
|
|
192
|
+
}
|
|
142
193
|
/** 渲染上下文 */
|
|
143
194
|
/** MarkerManager 接口(用于 RenderContext) */
|
|
144
195
|
export interface MarkerManagerLike {
|
|
@@ -159,6 +210,13 @@ export interface RenderContext {
|
|
|
159
210
|
dpr: number;
|
|
160
211
|
paneWidth: number;
|
|
161
212
|
kLinePositions: number[];
|
|
213
|
+
/** 每根K线柱中心的X坐标(物理像素对齐后,逻辑像素) */
|
|
214
|
+
kLineCenters: number[];
|
|
215
|
+
/** 每根K线对应柱的X/宽度(物理像素对齐后,逻辑像素),供柱状图使用 */
|
|
216
|
+
kBarRects: Array<{
|
|
217
|
+
x: number;
|
|
218
|
+
width: number;
|
|
219
|
+
}>;
|
|
162
220
|
markerManager?: MarkerManagerLike;
|
|
163
221
|
/** 十字线指向的 K 线索引(无十字线时为 null) */
|
|
164
222
|
crosshairIndex?: number | null;
|
|
@@ -174,6 +232,16 @@ export interface RenderContext {
|
|
|
174
232
|
plotWidth: number;
|
|
175
233
|
plotHeight: number;
|
|
176
234
|
};
|
|
235
|
+
/** 用户设置配置(渲染器只读) */
|
|
236
|
+
settings?: Record<string, boolean>;
|
|
237
|
+
/** 需要在Y轴上绘制的标签列表(由各类标记渲染器填充) */
|
|
238
|
+
yAxisLabels?: YAxisLabel[];
|
|
239
|
+
/** 需要在X轴上绘制的标签列表(由各类标记渲染器填充) */
|
|
240
|
+
xAxisLabels?: XAxisLabel[];
|
|
241
|
+
/** 需要在Y轴上绘制的范围带列表(由绘图渲染器填充,先于标签绘制) */
|
|
242
|
+
yAxisRanges?: YAxisRange[];
|
|
243
|
+
/** 需要在X轴上绘制的范围带列表(由绘图渲染器填充,先于标签绘制) */
|
|
244
|
+
xAxisRanges?: XAxisRange[];
|
|
177
245
|
}
|
|
178
246
|
export type DrawingAnchor = {
|
|
179
247
|
id: string;
|
|
@@ -245,6 +313,7 @@ export type DrawingGeometry = {
|
|
|
245
313
|
bottom: number;
|
|
246
314
|
};
|
|
247
315
|
meta?: Record<string, unknown>;
|
|
316
|
+
computedAnchors?: DrawingAnchor[];
|
|
248
317
|
};
|
|
249
318
|
export type DrawingComputeContext = {
|
|
250
319
|
pane: PaneInfo;
|
|
@@ -255,6 +324,11 @@ export type DrawingComputeContext = {
|
|
|
255
324
|
end: number;
|
|
256
325
|
};
|
|
257
326
|
kLinePositions: number[];
|
|
327
|
+
kLineCenters: number[];
|
|
328
|
+
kBarRects: Array<{
|
|
329
|
+
x: number;
|
|
330
|
+
width: number;
|
|
331
|
+
}>;
|
|
258
332
|
kWidth: number;
|
|
259
333
|
kGap: number;
|
|
260
334
|
dpr: number;
|
|
@@ -127,3 +127,40 @@ export declare function drawCrosshairPriceLabel(ctx: CanvasRenderingContext2D, o
|
|
|
127
127
|
export declare function drawLastPriceDashedLine(ctx: CanvasRenderingContext2D, opts: LastPriceLineOptions): void;
|
|
128
128
|
/** 底部时间轴(X方向随 scrollLeft 变化) */
|
|
129
129
|
export declare function drawTimeAxis(ctx: CanvasRenderingContext2D, opts: TimeAxisOptions): void;
|
|
130
|
+
/** ============ 轴标签绘制函数 ============ */
|
|
131
|
+
export interface AxisPriceLabelOptions {
|
|
132
|
+
x: number;
|
|
133
|
+
y: number;
|
|
134
|
+
width: number;
|
|
135
|
+
height: number;
|
|
136
|
+
priceY: number;
|
|
137
|
+
price: number;
|
|
138
|
+
dpr: number;
|
|
139
|
+
bgColor?: string;
|
|
140
|
+
borderColor?: string;
|
|
141
|
+
textColor?: string;
|
|
142
|
+
fontSize?: number;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* 在右侧价格轴上绘制价格标签
|
|
146
|
+
* 与 drawCrosshairPriceLabel 类似,但简化了参数(价格直接传入,无需计算)
|
|
147
|
+
*/
|
|
148
|
+
export declare function drawAxisPriceLabel(ctx: CanvasRenderingContext2D, opts: AxisPriceLabelOptions): void;
|
|
149
|
+
export interface AxisTimeLabelOptions {
|
|
150
|
+
x: number;
|
|
151
|
+
y: number;
|
|
152
|
+
width: number;
|
|
153
|
+
height: number;
|
|
154
|
+
labelX: number;
|
|
155
|
+
timestamp: number;
|
|
156
|
+
dpr: number;
|
|
157
|
+
bgColor?: string;
|
|
158
|
+
textColor?: string;
|
|
159
|
+
fontSize?: number;
|
|
160
|
+
paddingX?: number;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* 在底部时间轴上绘制时间标签
|
|
164
|
+
* 与 drawCrosshairTimeLabel 类似,但 labelX 是屏幕坐标(已处理 scrollLeft)
|
|
165
|
+
*/
|
|
166
|
+
export declare function drawAxisTimeLabel(ctx: CanvasRenderingContext2D, opts: AxisTimeLabelOptions): void;
|
package/package.json
CHANGED
|
@@ -1,7 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@363045841yyt/klinechart",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"license": "MIT",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"kline-chart",
|
|
7
|
+
"candlestick-chart",
|
|
8
|
+
"financial-chart",
|
|
9
|
+
"tradingview",
|
|
10
|
+
"canvas",
|
|
11
|
+
"rendering-engine",
|
|
12
|
+
"resizeobserver",
|
|
13
|
+
"device-pixel-content-box",
|
|
14
|
+
"drawing-tools",
|
|
15
|
+
"chart-drawing",
|
|
16
|
+
"trend-line",
|
|
17
|
+
"fibonacci",
|
|
18
|
+
"high-performance",
|
|
19
|
+
"pixel-perfect",
|
|
20
|
+
"crisp-rendering",
|
|
21
|
+
"sharp-rendering",
|
|
22
|
+
"device-pixel-ratio",
|
|
23
|
+
"responsive",
|
|
24
|
+
"modern-ui",
|
|
25
|
+
"agent",
|
|
26
|
+
"ai-chart",
|
|
27
|
+
"visualization",
|
|
28
|
+
"quantitative-trading",
|
|
29
|
+
"technical-analysis",
|
|
30
|
+
"plugin-architecture",
|
|
31
|
+
"typescript"
|
|
32
|
+
],
|
|
5
33
|
"type": "module",
|
|
6
34
|
"engines": {
|
|
7
35
|
"node": "^20.19.0 || >=22.12.0"
|