@qfo/qfchart 0.6.6 → 0.6.7
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/dist/index.d.ts +1 -1
- package/dist/qfchart.min.browser.js +7 -7
- package/dist/qfchart.min.es.js +10 -10
- package/package.json +1 -1
- package/src/QFChart.ts +1434 -1434
- package/src/components/SeriesRendererFactory.ts +38 -36
- package/src/components/renderers/LabelRenderer.ts +231 -0
- package/src/types.ts +206 -205
package/src/types.ts
CHANGED
|
@@ -1,205 +1,206 @@
|
|
|
1
|
-
import { EventBus } from './utils/EventBus';
|
|
2
|
-
|
|
3
|
-
export interface OHLCV {
|
|
4
|
-
time: number;
|
|
5
|
-
open: number;
|
|
6
|
-
high: number;
|
|
7
|
-
low: number;
|
|
8
|
-
close: number;
|
|
9
|
-
volume: number;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface IndicatorPoint {
|
|
13
|
-
time: number;
|
|
14
|
-
value: number | number[] | null;
|
|
15
|
-
options?: {
|
|
16
|
-
color?: string;
|
|
17
|
-
offset?: number;
|
|
18
|
-
wickcolor?: string;
|
|
19
|
-
bordercolor?: string;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export type IndicatorStyle =
|
|
24
|
-
| 'line'
|
|
25
|
-
| 'step'
|
|
26
|
-
| 'columns'
|
|
27
|
-
| 'histogram'
|
|
28
|
-
| 'circles'
|
|
29
|
-
| 'cross'
|
|
30
|
-
| 'background'
|
|
31
|
-
| 'shape'
|
|
32
|
-
| 'char'
|
|
33
|
-
| 'bar'
|
|
34
|
-
| 'candle'
|
|
35
|
-
| 'barcolor'
|
|
36
|
-
| 'fill'
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
1
|
+
import { EventBus } from './utils/EventBus';
|
|
2
|
+
|
|
3
|
+
export interface OHLCV {
|
|
4
|
+
time: number;
|
|
5
|
+
open: number;
|
|
6
|
+
high: number;
|
|
7
|
+
low: number;
|
|
8
|
+
close: number;
|
|
9
|
+
volume: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface IndicatorPoint {
|
|
13
|
+
time: number;
|
|
14
|
+
value: number | number[] | null;
|
|
15
|
+
options?: {
|
|
16
|
+
color?: string;
|
|
17
|
+
offset?: number;
|
|
18
|
+
wickcolor?: string;
|
|
19
|
+
bordercolor?: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type IndicatorStyle =
|
|
24
|
+
| 'line'
|
|
25
|
+
| 'step'
|
|
26
|
+
| 'columns'
|
|
27
|
+
| 'histogram'
|
|
28
|
+
| 'circles'
|
|
29
|
+
| 'cross'
|
|
30
|
+
| 'background'
|
|
31
|
+
| 'shape'
|
|
32
|
+
| 'char'
|
|
33
|
+
| 'bar'
|
|
34
|
+
| 'candle'
|
|
35
|
+
| 'barcolor'
|
|
36
|
+
| 'fill'
|
|
37
|
+
| 'label';
|
|
38
|
+
|
|
39
|
+
export interface IndicatorOptions {
|
|
40
|
+
style: IndicatorStyle;
|
|
41
|
+
color: string;
|
|
42
|
+
overlay?: boolean; // Override indicator-level overlay setting for this specific plot
|
|
43
|
+
offset?: number;
|
|
44
|
+
linewidth?: number;
|
|
45
|
+
smooth?: boolean;
|
|
46
|
+
shape?: string;
|
|
47
|
+
size?: string;
|
|
48
|
+
text?: string;
|
|
49
|
+
textcolor?: string;
|
|
50
|
+
location?: string;
|
|
51
|
+
width?: number;
|
|
52
|
+
height?: number;
|
|
53
|
+
wickcolor?: string;
|
|
54
|
+
bordercolor?: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface IndicatorPlot {
|
|
58
|
+
data?: IndicatorPoint[]; // Optional for fill plots
|
|
59
|
+
options: IndicatorOptions;
|
|
60
|
+
plot1?: string; // For fill plots: reference to first plot ID
|
|
61
|
+
plot2?: string; // For fill plots: reference to second plot ID
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// A collection of plots that make up a single indicator (e.g. MACD has macd line, signal line, histogram)
|
|
65
|
+
export interface Indicator {
|
|
66
|
+
id: string;
|
|
67
|
+
plots: { [name: string]: IndicatorPlot };
|
|
68
|
+
paneIndex: number;
|
|
69
|
+
height?: number; // Desired height in percentage (e.g. 15 for 15%)
|
|
70
|
+
collapsed?: boolean;
|
|
71
|
+
titleColor?: string;
|
|
72
|
+
controls?: {
|
|
73
|
+
collapse?: boolean;
|
|
74
|
+
maximize?: boolean;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface QFChartOptions {
|
|
79
|
+
title?: string; // Title for the main chart (e.g. "BTC/USDT")
|
|
80
|
+
titleColor?: string;
|
|
81
|
+
backgroundColor?: string;
|
|
82
|
+
upColor?: string;
|
|
83
|
+
downColor?: string;
|
|
84
|
+
fontColor?: string;
|
|
85
|
+
fontFamily?: string;
|
|
86
|
+
padding?: number; // Horizontal padding (empty candles on sides), defaults to 0.2
|
|
87
|
+
yAxisPadding?: number; // Vertical Y-axis padding in percentage (e.g., 5 = 5% padding), defaults to 5
|
|
88
|
+
yAxisMin?: number | 'auto'; // Fixed minimum value for main Y-axis, or 'auto' for dynamic
|
|
89
|
+
yAxisMax?: number | 'auto'; // Fixed maximum value for main Y-axis, or 'auto' for dynamic
|
|
90
|
+
yAxisLabelFormatter?: (value: number) => string; // Custom formatter function for Y-axis labels
|
|
91
|
+
yAxisDecimalPlaces?: number; // Number of decimal places for Y-axis labels. If undefined, auto-detected from data.
|
|
92
|
+
lastPriceLine?: {
|
|
93
|
+
// Configuration for the horizontal line showing the last price
|
|
94
|
+
visible?: boolean;
|
|
95
|
+
color?: string; // Defaults to current candle color or '#fff'
|
|
96
|
+
lineStyle?: 'solid' | 'dashed' | 'dotted'; // Defaults to 'dashed'
|
|
97
|
+
showCountdown?: boolean; // Show countdown to bar close
|
|
98
|
+
};
|
|
99
|
+
interval?: number; // Bar interval in milliseconds (required for countdown)
|
|
100
|
+
height?: string | number;
|
|
101
|
+
controls?: {
|
|
102
|
+
collapse?: boolean;
|
|
103
|
+
maximize?: boolean;
|
|
104
|
+
fullscreen?: boolean;
|
|
105
|
+
};
|
|
106
|
+
dataZoom?: {
|
|
107
|
+
visible?: boolean;
|
|
108
|
+
position?: 'top' | 'bottom';
|
|
109
|
+
height?: number; // height in %, default 6
|
|
110
|
+
start?: number; // 0-100, default 50
|
|
111
|
+
end?: number; // 0-100, default 100
|
|
112
|
+
zoomOnTouch?: boolean; // Enable inside zoom on touch devices, default true
|
|
113
|
+
};
|
|
114
|
+
databox?: {
|
|
115
|
+
position: 'floating' | 'left' | 'right';
|
|
116
|
+
triggerOn?: 'mousemove' | 'click' | 'none'; // When to show tooltip/crosshair, default 'mousemove'
|
|
117
|
+
};
|
|
118
|
+
layout?: {
|
|
119
|
+
mainPaneHeight: string; // e.g. "60%"
|
|
120
|
+
gap: number; // e.g. 5 (percent)
|
|
121
|
+
};
|
|
122
|
+
watermark?: boolean; // Default true
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Plugin System Types
|
|
126
|
+
|
|
127
|
+
export interface Coordinate {
|
|
128
|
+
x: number;
|
|
129
|
+
y: number;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface DataCoordinate {
|
|
133
|
+
timeIndex: number;
|
|
134
|
+
value: number;
|
|
135
|
+
paneIndex?: number; // Optional pane index
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface ChartContext {
|
|
139
|
+
// Core Access
|
|
140
|
+
getChart(): any; // echarts.ECharts instance
|
|
141
|
+
getMarketData(): OHLCV[];
|
|
142
|
+
getTimeToIndex(): Map<number, number>;
|
|
143
|
+
getOptions(): QFChartOptions;
|
|
144
|
+
|
|
145
|
+
// Event Bus
|
|
146
|
+
events: EventBus;
|
|
147
|
+
|
|
148
|
+
// Helpers
|
|
149
|
+
coordinateConversion: {
|
|
150
|
+
pixelToData: (point: Coordinate) => DataCoordinate | null;
|
|
151
|
+
dataToPixel: (point: DataCoordinate) => Coordinate | null;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// Interaction Control
|
|
155
|
+
disableTools(): void; // To disable other active tools
|
|
156
|
+
|
|
157
|
+
// Zoom Control
|
|
158
|
+
setZoom(start: number, end: number): void;
|
|
159
|
+
|
|
160
|
+
// Drawing Management
|
|
161
|
+
addDrawing(drawing: DrawingElement): void;
|
|
162
|
+
removeDrawing(id: string): void;
|
|
163
|
+
getDrawing(id: string): DrawingElement | undefined;
|
|
164
|
+
updateDrawing(drawing: DrawingElement): void;
|
|
165
|
+
|
|
166
|
+
// Interaction Locking
|
|
167
|
+
lockChart(): void;
|
|
168
|
+
unlockChart(): void;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export type DrawingType = 'line' | 'fibonacci';
|
|
172
|
+
|
|
173
|
+
export interface DrawingElement {
|
|
174
|
+
id: string;
|
|
175
|
+
type: DrawingType;
|
|
176
|
+
points: DataCoordinate[]; // [start, end]
|
|
177
|
+
paneIndex?: number; // Pane where this drawing belongs (default 0)
|
|
178
|
+
style?: {
|
|
179
|
+
color?: string;
|
|
180
|
+
lineWidth?: number;
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export interface PluginConfig {
|
|
185
|
+
id: string;
|
|
186
|
+
name?: string;
|
|
187
|
+
icon?: string;
|
|
188
|
+
hotkey?: string;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export interface Plugin {
|
|
192
|
+
id: string;
|
|
193
|
+
name?: string;
|
|
194
|
+
icon?: string;
|
|
195
|
+
|
|
196
|
+
init(context: ChartContext): void;
|
|
197
|
+
|
|
198
|
+
// Called when the tool button is clicked/activated
|
|
199
|
+
activate?(): void;
|
|
200
|
+
|
|
201
|
+
// Called when the tool is deactivated
|
|
202
|
+
deactivate?(): void;
|
|
203
|
+
|
|
204
|
+
// Cleanup when plugin is removed
|
|
205
|
+
destroy?(): void;
|
|
206
|
+
}
|