st-comp 0.0.146 → 0.0.147

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.
Files changed (148) hide show
  1. package/components.d.ts +0 -3
  2. package/es/ChartLayout.cjs +1 -1
  3. package/es/ChartLayout.js +2 -2
  4. package/es/Dialog.cjs +1 -1
  5. package/es/Dialog.js +22 -26
  6. package/es/FactorWarning.cjs +1 -1
  7. package/es/FactorWarning.js +103 -112
  8. package/es/KlineBasic.cjs +1 -1
  9. package/es/KlineBasic.js +1426 -671
  10. package/es/KlineNew.cjs +3 -1
  11. package/es/KlineNew.js +2736 -314
  12. package/es/Pagination.cjs +1 -1
  13. package/es/Pagination.js +96 -102
  14. package/es/Table.cjs +1 -1
  15. package/es/Table.js +60 -66
  16. package/es/User.cjs +1 -1
  17. package/es/User.js +96 -103
  18. package/es/VarietySearch.cjs +1 -1
  19. package/es/VarietySearch.js +32 -41
  20. package/es/VirtualTable.cjs +1 -13
  21. package/es/VirtualTable.js +1 -2801
  22. package/es/_initCloneObject-7493ecd5.cjs +1 -0
  23. package/es/{_initCloneObject-14b53c6f.js → _initCloneObject-a8dcd058.js} +26 -26
  24. package/es/{base-ec05f348.cjs → base-00ce90ec.cjs} +3 -3
  25. package/es/{base-437d17f3.js → base-674a354a.js} +63 -64
  26. package/es/config-provider-419ffbf2.js +120 -0
  27. package/es/config-provider-68414290.cjs +3 -0
  28. package/es/dropdown-127a8c0d.cjs +1 -0
  29. package/es/{dropdown-634b5e27.js → dropdown-ce30ada6.js} +30 -31
  30. package/es/el-button-7b9f5933.js +745 -0
  31. package/es/el-button-c00975e1.cjs +1 -0
  32. package/es/{el-checkbox-group-e8fece80.js → el-checkbox-group-0554b352.js} +10 -10
  33. package/es/el-checkbox-group-7a313d34.cjs +1 -0
  34. package/es/{el-empty-bacc6613.js → el-empty-39b3aed7.js} +5 -5
  35. package/es/{el-empty-19ea04f4.cjs → el-empty-87154b6d.cjs} +1 -1
  36. package/es/el-form-item-7867f64d.cjs +12 -0
  37. package/es/{el-form-item-af1855f0.js → el-form-item-fc6f80ab.js} +78 -79
  38. package/es/el-input-2ff1628c.cjs +1 -0
  39. package/es/{el-input-4961b99f.js → el-input-d249ac86.js} +82 -84
  40. package/es/{el-input-number-610fc8ba.js → el-input-number-2066fbb7.js} +35 -36
  41. package/es/el-input-number-d6801a5c.cjs +1 -0
  42. package/es/{el-message-c3b3ac96.js → el-message-9859835d.js} +79 -81
  43. package/es/el-message-ffcf690c.cjs +1 -0
  44. package/es/el-overlay-91784be2.cjs +1 -0
  45. package/es/el-overlay-f0757cc4.js +525 -0
  46. package/es/el-popover-4db657e2.cjs +1 -0
  47. package/es/{el-popover-0aa071f2.js → el-popover-b7b43c1f.js} +18 -18
  48. package/es/el-scrollbar-35bac6b3.js +2452 -0
  49. package/es/el-scrollbar-ec09bbd3.cjs +1 -0
  50. package/es/el-select-0785c35a.cjs +1 -0
  51. package/es/{el-select-9381b156.js → el-select-bcbb7e55.js} +329 -333
  52. package/es/el-table-column-2478adf8.cjs +14 -0
  53. package/es/{el-table-column-55bffba5.js → el-table-column-c1e1a206.js} +346 -350
  54. package/es/el-tag-13ee17b3.cjs +1 -0
  55. package/es/el-tag-73372c6c.js +359 -0
  56. package/es/index-07b61d12.cjs +1 -0
  57. package/es/{index-39ec9741.js → index-45de4a12.js} +7 -7
  58. package/es/index-65b719a4.cjs +1 -0
  59. package/es/index-8b5fbc11.js +66 -0
  60. package/es/index-8c85d7c5.js +858 -0
  61. package/es/index-a49f4743.cjs +2 -0
  62. package/es/{scroll-387fcfdb.js → scroll-cb696ed2.js} +1 -1
  63. package/es/{scroll-41224831.cjs → scroll-cca17da0.cjs} +1 -1
  64. package/es/style.css +1 -1
  65. package/es/{zh-cn-ab9a583d.cjs → zh-cn-37af467d.cjs} +1 -1
  66. package/es/{zh-cn-eb9c2820.js → zh-cn-ef7d7220.js} +2 -2
  67. package/lib/bundle.js +1 -1
  68. package/lib/bundle.umd.cjs +206 -206
  69. package/lib/{index-9b8ff62a.js → index-24f8572c.js} +31450 -33319
  70. package/lib/{python-a9c3d9e5.js → python-2143eee4.js} +1 -1
  71. package/lib/style.css +1 -1
  72. package/package.json +1 -1
  73. package/packages/KlineBasic/components/KlineSub/index.vue +17 -3
  74. package/packages/KlineBasic/index.vue +2 -1
  75. package/packages/KlineBasic/utils.js +20 -2
  76. package/packages/index.ts +0 -2
  77. package/src/pages/KlineBasic/api.js +1 -1
  78. package/src/router/routes.ts +0 -5
  79. package/es/Kline.cjs +0 -1
  80. package/es/Kline.js +0 -1901
  81. package/es/_initCloneObject-441db749.cjs +0 -1
  82. package/es/castArray-4251bbe4.js +0 -10
  83. package/es/castArray-a45823fe.cjs +0 -1
  84. package/es/config-provider-55482a43.js +0 -47
  85. package/es/config-provider-7cdfca4d.cjs +0 -1
  86. package/es/debounce-ac30be50.js +0 -83
  87. package/es/debounce-b2ff12bd.cjs +0 -1
  88. package/es/dropdown-d7c59a21.cjs +0 -1
  89. package/es/el-button-196807af.cjs +0 -1
  90. package/es/el-button-e1665717.js +0 -235
  91. package/es/el-checkbox-group-492b95cc.cjs +0 -1
  92. package/es/el-form-item-5bdffd07.cjs +0 -12
  93. package/es/el-input-23e2bac3.cjs +0 -1
  94. package/es/el-input-number-40a81eb5.cjs +0 -1
  95. package/es/el-menu-item-78b858f2.cjs +0 -1
  96. package/es/el-menu-item-7d04c11a.js +0 -771
  97. package/es/el-message-d4df8136.cjs +0 -1
  98. package/es/el-overlay-12dd9b35.js +0 -519
  99. package/es/el-overlay-bc0790a2.cjs +0 -1
  100. package/es/el-popover-8a77e015.cjs +0 -1
  101. package/es/el-popper-50100766.js +0 -2262
  102. package/es/el-popper-746070ba.cjs +0 -1
  103. package/es/el-scrollbar-562d0595.js +0 -201
  104. package/es/el-scrollbar-d1c3e7f7.cjs +0 -1
  105. package/es/el-select-b162dffc.cjs +0 -1
  106. package/es/el-table-column-6d761fce.cjs +0 -14
  107. package/es/el-tag-985d9aff.js +0 -279
  108. package/es/el-tag-c51a6490.cjs +0 -1
  109. package/es/index-09e01b1d.js +0 -81
  110. package/es/index-0cb48e01.js +0 -306
  111. package/es/index-3bf8d597.cjs +0 -1
  112. package/es/index-657047bb.js +0 -513
  113. package/es/index-8a0b1c53.cjs +0 -3
  114. package/es/index-a387515d.cjs +0 -1
  115. package/es/index-a902a0d9.js +0 -59
  116. package/es/index-deb8de52.cjs +0 -1
  117. package/es/index-eea0bcb3.cjs +0 -1
  118. package/es/index.esm-8d9a2abe.js +0 -2432
  119. package/es/index.esm-94a95a2a.cjs +0 -3
  120. package/es/raf-8fc301fd.cjs +0 -1
  121. package/es/raf-b128c7b7.js +0 -6
  122. package/es/typescript-7ae59c4c.js +0 -4
  123. package/es/typescript-b63f8e83.cjs +0 -1
  124. package/es/use-form-common-props-1b84d8f4.cjs +0 -2
  125. package/es/use-form-common-props-f377e500.js +0 -587
  126. package/es/vnode-7dfd4ed5.js +0 -14
  127. package/es/vnode-7fbc61e1.cjs +0 -1
  128. package/packages/Kline/components/Contextmenu/index.vue +0 -110
  129. package/packages/Kline/components/Tips/index.vue +0 -40
  130. package/packages/Kline/componentsNew/KlineSlide/index.vue +0 -155
  131. package/packages/Kline/componentsNew/KlineSub/index.vue +0 -297
  132. package/packages/Kline/componentsNew/KlineTips/index.vue +0 -66
  133. package/packages/Kline/componentsNew/KlineUtils/index.vue +0 -84
  134. package/packages/Kline/componentsNew/Tips/index.vue +0 -33
  135. package/packages/Kline/formatKlineData.ts +0 -109
  136. package/packages/Kline/images/buy.svg +0 -1
  137. package/packages/Kline/images/pen.png +0 -0
  138. package/packages/Kline/images/sell.svg +0 -1
  139. package/packages/Kline/images/t.svg +0 -1
  140. package/packages/Kline/index.ts +0 -16
  141. package/packages/Kline/index.vue +0 -891
  142. package/packages/Kline/option.ts +0 -539
  143. package/packages/Kline/type.d.ts +0 -219
  144. package/packages/Kline/utils.ts +0 -682
  145. package/src/pages/Kline/api.ts +0 -127
  146. package/src/pages/Kline/components/MultiCycleSingleVariety.vue +0 -701
  147. package/src/pages/Kline/components/SingleCycleSingleVariety.vue +0 -924
  148. package/src/pages/Kline/index.vue +0 -90
@@ -1,682 +0,0 @@
1
- import type { EChartsType, ElementEvent } from "echarts";
2
- import type {
3
- KlineDataType,
4
- WarningConfigType,
5
- PositionConfigType,
6
- ConditionConfigType,
7
- GraphicEvent,
8
- } from "./type.d.ts";
9
-
10
- // ------------------普通工具函数---------------------
11
-
12
- /**
13
- * @description: console方法封装
14
- * @param {String} message 消息文本
15
- * @param {Object} option 配置选项
16
- */
17
- export const printConsole = (message: string, option?: { type?: string; color?: string }) => {
18
- const { type = "log", color = "black" } = option ?? {};
19
- let isShow = localStorage.getItem("st-kline-console-show") === "true" ? true : false;
20
- isShow && console[type](`%c${message}`, `color:${color}`);
21
- };
22
-
23
- /**
24
- * @description: 格式化数字:保留后三位小数
25
- * @param {number} value
26
- * @return {*}
27
- */
28
- export const formatValue = (value: number) => {
29
- return value || value === 0 ? Math.round(value * 1000) / 1000 : null;
30
- };
31
-
32
- /**
33
- * @description: 格式化价格:万 || 亿 || 万亿
34
- * @param {number} value
35
- * @return {*}
36
- */
37
- export const formatPrice = (value: number) => {
38
- if (value >= 1000000000000) {
39
- return `${(value / 1000000000000).toFixed(2)}万亿`;
40
- } else if (value >= 100000000) {
41
- return `${(value / 100000000).toFixed(2)}亿`;
42
- } else if (value >= 10000) {
43
- return `${(value / 10000).toFixed(2)}万`;
44
- } else {
45
- return value.toFixed(2);
46
- }
47
- };
48
-
49
- // -----------------额外画线工具函数-------------------
50
- interface InfoType {
51
- info: any;
52
- config: WarningConfigType | PositionConfigType | ConditionConfigType;
53
- event: GraphicEvent;
54
- }
55
-
56
- // 单条线的配置-预警线
57
- interface warningParamsType {
58
- y: number;
59
- text: string;
60
- info: InfoType;
61
- gridLeft: number;
62
- gridRight: number;
63
- echartsWidth: number;
64
- echartsInstance: EChartsType;
65
- }
66
- export const getWarningItem = (params: warningParamsType) => {
67
- // 1.解构入参
68
- const { y, text, info, gridLeft, gridRight, echartsWidth, echartsInstance } = params;
69
- const { config, event } = info;
70
-
71
- let dragStart = 0; // 拖拽开始坐标
72
-
73
- // -----------------------------------return-------------------------------------------
74
- return {
75
- type: "group",
76
- draggable: config.draggable ? "vertical" : false,
77
- children: [
78
- {
79
- type: "line",
80
- info,
81
- shape: {
82
- x1: gridLeft,
83
- y1: y,
84
- x2: echartsWidth - gridRight,
85
- y2: y,
86
- },
87
- style: {
88
- stroke: config.lineColor,
89
- lineWidth: 1,
90
- lineDash: [8, 4],
91
- },
92
- z: 10,
93
- },
94
- {
95
- type: "group",
96
- x: echartsWidth,
97
- y: y - 5,
98
- children: [
99
- {
100
- type: "text",
101
- left: -1 * gridRight,
102
- info,
103
- style: {
104
- fill: config.textColor,
105
- text,
106
- stroke: "#000",
107
- lineWidth: 1,
108
- opacity: 1,
109
- },
110
- z: 10,
111
- },
112
- ],
113
- },
114
- ],
115
- // 事件:鼠标滑入
116
- onmouseover: (params: ElementEvent) => {
117
- if (event.onmouseover instanceof Function) {
118
- event.onmouseover(params, info);
119
- }
120
- },
121
- // 事件:鼠标滑出
122
- onmouseout: (params: ElementEvent) => {
123
- if (event.onmouseout instanceof Function) {
124
- event.onmouseout(params, info);
125
- }
126
- },
127
- // 事件:开始拖拽
128
- ondragstart: (params: ElementEvent) => {
129
- if (event.ondragstart instanceof Function && config.draggable) {
130
- dragStart = params.offsetY; // 记录拖拽开始坐标
131
- event.ondragstart(params, info);
132
- }
133
- },
134
- // 事件:结束拖拽
135
- ondragend: (params: ElementEvent) => {
136
- if (event.ondragend instanceof Function && config.draggable) {
137
- const dragEnd = params.offsetY; // 记录结束拖拽坐标
138
- const dragInterval = dragEnd - dragStart; // 拖拽偏移量
139
- if (dragInterval === 0) {
140
- return;
141
- }
142
- const yAxisValue = echartsInstance.convertFromPixel({ yAxisIndex: 0 }, y + dragInterval);
143
- event.ondragend(params, info, yAxisValue);
144
- }
145
- },
146
- };
147
- };
148
-
149
- // 单条线的配置-持仓线
150
- interface positionParamsType {
151
- y: number;
152
- text: string;
153
- info: InfoType;
154
- gridLeft: number;
155
- gridRight: number;
156
- echartsWidth: number;
157
- echartsInstance: EChartsType;
158
- }
159
- export const getPositionItem = (params: positionParamsType) => {
160
- // 1.解构入参
161
- const { y, text, info, gridLeft, gridRight, echartsWidth, echartsInstance } = params;
162
- const { config, event } = info;
163
-
164
- let dragStart = 0; // 拖拽开始坐标
165
-
166
- // --------------------默认鼠标滑入/滑出展示事件: 展示持仓线文本--------------------------
167
- const defaultOnMouseOver = (params: ElementEvent) => {
168
- let groupItem: any = null;
169
- if (params.target.type === "line") {
170
- groupItem = params.target.parent;
171
- } else if (params.target.type === "tspan") {
172
- groupItem = params.target.parent.parent.parent;
173
- }
174
- // 处理持仓线鼠标滑入时展示
175
- groupItem.children()[1].children()[0].animate("style", false).when(200, { opacity: 1 }).start();
176
- };
177
- const defaultOnMouseOut = (params: ElementEvent) => {
178
- let groupItem: any = null;
179
- if (params.target.type === "line") {
180
- groupItem = params.target.parent;
181
- } else if (params.target.type === "tspan") {
182
- groupItem = params.target.parent.parent.parent;
183
- }
184
- // 处理持仓线鼠标滑出时展示
185
- groupItem.children()[1].children()[0].animate("style", false).when(200, { opacity: 0 }).start();
186
- };
187
-
188
- // -----------------------------------return-------------------------------------------
189
- return {
190
- type: "group",
191
- draggable: config.draggable ? "vertical" : false, // 是否支持拖拽
192
- children: [
193
- {
194
- type: "line",
195
- info,
196
- shape: {
197
- x1: gridLeft,
198
- y1: y,
199
- x2: echartsWidth - gridRight,
200
- y2: y,
201
- },
202
- style: {
203
- stroke: config.lineColor,
204
- lineWidth: 1,
205
- },
206
- z: 10,
207
- },
208
- {
209
- type: "group",
210
- x: echartsWidth / 2,
211
- y: y - 5,
212
- children: [
213
- {
214
- type: "text",
215
- left: "center",
216
- info,
217
- style: {
218
- fill: config.textColor,
219
- text,
220
- stroke: "#000",
221
- lineWidth: 1,
222
- opacity: 0, //隐藏文本
223
- },
224
- z: 10,
225
- },
226
- ],
227
- },
228
- ],
229
- // 事件:鼠标滑入
230
- onmouseover: (params: ElementEvent) => {
231
- if (event.onmouseover instanceof Function) {
232
- event.onmouseover(params, info);
233
- } else {
234
- defaultOnMouseOver(params);
235
- }
236
- },
237
- // 事件:鼠标滑出
238
- onmouseout: (params: ElementEvent) => {
239
- if (event.onmouseout instanceof Function) {
240
- event.onmouseout(params, info);
241
- } else {
242
- defaultOnMouseOut(params);
243
- }
244
- },
245
- // 事件:开始拖拽
246
- ondragstart: (params: ElementEvent) => {
247
- if (event.ondragstart instanceof Function && config.draggable) {
248
- dragStart = params.offsetY; // 记录拖拽开始坐标
249
- event.ondragstart(params, info);
250
- }
251
- },
252
- // 事件:结束拖拽
253
- ondragend: (params: ElementEvent) => {
254
- if (event.ondragend instanceof Function && config.draggable) {
255
- const dragEnd = params.offsetY; // 记录结束拖拽坐标
256
- const dragInterval = dragEnd - dragStart; // 拖拽偏移量
257
- if (dragInterval === 0) {
258
- return;
259
- }
260
- const yAxisValue = echartsInstance.convertFromPixel({ yAxisIndex: 0 }, y + dragInterval);
261
- event.ondragend(params, info, yAxisValue);
262
- }
263
- },
264
- };
265
- };
266
-
267
- // 单条线的配置-条件单
268
- interface conditionParamsType {
269
- y: number;
270
- text: string;
271
- profitY: number;
272
- profitText: string;
273
- lossY: number;
274
- lossText: string;
275
- info: InfoType;
276
- gridLeft: number;
277
- gridRight: number;
278
- echartsWidth: number;
279
- echartsInstance: EChartsType;
280
- }
281
- export const getConditionItem = (params: conditionParamsType) => {
282
- // 1.解构入参
283
- const { y, text, profitY, profitText, lossY, lossText, info, gridLeft, gridRight, echartsWidth, echartsInstance } =
284
- params;
285
- const { config, event } = info;
286
-
287
- let dragStart = 0; // 拖拽开始坐标
288
-
289
- // --------------------默认鼠标滑入/滑出展示事件: alt展示盈亏线---------------------------
290
- // 键盘按下事件函数
291
- let handleKeyDown: any = null;
292
- // 键盘弹起函数
293
- let handleKeyUp: any = null;
294
- // [展示/隐藏]盈亏线
295
- const handleProfitLossShow = (groupItem: any, show: boolean) => {
296
- groupItem.children()[2]?.animate("style", false).when(200, { opacity: ~~show }).start();
297
- groupItem.children()[3].children()[0]?.animate("style", false).when(200, { opacity: ~~show }).start();
298
- groupItem.children()[4]?.animate("style", false).when(200, { opacity: ~~show }).start();
299
- groupItem.children()[5].children()[0]?.animate("style", false).when(200, { opacity: ~~show }).start();
300
- };
301
- // 默认的鼠标滑入事件
302
- const defaultOnMouseOver = (params: ElementEvent) => {
303
- let groupItem: any = null;
304
- if (params.target.type === "line") {
305
- groupItem = params.target.parent;
306
- } else if (params.target.type === "tspan") {
307
- groupItem = params.target.parent.parent.parent;
308
- }
309
- // 处理持仓线鼠标滑入+按下alt时展示
310
- handleKeyDown = (e) => {
311
- e.preventDefault();
312
- if (e.code === "AltLeft" || e.code === "AltRight") {
313
- handleProfitLossShow(groupItem, true);
314
- }
315
- };
316
- handleKeyUp = (e) => {
317
- if (e.code === "AltLeft" || e.code === "AltRight") {
318
- handleProfitLossShow(groupItem, false);
319
- }
320
- };
321
- window.addEventListener("keydown", handleKeyDown);
322
- window.addEventListener("keyup", handleKeyUp);
323
- };
324
- // 默认的鼠标滑出事件
325
- const defaultOnMouseOut = (params: ElementEvent) => {
326
- let groupItem: any = null;
327
- if (params.target.type === "line") {
328
- groupItem = params.target.parent;
329
- } else if (params.target.type === "tspan") {
330
- groupItem = params.target.parent.parent.parent;
331
- }
332
- // 处理持仓线鼠标滑出时展示
333
- handleProfitLossShow(groupItem, false);
334
- window.removeEventListener("keydown", handleKeyDown);
335
- window.removeEventListener("keyup", handleKeyUp);
336
- };
337
-
338
- // -----------------------------------return-------------------------------------------
339
- return {
340
- type: "group",
341
- draggable: config.draggable ? "vertical" : false, // 是否支持拖拽
342
- children: [
343
- // 条件单-主线
344
- {
345
- type: "line",
346
- info,
347
- shape: {
348
- x1: gridLeft,
349
- y1: y,
350
- x2: echartsWidth - gridRight,
351
- y2: y,
352
- },
353
- style: {
354
- stroke: config.lineColor,
355
- lineWidth: 1,
356
- },
357
- z: 10,
358
- },
359
- // 条件单-文本内容
360
- {
361
- type: "group",
362
- x: echartsWidth / 2,
363
- y: y - 5,
364
- children: [
365
- {
366
- type: "text",
367
- left: "center",
368
- info,
369
- style: {
370
- fill: config.textColor, // 填充色
371
- text: text,
372
- stroke: "#000", // 线条颜色
373
- lineWidth: 1,
374
- opacity: 1, //直接展示文本
375
- },
376
- z: 10,
377
- },
378
- ],
379
- },
380
- // 条件单-止盈线
381
- {
382
- type: "line",
383
- info,
384
- shape: {
385
- x1: gridLeft,
386
- y1: profitY,
387
- x2: echartsWidth - gridRight,
388
- y2: profitY,
389
- },
390
- style: {
391
- stroke: (config as ConditionConfigType).profitLineColor,
392
- lineWidth: 1,
393
- lineDash: [8, 4],
394
- opacity: 0,
395
- },
396
- z: 10,
397
- },
398
- // 条件单-止盈线文本内容
399
- {
400
- type: "group",
401
- x: echartsWidth / 2,
402
- y: profitY - 5,
403
- children: [
404
- {
405
- type: "text",
406
- left: "center",
407
- info,
408
- style: {
409
- fill: (config as ConditionConfigType).profitTextColor,
410
- text: profitText,
411
- stroke: "#000",
412
- lineWidth: 1,
413
- opacity: 0,
414
- },
415
- z: 10,
416
- },
417
- ],
418
- },
419
- // 条件单-止损线
420
- {
421
- type: "line",
422
- info,
423
- shape: {
424
- x1: gridLeft,
425
- y1: lossY,
426
- x2: echartsWidth - gridRight,
427
- y2: lossY,
428
- },
429
- style: {
430
- stroke: (config as ConditionConfigType).lossLineColor,
431
- lineWidth: 1,
432
- lineDash: [8, 4],
433
- opacity: 0,
434
- },
435
- z: 10,
436
- },
437
- // 条件单-止损线文本内容
438
- {
439
- type: "group",
440
- x: echartsWidth / 2,
441
- y: lossY - 5,
442
- children: [
443
- {
444
- type: "text",
445
- left: "center",
446
- info,
447
- style: {
448
- fill: (config as ConditionConfigType).lossTextColor,
449
- text: lossText,
450
- stroke: "#000",
451
- lineWidth: 1,
452
- opacity: 0,
453
- },
454
- z: 10,
455
- },
456
- ],
457
- },
458
- ],
459
- // 事件:鼠标滑入
460
- onmouseover: (params: ElementEvent) => {
461
- if (event.onmouseover instanceof Function) {
462
- event.onmouseover(params, info);
463
- } else {
464
- defaultOnMouseOver(params);
465
- }
466
- },
467
- // 事件:鼠标滑出
468
- onmouseout: (params: ElementEvent) => {
469
- if (event.onmouseout instanceof Function) {
470
- event.onmouseout(params, info);
471
- } else {
472
- defaultOnMouseOut(params);
473
- }
474
- },
475
- // 事件:开始拖拽
476
- ondragstart: (params: ElementEvent) => {
477
- if (event.ondragstart instanceof Function && config.draggable) {
478
- dragStart = params.offsetY; // 记录拖拽开始坐标
479
- event.ondragstart(params, info);
480
- }
481
- },
482
- // 事件:结束拖拽
483
- ondragend: (params: ElementEvent) => {
484
- if (event.ondragend instanceof Function && config.draggable) {
485
- const dragEnd = params.offsetY; // 记录结束拖拽坐标
486
- const dragInterval = dragEnd - dragStart; // 拖拽偏移量
487
- if (dragInterval === 0) {
488
- return;
489
- }
490
- const yAxisValue = echartsInstance.convertFromPixel({ yAxisIndex: 0 }, y + dragInterval);
491
- event.ondragend(params, info, yAxisValue);
492
- }
493
- },
494
- };
495
- };
496
-
497
- // -----------------点位处理工具函数--------------------
498
-
499
- /**
500
- * @description: 返回交易类型
501
- * @param {Object} data 单个点位数据
502
- * @param {String} type 买卖点[sellbuy], 开平点[openClose]
503
- * @returns {String} tradeType
504
- */
505
- const handleTradeType = (
506
- data: {
507
- direction?: string;
508
- tradeAction?: string;
509
- tradeType?: string;
510
- },
511
- type: string
512
- ) => {
513
- const { direction = "", tradeAction = "", tradeType = "" } = data;
514
- if (type === "sellBuy") {
515
- const key = tradeType ?? direction + tradeAction;
516
- const keyMap = new Map([
517
- ["开多", "买"],
518
- ["平多", "卖"],
519
- ["开空", "卖"],
520
- ["平空", "买"],
521
- ]);
522
- return keyMap.get(key);
523
- } else if (type === "openClose") {
524
- return tradeType ?? direction + tradeAction;
525
- }
526
- };
527
-
528
- /**
529
- * @description: 返回买卖点配置
530
- * @todo: 均标注在K线最上方
531
- */
532
- const handleSellBuyConfig = (data: any[], originData: KlineDataType) => {
533
- return data.reduce((result, next) => {
534
- // 1.获取交易类型
535
- const tradeType = handleTradeType(next, "sellBuy");
536
- /**
537
- * 2.获取标注图标
538
- * 因为传入参数数据时,已经对数据进行了合并处理,不会出现例如: 两个平空数据于一条K线上,这种情况,所以
539
- * 简单判断该条K线上是否有多个数据即可判断出是否是买卖同时存在,如果同时存在图标变成T
540
- */
541
- const timeTradeList = data.filter((item: any) => item.time === next.time)
542
- let symbol = "image://" + new URL(`./images/${tradeType === "买" ? "buy" : "sell"}.svg`, import.meta.url).href;
543
- if (timeTradeList.length > 1) {
544
- // 存在多条数据, 处理出他们的交易类型, 进行去重
545
- const timeTradeTypes = [...new Set(timeTradeList.map(i => handleTradeType(i, "sellBuy")))]
546
- if (timeTradeTypes.length > 1) {
547
- symbol = "image://" + new URL("./images/t.svg", import.meta.url).href;
548
- } else {
549
- symbol = "image://" + new URL(`./images/${tradeType === "买" ? "buy" : "sell"}.svg`, import.meta.url).href;
550
- }
551
- } else {
552
- symbol = "image://" + new URL(`./images/${tradeType === "买" ? "buy" : "sell"}.svg`, import.meta.url).href;
553
- }
554
- // 3.获取对应Y轴值
555
- const originDataItem = originData.find((item: any) => item[0] === next.time) ?? [];
556
- const yAxisValue = originDataItem[2];
557
- // 5.连线逻辑处理
558
- const markLineTarget =
559
- next?.markLineTarget?.map((target: { time: string; name: string; lineStyle: any }) => {
560
- const startX = next.time;
561
- const startY = yAxisValue + "";
562
- const endX = target.time;
563
- const endItem = originData.find((item: any) => item[0] === target.time)
564
- const endY = endItem ? endItem[3] : null;
565
- return [
566
- {
567
- coord: [startX, startY],
568
- lineStyle: target.lineStyle,
569
- },
570
- {
571
- coord: [endX, endY],
572
- },
573
- ];
574
- }) ?? null;
575
- result.push({
576
- symbol, // 图标
577
- symbolSize: 25, // 图标大小
578
- animation: false, // 是否展示动画
579
- coord: [next.time + "", yAxisValue], // X轴[时间],Y轴[最高价]
580
- symbolRotate: 0, // 旋转角度
581
- symbolOffset: [0, "-7"], // 偏移距离
582
- markLineTarget,
583
- });
584
- return result;
585
- }, []);
586
- };
587
-
588
- /**
589
- * @description: 返回开平点配置
590
- * @todo: 开标注在K线最上方,平标注在K线最下方
591
- */
592
- const handleOpenCloseConfig = (data: any[], originData: KlineDataType) => {
593
- return data.reduce((result, next, index) => {
594
- // 1.获取交易类型
595
- const tradeType = handleTradeType(next, "openClose");
596
- // 2.确定位置
597
- const position = tradeType === "开多" || tradeType === "开空" ? "top" : "bottom";
598
- // 3.获取对应Y轴值
599
- const originDataItem = originData.find((item: any) => item[0] === next.time) ?? [];
600
- const yAxisValue = position === "top" ? originDataItem[2] : originDataItem[3];
601
- // 4.计算偏移量,避免点位重叠
602
- let offset = 7;
603
- offset +=
604
- data.slice(0, index).filter((item: any) => {
605
- const itemTradeType = handleTradeType(item, "openClose");
606
- const itemPosition = itemTradeType === "开多" || itemTradeType === "开空" ? "top" : "bottom";
607
- return itemPosition === position && item.time === next.time;
608
- }).length * 7;
609
- // 5.连线逻辑处理
610
- const markLineTarget =
611
- next?.markLineTarget?.map((target: { time: string; name: string; lineStyle: any }) => {
612
- const startX = next.time;
613
- const startY = yAxisValue + "";
614
- const endX = target.time;
615
- const endY = originData.find((item: any) => item[0] === target.time)[3];
616
- return [
617
- {
618
- coord: [startX, startY],
619
- lineStyle: target.lineStyle,
620
- },
621
- {
622
- coord: [endX, endY],
623
- },
624
- ];
625
- }) ?? null;
626
- result.push({
627
- symbol: "triangle", // 图标
628
- symbolSize: [10, 12], // 图标大小
629
- animation: false, // 是否展示动画
630
- coord: [next.time + "", yAxisValue], // X轴[时间],Y轴[最高价||最低价]
631
- symbolRotate: position === "top" ? 180 : 0, //标注旋转角度
632
- symbolOffset: [0, `${position === "top" ? offset * -1 : offset}`], //标注偏移距离
633
- itemStyle: { color: position === "top" ? "#FF0000" : "#389e0d" }, // 图标颜色
634
- // 文本
635
- label: {
636
- show: true, // 是否展示
637
- position,
638
- color: "#fff",
639
- formatter: `${tradeType} ${position === "top" ? "+" : "-"} ${next.amount}手 ${
640
- next.part ? `(${next.part}份)` : ""
641
- }`,
642
- },
643
- markLineTarget,
644
- });
645
- return result;
646
- }, []);
647
- };
648
-
649
- /**
650
- * @description: 返回点位配置
651
- * @param {Array} markData 点位数据
652
- * @param {Array} originData K线源数据
653
- */
654
- export const handlePoint = (markData, originData: KlineDataType) => {
655
- return markData.reduce((result, next) => {
656
- const { key, data } = next;
657
- // 无数据直接循环下一组数据
658
- if (data === null || data.length === 0) return result;
659
- // 点位数据转换配置项结构
660
- const configMap = new Map([
661
- // 买卖点
662
- [
663
- "sellBuy",
664
- () => {
665
- return handleSellBuyConfig(data, originData);
666
- },
667
- ],
668
- // 开平点
669
- [
670
- "openClose",
671
- () => {
672
- return handleOpenCloseConfig(data, originData);
673
- },
674
- ],
675
- // 信号点
676
- ["signal", () => {}],
677
- ]);
678
- const callBack = configMap.get(key);
679
- if (callBack instanceof Function) result.push(...callBack());
680
- return result;
681
- }, []);
682
- };