@qfo/qfchart 0.6.6 → 0.6.8
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 +16 -16
- package/dist/qfchart.min.es.js +16 -16
- package/package.json +81 -81
- package/src/QFChart.ts +1434 -1434
- package/src/components/SeriesBuilder.ts +251 -250
- package/src/components/SeriesRendererFactory.ts +42 -36
- package/src/components/renderers/DrawingLineRenderer.ts +188 -0
- package/src/components/renderers/FillRenderer.ts +99 -99
- package/src/components/renderers/LabelRenderer.ts +274 -0
- package/src/components/renderers/LinefillRenderer.ts +167 -0
- package/src/components/renderers/SeriesRenderer.ts +21 -20
- package/src/types.ts +207 -205
- package/src/utils/ShapeUtils.ts +148 -140
package/src/utils/ShapeUtils.ts
CHANGED
|
@@ -1,140 +1,148 @@
|
|
|
1
|
-
export class ShapeUtils {
|
|
2
|
-
public static getShapeSymbol(shape: string): string {
|
|
3
|
-
// SVG Paths need to be:
|
|
4
|
-
// 1. Valid SVG path data strings
|
|
5
|
-
// 2. Ideally centered around the origin or a standard box (e.g., 0 0 24 24)
|
|
6
|
-
// 3. ECharts path:// format expects just the path data usually, but complex shapes might need 'image://' or better paths.
|
|
7
|
-
// For simple shapes, standard ECharts symbols or simple paths work.
|
|
8
|
-
|
|
9
|
-
switch (shape) {
|
|
10
|
-
case 'arrowdown':
|
|
11
|
-
// Blocky arrow down
|
|
12
|
-
return 'path://M12 24l-12-12h8v-12h8v12h8z';
|
|
13
|
-
|
|
14
|
-
case 'arrowup':
|
|
15
|
-
// Blocky arrow up
|
|
16
|
-
return 'path://M12 0l12 12h-8v12h-8v-12h-8z';
|
|
17
|
-
|
|
18
|
-
case 'circle':
|
|
19
|
-
return 'circle';
|
|
20
|
-
|
|
21
|
-
case 'cross':
|
|
22
|
-
// Plus sign (+)
|
|
23
|
-
return 'path://M11 2h2v9h9v2h-9v9h-2v-9h-9v-2h9z';
|
|
24
|
-
|
|
25
|
-
case 'diamond':
|
|
26
|
-
return 'diamond'; // Built-in
|
|
27
|
-
|
|
28
|
-
case 'flag':
|
|
29
|
-
// Flag on a pole
|
|
30
|
-
return 'path://M6 2v20h2v-8h12l-2-6 2-6h-12z';
|
|
31
|
-
|
|
32
|
-
case 'labeldown':
|
|
33
|
-
// Bubble pointing down:
|
|
34
|
-
return 'path://
|
|
35
|
-
|
|
36
|
-
case '
|
|
37
|
-
// Bubble
|
|
38
|
-
return 'path://
|
|
39
|
-
|
|
40
|
-
case '
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return '
|
|
50
|
-
|
|
51
|
-
case '
|
|
52
|
-
//
|
|
53
|
-
return 'path://
|
|
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
|
-
case '
|
|
123
|
-
// Shape
|
|
124
|
-
return { position: '
|
|
125
|
-
|
|
126
|
-
case '
|
|
127
|
-
// Shape
|
|
128
|
-
return { position: '
|
|
129
|
-
|
|
130
|
-
case '
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
1
|
+
export class ShapeUtils {
|
|
2
|
+
public static getShapeSymbol(shape: string): string {
|
|
3
|
+
// SVG Paths need to be:
|
|
4
|
+
// 1. Valid SVG path data strings
|
|
5
|
+
// 2. Ideally centered around the origin or a standard box (e.g., 0 0 24 24)
|
|
6
|
+
// 3. ECharts path:// format expects just the path data usually, but complex shapes might need 'image://' or better paths.
|
|
7
|
+
// For simple shapes, standard ECharts symbols or simple paths work.
|
|
8
|
+
|
|
9
|
+
switch (shape) {
|
|
10
|
+
case 'arrowdown':
|
|
11
|
+
// Blocky arrow down
|
|
12
|
+
return 'path://M12 24l-12-12h8v-12h8v12h8z';
|
|
13
|
+
|
|
14
|
+
case 'arrowup':
|
|
15
|
+
// Blocky arrow up
|
|
16
|
+
return 'path://M12 0l12 12h-8v12h-8v-12h-8z';
|
|
17
|
+
|
|
18
|
+
case 'circle':
|
|
19
|
+
return 'circle';
|
|
20
|
+
|
|
21
|
+
case 'cross':
|
|
22
|
+
// Plus sign (+)
|
|
23
|
+
return 'path://M11 2h2v9h9v2h-9v9h-2v-9h-9v-2h9z';
|
|
24
|
+
|
|
25
|
+
case 'diamond':
|
|
26
|
+
return 'diamond'; // Built-in
|
|
27
|
+
|
|
28
|
+
case 'flag':
|
|
29
|
+
// Flag on a pole
|
|
30
|
+
return 'path://M6 2v20h2v-8h12l-2-6 2-6h-12z';
|
|
31
|
+
|
|
32
|
+
case 'labeldown':
|
|
33
|
+
// Bubble pointing down: rect with small triangle at bottom center
|
|
34
|
+
return 'path://M2 1h20a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1h-8l-2 3-2-3h-8a1 1 0 0 1-1-1v-14a1 1 0 0 1 1-1z';
|
|
35
|
+
|
|
36
|
+
case 'labelleft':
|
|
37
|
+
// Bubble with small pointer on the left side (pointing left)
|
|
38
|
+
return 'path://M0 10l3-3v-5a1 1 0 0 1 1-1h18a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1h-18a1 1 0 0 1-1-1v-5z';
|
|
39
|
+
|
|
40
|
+
case 'labelright':
|
|
41
|
+
// Bubble with small pointer on the right side (pointing right)
|
|
42
|
+
return 'path://M24 10l-3-3v-5a1 1 0 0 0-1-1h-18a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h18a1 1 0 0 0 1-1v-5z';
|
|
43
|
+
|
|
44
|
+
case 'labelup':
|
|
45
|
+
// Bubble pointing up: small triangle at top, rect below
|
|
46
|
+
return 'path://M12 1l2 3h8a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1h-20a1 1 0 0 1-1-1v-14a1 1 0 0 1 1-1h8z';
|
|
47
|
+
|
|
48
|
+
case 'square':
|
|
49
|
+
return 'rect';
|
|
50
|
+
|
|
51
|
+
case 'triangledown':
|
|
52
|
+
// Pointing down
|
|
53
|
+
return 'path://M12 21l-10-18h20z';
|
|
54
|
+
|
|
55
|
+
case 'triangleup':
|
|
56
|
+
// Pointing up
|
|
57
|
+
return 'triangle'; // Built-in is pointing up
|
|
58
|
+
|
|
59
|
+
case 'xcross':
|
|
60
|
+
// 'X' shape
|
|
61
|
+
return 'path://M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z';
|
|
62
|
+
|
|
63
|
+
default:
|
|
64
|
+
return 'circle';
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public static getShapeRotation(shape: string): number {
|
|
69
|
+
// With custom paths defined above, we might not need rotation unless we reuse shapes.
|
|
70
|
+
// Built-in triangle is UP.
|
|
71
|
+
return 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public static getShapeSize(size: string, width?: number, height?: number): number | number[] {
|
|
75
|
+
// If both width and height are specified, use them directly
|
|
76
|
+
if (width !== undefined && height !== undefined) {
|
|
77
|
+
return [width, height];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Base size from the size parameter
|
|
81
|
+
let baseSize: number;
|
|
82
|
+
switch (size) {
|
|
83
|
+
case 'tiny':
|
|
84
|
+
baseSize = 8;
|
|
85
|
+
break;
|
|
86
|
+
case 'small':
|
|
87
|
+
baseSize = 12;
|
|
88
|
+
break;
|
|
89
|
+
case 'normal':
|
|
90
|
+
case 'auto':
|
|
91
|
+
baseSize = 16;
|
|
92
|
+
break;
|
|
93
|
+
case 'large':
|
|
94
|
+
baseSize = 24;
|
|
95
|
+
break;
|
|
96
|
+
case 'huge':
|
|
97
|
+
baseSize = 32;
|
|
98
|
+
break;
|
|
99
|
+
default:
|
|
100
|
+
baseSize = 16;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// If only width is specified, preserve aspect ratio (assume square default)
|
|
104
|
+
if (width !== undefined) {
|
|
105
|
+
return [width, width];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// If only height is specified, preserve aspect ratio (assume square default)
|
|
109
|
+
if (height !== undefined) {
|
|
110
|
+
return [height, height];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Default uniform size
|
|
114
|
+
return baseSize;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Helper to determine label position and distance relative to shape BASED ON LOCATION
|
|
118
|
+
public static getLabelConfig(shape: string, location: string): { position: string; distance: number } {
|
|
119
|
+
// Text position should be determined by location, not shape direction
|
|
120
|
+
|
|
121
|
+
switch (location) {
|
|
122
|
+
case 'abovebar':
|
|
123
|
+
// Shape is above the candle, text should be above the shape
|
|
124
|
+
return { position: 'top', distance: 5 };
|
|
125
|
+
|
|
126
|
+
case 'belowbar':
|
|
127
|
+
// Shape is below the candle, text should be below the shape
|
|
128
|
+
return { position: 'bottom', distance: 5 };
|
|
129
|
+
|
|
130
|
+
case 'top':
|
|
131
|
+
// Shape at top of chart, text below it
|
|
132
|
+
return { position: 'bottom', distance: 5 };
|
|
133
|
+
|
|
134
|
+
case 'bottom':
|
|
135
|
+
// Shape at bottom of chart, text above it
|
|
136
|
+
return { position: 'top', distance: 5 };
|
|
137
|
+
|
|
138
|
+
case 'absolute':
|
|
139
|
+
default:
|
|
140
|
+
// For labelup/down, text is INSIDE the shape
|
|
141
|
+
if (shape === 'labelup' || shape === 'labeldown') {
|
|
142
|
+
return { position: 'inside', distance: 0 };
|
|
143
|
+
}
|
|
144
|
+
// For other shapes, text above by default
|
|
145
|
+
return { position: 'top', distance: 5 };
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|