@qfo/qfchart 0.6.7 → 0.7.1
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 +4 -1
- package/dist/qfchart.min.browser.js +14 -14
- package/dist/qfchart.min.es.js +14 -14
- package/package.json +81 -81
- package/src/QFChart.ts +52 -0
- package/src/components/LayoutManager.ts +682 -679
- package/src/components/SeriesBuilder.ts +260 -250
- package/src/components/SeriesRendererFactory.ts +8 -0
- package/src/components/TableOverlayRenderer.ts +322 -0
- package/src/components/renderers/BoxRenderer.ts +258 -0
- package/src/components/renderers/DrawingLineRenderer.ts +194 -0
- package/src/components/renderers/FillRenderer.ts +99 -99
- package/src/components/renderers/LabelRenderer.ts +85 -41
- package/src/components/renderers/LinefillRenderer.ts +155 -0
- package/src/components/renderers/PolylineRenderer.ts +197 -0
- package/src/components/renderers/SeriesRenderer.ts +21 -20
- package/src/components/renderers/ShapeRenderer.ts +121 -121
- package/src/types.ts +2 -1
- package/src/utils/ShapeUtils.ts +156 -140
package/src/utils/ShapeUtils.ts
CHANGED
|
@@ -1,140 +1,156 @@
|
|
|
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
|
-
|
|
12
|
-
return 'path://M12 24l-12-12h8v-12h8v12h8z';
|
|
13
|
-
|
|
14
|
-
case 'arrowup':
|
|
15
|
-
|
|
16
|
-
return 'path://M12 0l12 12h-8v12h-8v-12h-8z';
|
|
17
|
-
|
|
18
|
-
case 'circle':
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
case '
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
case '
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
case '
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return '
|
|
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
|
-
case '
|
|
127
|
-
// Shape
|
|
128
|
-
return { position: 'top', distance: 5 };
|
|
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
|
+
case 'shape_arrow_down':
|
|
12
|
+
return 'path://M12 24l-12-12h8v-12h8v12h8z';
|
|
13
|
+
|
|
14
|
+
case 'arrowup':
|
|
15
|
+
case 'shape_arrow_up':
|
|
16
|
+
return 'path://M12 0l12 12h-8v12h-8v-12h-8z';
|
|
17
|
+
|
|
18
|
+
case 'circle':
|
|
19
|
+
case 'shape_circle':
|
|
20
|
+
return 'circle';
|
|
21
|
+
|
|
22
|
+
case 'cross':
|
|
23
|
+
case 'shape_cross':
|
|
24
|
+
return 'path://M11 2h2v9h9v2h-9v9h-2v-9h-9v-2h9z';
|
|
25
|
+
|
|
26
|
+
case 'diamond':
|
|
27
|
+
case 'shape_diamond':
|
|
28
|
+
return 'diamond';
|
|
29
|
+
|
|
30
|
+
case 'flag':
|
|
31
|
+
case 'shape_flag':
|
|
32
|
+
return 'path://M6 2v20h2v-8h12l-2-6 2-6h-12z';
|
|
33
|
+
|
|
34
|
+
case 'labeldown':
|
|
35
|
+
case 'shape_label_down':
|
|
36
|
+
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';
|
|
37
|
+
|
|
38
|
+
case 'labelleft':
|
|
39
|
+
case 'shape_label_left':
|
|
40
|
+
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';
|
|
41
|
+
|
|
42
|
+
case 'labelright':
|
|
43
|
+
case 'shape_label_right':
|
|
44
|
+
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';
|
|
45
|
+
|
|
46
|
+
case 'labelup':
|
|
47
|
+
case 'shape_label_up':
|
|
48
|
+
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';
|
|
49
|
+
|
|
50
|
+
case 'square':
|
|
51
|
+
case 'shape_square':
|
|
52
|
+
return 'rect';
|
|
53
|
+
|
|
54
|
+
case 'triangledown':
|
|
55
|
+
case 'shape_triangle_down':
|
|
56
|
+
return 'path://M12 21l-10-18h20z';
|
|
57
|
+
|
|
58
|
+
case 'triangleup':
|
|
59
|
+
case 'shape_triangle_up':
|
|
60
|
+
return 'triangle';
|
|
61
|
+
|
|
62
|
+
case 'xcross':
|
|
63
|
+
case 'shape_xcross':
|
|
64
|
+
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';
|
|
65
|
+
|
|
66
|
+
default:
|
|
67
|
+
return 'circle';
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public static getShapeRotation(shape: string): number {
|
|
72
|
+
// With custom paths defined above, we might not need rotation unless we reuse shapes.
|
|
73
|
+
// Built-in triangle is UP.
|
|
74
|
+
return 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public static getShapeSize(size: string, width?: number, height?: number): number | number[] {
|
|
78
|
+
// If both width and height are specified, use them directly
|
|
79
|
+
if (width !== undefined && height !== undefined) {
|
|
80
|
+
return [width, height];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Base size from the size parameter
|
|
84
|
+
let baseSize: number;
|
|
85
|
+
switch (size) {
|
|
86
|
+
case 'tiny':
|
|
87
|
+
baseSize = 8;
|
|
88
|
+
break;
|
|
89
|
+
case 'small':
|
|
90
|
+
baseSize = 12;
|
|
91
|
+
break;
|
|
92
|
+
case 'normal':
|
|
93
|
+
case 'auto':
|
|
94
|
+
baseSize = 16;
|
|
95
|
+
break;
|
|
96
|
+
case 'large':
|
|
97
|
+
baseSize = 24;
|
|
98
|
+
break;
|
|
99
|
+
case 'huge':
|
|
100
|
+
baseSize = 32;
|
|
101
|
+
break;
|
|
102
|
+
default:
|
|
103
|
+
baseSize = 16;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// If only width is specified, preserve aspect ratio (assume square default)
|
|
107
|
+
if (width !== undefined) {
|
|
108
|
+
return [width, width];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// If only height is specified, preserve aspect ratio (assume square default)
|
|
112
|
+
if (height !== undefined) {
|
|
113
|
+
return [height, height];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Default uniform size
|
|
117
|
+
return baseSize;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Helper to determine label position and distance relative to shape BASED ON LOCATION
|
|
121
|
+
public static getLabelConfig(shape: string, location: string): { position: string; distance: number } {
|
|
122
|
+
// Text position should be determined by location, not shape direction
|
|
123
|
+
|
|
124
|
+
switch (location) {
|
|
125
|
+
case 'abovebar':
|
|
126
|
+
case 'AboveBar':
|
|
127
|
+
// Shape is above the candle, text should be above the shape
|
|
128
|
+
return { position: 'top', distance: 5 };
|
|
129
|
+
|
|
130
|
+
case 'belowbar':
|
|
131
|
+
case 'BelowBar':
|
|
132
|
+
// Shape is below the candle, text should be below the shape
|
|
133
|
+
return { position: 'bottom', distance: 5 };
|
|
134
|
+
|
|
135
|
+
case 'top':
|
|
136
|
+
case 'Top':
|
|
137
|
+
// Shape at top of chart, text below it
|
|
138
|
+
return { position: 'bottom', distance: 5 };
|
|
139
|
+
|
|
140
|
+
case 'bottom':
|
|
141
|
+
case 'Bottom':
|
|
142
|
+
// Shape at bottom of chart, text above it
|
|
143
|
+
return { position: 'top', distance: 5 };
|
|
144
|
+
|
|
145
|
+
case 'absolute':
|
|
146
|
+
case 'Absolute':
|
|
147
|
+
default:
|
|
148
|
+
// For labelup/down, text is INSIDE the shape
|
|
149
|
+
if (shape === 'labelup' || shape === 'labeldown' || shape === 'shape_label_up' || shape === 'shape_label_down') {
|
|
150
|
+
return { position: 'inside', distance: 0 };
|
|
151
|
+
}
|
|
152
|
+
// For other shapes, text above by default
|
|
153
|
+
return { position: 'top', distance: 5 };
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|