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