st-comp 0.0.277 → 0.0.279
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/README.md +19 -19
- package/es/ChartLayout.cjs +1 -1
- package/es/ChartLayout.js +1 -1
- package/es/ConfigProvider.cjs +1 -1
- package/es/ConfigProvider.js +3 -3
- package/es/Contextmenu.cjs +1 -1
- package/es/Contextmenu.js +7 -7
- package/es/CustomFunction.cjs +2 -2
- package/es/CustomFunction.js +514 -308
- package/es/FactorWarning.cjs +1 -1
- package/es/FactorWarning.js +37 -37
- package/es/HeatMap.cjs +1 -1
- package/es/HeatMap.js +7 -7
- package/es/Kline.cjs +1 -1
- package/es/Kline.js +18 -18
- package/es/KlineBasic.cjs +1 -1
- package/es/KlineBasic.js +93 -93
- package/es/KlineConfig.cjs +1 -1
- package/es/KlineConfig.js +17 -17
- package/es/KlineNew.cjs +1 -1
- package/es/KlineNew.js +14 -14
- package/es/KlinePlus.cjs +4 -4
- package/es/KlinePlus.js +760 -656
- package/es/LinearLegend.cjs +1 -1
- package/es/LinearLegend.js +1 -1
- package/es/Map.cjs +1 -1
- package/es/Map.js +1 -1
- package/es/MonacoEditor.cjs +1 -1
- package/es/MonacoEditor.js +18 -18
- package/es/Pagination.cjs +1 -1
- package/es/Pagination.js +76 -76
- package/es/PasswordPrompt.cjs +1 -1
- package/es/PasswordPrompt.js +2 -2
- package/es/Pie.cjs +2 -2
- package/es/Pie.js +14 -14
- package/es/Table.cjs +1 -1
- package/es/Table.js +22 -22
- package/es/TreeMap.cjs +1 -1
- package/es/TreeMap.js +4 -4
- package/es/User.cjs +1 -1
- package/es/User.js +73 -73
- package/es/VarSelectDialog.cjs +2 -2
- package/es/VarSelectDialog.js +21 -21
- package/es/VarietyAiHelper.cjs +4 -4
- package/es/VarietyAiHelper.js +139 -138
- package/es/VarietyAutoComplete.cjs +1 -1
- package/es/VarietyAutoComplete.js +16 -16
- package/es/VarietySearch.cjs +4 -4
- package/es/VarietySearch.js +861 -857
- package/es/{VarietySelect-6a166293.js → VarietySelect-41daac7b.js} +10 -10
- package/es/{VarietySelect-610903f0.cjs → VarietySelect-d58eee29.cjs} +1 -1
- package/es/VarietyTextCopy.cjs +2 -2
- package/es/VarietyTextCopy.js +25 -25
- package/es/VirtualTable.cjs +1 -1
- package/es/VirtualTable.js +6 -6
- package/es/{_initCloneObject-152b4f4e.js → _initCloneObject-5e73c9c8.js} +2 -2
- package/es/{_initCloneObject-76e116d0.cjs → _initCloneObject-a5832933.cjs} +1 -1
- package/es/aiTools-229609fb.cjs +2 -0
- package/es/aiTools-ce2f9281.js +115 -0
- package/es/aiTools.js +179 -176
- package/es/{config-provider-4c784baf.cjs → config-provider-06ea6b42.cjs} +1 -1
- package/es/{config-provider-7a3aca55.js → config-provider-88b637a8.js} +3 -3
- package/es/{dropdown-987c47fb.cjs → dropdown-4ce4c3e2.cjs} +1 -1
- package/es/{dropdown-01e09205.js → dropdown-72fbc15d.js} +2 -2
- package/es/{el-autocomplete-342ae823.js → el-autocomplete-6cafcdf1.js} +5 -5
- package/es/{el-autocomplete-16f66b34.cjs → el-autocomplete-e0857c5b.cjs} +1 -1
- package/es/{el-button-13dc915f.cjs → el-button-613e0bb2.cjs} +1 -1
- package/es/{el-button-314171a0.js → el-button-94d3de38.js} +3 -3
- package/es/{el-checkbox-5899681f.js → el-checkbox-6d4cb393.js} +3 -3
- package/es/{el-checkbox-bdf64663.cjs → el-checkbox-e90762df.cjs} +1 -1
- package/es/{el-dialog-0ef95df6.cjs → el-dialog-02942e22.cjs} +1 -1
- package/es/{el-dialog-86a3eec2.js → el-dialog-5e30161f.js} +4 -4
- package/es/{el-form-item-77ef6784.cjs → el-form-item-44f060d8.cjs} +1 -1
- package/es/{el-form-item-cda4d93c.js → el-form-item-9e8969ea.js} +5 -5
- package/es/{el-input-fa1445ad.js → el-input-342b2def.js} +13 -13
- package/es/{el-input-89222943.cjs → el-input-9a9a7f7f.cjs} +1 -1
- package/es/{el-input-number-d3338e5e.cjs → el-input-number-65c847d6.cjs} +1 -1
- package/es/{el-input-number-8f6dbf74.js → el-input-number-c22b803a.js} +35 -35
- package/es/{el-loading-84dde1a8.cjs → el-loading-8179b497.cjs} +1 -1
- package/es/{el-loading-9b671203.js → el-loading-bcc51e3d.js} +1 -1
- package/es/{el-menu-item-535fef90.js → el-menu-item-339baf6d.js} +21 -21
- package/es/{el-menu-item-4531fd0e.cjs → el-menu-item-83186444.cjs} +1 -1
- package/es/{el-message-box-621ed2f1.js → el-message-box-035b699c.js} +9 -9
- package/es/{el-message-box-f5717070.cjs → el-message-box-c62d3217.cjs} +1 -1
- package/es/{el-overlay-23de4324.js → el-overlay-3e17604b.js} +3 -3
- package/es/{el-overlay-151708cb.cjs → el-overlay-8f1da9e8.cjs} +1 -1
- package/es/{el-popconfirm-b8aa490e.cjs → el-popconfirm-4e32ec1b.cjs} +1 -1
- package/es/{el-popconfirm-bcff0aa5.js → el-popconfirm-f8a86e2c.js} +4 -4
- package/es/{el-popper-43ec37f4.cjs → el-popper-a4f3ae4d.cjs} +1 -1
- package/es/{el-popper-03988662.js → el-popper-fbd0dcea.js} +1 -1
- package/es/{el-segmented-db3a86be.js → el-segmented-56bd58a8.js} +2 -2
- package/es/{el-segmented-79a1367c.cjs → el-segmented-833ac177.cjs} +1 -1
- package/es/{el-select-4bd0010d.js → el-select-44fa547d.js} +8 -8
- package/es/{el-select-ec04e7ce.cjs → el-select-70806166.cjs} +1 -1
- package/es/{el-table-column-35e47229.cjs → el-table-column-3e2cdfca.cjs} +1 -1
- package/es/{el-table-column-7af2bec7.js → el-table-column-b74a857d.js} +9 -9
- package/es/{el-tag-bef9e83d.js → el-tag-66c83156.js} +2 -2
- package/es/{el-tag-5d5608e0.cjs → el-tag-9c2f329f.cjs} +1 -1
- package/es/{el-text-f998902c.js → el-text-034bd3f4.js} +1 -1
- package/es/{el-text-abf10fdf.cjs → el-text-6b2374bb.cjs} +1 -1
- package/es/index-00f6ca75.cjs +1 -0
- package/es/{index-a00e0534.cjs → index-185792a7.cjs} +1 -1
- package/es/{index-d1b554ac.js → index-1e2a38ab.js} +2 -2
- package/es/{index-0986e373.cjs → index-3153c1db.cjs} +1 -1
- package/es/{index-936e7dec.js → index-44a382a5.js} +2 -2
- package/es/{index-ce21e2ce.js → index-5216d5f5.js} +5 -5
- package/es/{index-7ed0999e.js → index-53cc4e43.js} +720 -716
- package/es/{index-cfcd60ca.cjs → index-5c0dd943.cjs} +1 -1
- package/es/{index-cfd00899.cjs → index-870b6c9d.cjs} +1 -1
- package/es/{index-a83ec4b7.js → index-8c2d7e05.js} +1 -1
- package/es/{index-8901a38c.cjs → index-94131fd7.cjs} +30 -30
- package/es/{index-db846633.cjs → index-9d16cea8.cjs} +1 -1
- package/es/{index-f3f6ee27.js → index-a33b2fb8.js} +178 -178
- package/es/{index-2d7ac156.cjs → index-a9246d17.cjs} +17 -17
- package/es/{index-60c69dd1.cjs → index-ac8dc53d.cjs} +1 -1
- package/es/{index-102edf6c.js → index-c5f2d372.js} +2 -2
- package/es/{index-6290ae0f.js → index-c6584658.js} +2 -2
- package/es/{index-5c44d71a.js → index-eb96e074.js} +149 -119
- package/es/{index-5ed42e9c.js → index-f034b910.js} +2 -2
- package/es/{index-c58e90e9.cjs → index-f58b2920.cjs} +1 -1
- package/es/{python-6cc6ec1b.js → python-8a1664e6.js} +18 -18
- package/es/{python-71f59893.cjs → python-a3db9620.cjs} +1 -1
- package/es/style.css +1 -1
- package/es/{use-form-common-props-02be4928.cjs → use-form-common-props-ac666630.cjs} +1 -1
- package/es/{use-form-common-props-76a09d89.js → use-form-common-props-ed72e914.js} +11 -11
- package/es/{use-global-config-31b3ec57.cjs → use-global-config-23472471.cjs} +1 -1
- package/es/{use-global-config-0f43458b.js → use-global-config-ee406d58.js} +2 -2
- package/es/{validator-ea292506.cjs → validator-366dbf39.cjs} +1 -1
- package/es/{validator-0e037618.js → validator-c60a8956.js} +1 -1
- package/es/{zh-cn-1227eb8a.js → zh-cn-b59a0910.js} +1 -1
- package/es/{zh-cn-0edc7234.cjs → zh-cn-c21d12d8.cjs} +1 -1
- package/lib/aiTools.js +179 -176
- package/lib/bundle.js +1 -1
- package/lib/bundle.umd.cjs +230 -230
- package/lib/{index-2a269748.js → index-62fa175a.js} +30149 -29800
- package/lib/{python-41da18e5.js → python-4a48fa39.js} +1 -1
- package/lib/style.css +1 -1
- package/package.json +53 -44
- package/auto-imports.d.ts +0 -13
- package/components.d.ts +0 -59
- package/es/aiTools-a3b095f6.js +0 -113
- package/es/aiTools-f36136a4.cjs +0 -2
- package/es/index-476c4459.cjs +0 -1
- package/index.html +0 -13
- package/packages/ChartLayout/index.ts +0 -8
- package/packages/ChartLayout/index.vue +0 -63
- package/packages/ConfigProvider/index.ts +0 -8
- package/packages/ConfigProvider/index.vue +0 -66
- package/packages/Contextmenu/index.ts +0 -8
- package/packages/Contextmenu/index.vue +0 -134
- package/packages/CustomFunction/components/ManageDialog.vue +0 -706
- package/packages/CustomFunction/index.ts +0 -8
- package/packages/CustomFunction/index.vue +0 -200
- package/packages/FactorWarning/index.ts +0 -8
- package/packages/FactorWarning/index.vue +0 -754
- package/packages/FactorWarning/tools.js +0 -10
- package/packages/HeatMap/index.ts +0 -8
- package/packages/HeatMap/index.vue +0 -141
- package/packages/Kline/components/Contextmenu/index.vue +0 -110
- package/packages/Kline/components/Tips/index.vue +0 -40
- package/packages/Kline/componentsNew/KlineSlide/index.vue +0 -155
- package/packages/Kline/componentsNew/KlineSub/index.vue +0 -297
- package/packages/Kline/componentsNew/KlineTips/index.vue +0 -66
- package/packages/Kline/componentsNew/KlineUtils/index.vue +0 -84
- package/packages/Kline/componentsNew/Tips/index.vue +0 -33
- package/packages/Kline/formatKlineData.ts +0 -109
- package/packages/Kline/images/buy.svg +0 -1
- package/packages/Kline/images/pen.png +0 -0
- package/packages/Kline/images/sell.svg +0 -1
- package/packages/Kline/images/t.svg +0 -1
- package/packages/Kline/index.ts +0 -16
- package/packages/Kline/index.vue +0 -891
- package/packages/Kline/option.ts +0 -539
- package/packages/Kline/type.d.ts +0 -219
- package/packages/Kline/utils.ts +0 -682
- package/packages/KlineBasic/api.js +0 -58
- package/packages/KlineBasic/components/AverageTips/index.vue +0 -33
- package/packages/KlineBasic/components/Contextmenu/index.vue +0 -105
- package/packages/KlineBasic/components/KlineSub/index.vue +0 -332
- package/packages/KlineBasic/components/KlineTips/index.vue +0 -99
- package/packages/KlineBasic/components/Tips/index.vue +0 -56
- package/packages/KlineBasic/index.ts +0 -8
- package/packages/KlineBasic/index.vue +0 -839
- package/packages/KlineBasic/utils.js +0 -258
- package/packages/KlineConfig/config.js +0 -46
- package/packages/KlineConfig/index.ts +0 -8
- package/packages/KlineConfig/index.vue +0 -356
- package/packages/KlineNew/components/KlineSlide/index.vue +0 -156
- package/packages/KlineNew/components/KlineSub/index.vue +0 -335
- package/packages/KlineNew/components/KlineTips/index.vue +0 -96
- package/packages/KlineNew/components/KlineUtils/index.vue +0 -341
- package/packages/KlineNew/components/Tips/index.vue +0 -33
- package/packages/KlineNew/index.ts +0 -14
- package/packages/KlinePlus/components/SliderChart.vue +0 -208
- package/packages/KlinePlus/components/Tips.vue +0 -36
- package/packages/KlinePlus/images/buy.svg +0 -1
- package/packages/KlinePlus/images/sell.svg +0 -1
- package/packages/KlinePlus/images/t.svg +0 -1
- package/packages/KlinePlus/index.ts +0 -8
- package/packages/KlinePlus/index.vue +0 -1067
- package/packages/KlinePlus/utils.js +0 -771
- package/packages/LinearLegend/index.ts +0 -8
- package/packages/LinearLegend/index.vue +0 -112
- package/packages/Map/China.json +0 -1
- package/packages/Map/index.ts +0 -8
- package/packages/Map/index.vue +0 -147
- package/packages/MonacoEditor/index.ts +0 -8
- package/packages/MonacoEditor/index.vue +0 -1141
- package/packages/MonacoEditor/tools.js +0 -18
- package/packages/Pagination/index.ts +0 -8
- package/packages/Pagination/index.vue +0 -87
- package/packages/PasswordPrompt/index.ts +0 -8
- package/packages/PasswordPrompt/index.vue +0 -267
- package/packages/Pie/index.ts +0 -8
- package/packages/Pie/index.vue +0 -148
- package/packages/Table/components/Button/index.vue +0 -61
- package/packages/Table/components/Formatter/index.vue +0 -26
- package/packages/Table/index.d.ts +0 -0
- package/packages/Table/index.ts +0 -8
- package/packages/Table/index.vue +0 -133
- package/packages/TreeMap/index.ts +0 -8
- package/packages/TreeMap/index.vue +0 -186
- package/packages/User/components/EditInfoDialog/Mobile.vue +0 -214
- package/packages/User/components/EditInfoDialog/index.vue +0 -161
- package/packages/User/components/EditPasswordDialog.vue +0 -168
- package/packages/User/components/SetPasswordDialog.vue +0 -160
- package/packages/User/index.ts +0 -8
- package/packages/User/index.vue +0 -117
- package/packages/VarSelectDialog/Mock.js +0 -495
- package/packages/VarSelectDialog/VarietySelect.vue +0 -78
- package/packages/VarSelectDialog/index.ts +0 -8
- package/packages/VarSelectDialog/index.vue +0 -323
- package/packages/VarietyAiHelper/images/like.png +0 -0
- package/packages/VarietyAiHelper/images/like_no.png +0 -0
- package/packages/VarietyAiHelper/index.ts +0 -8
- package/packages/VarietyAiHelper/index.vue +0 -910
- package/packages/VarietyAutoComplete/index.ts +0 -8
- package/packages/VarietyAutoComplete/index.vue +0 -89
- package/packages/VarietySearch/components/AddTag/index.vue +0 -268
- package/packages/VarietySearch/components/CommonIndicator/IndicatorTags.vue +0 -52
- package/packages/VarietySearch/components/CommonIndicator/index.vue +0 -697
- package/packages/VarietySearch/components/CommonIndicator/tools.js +0 -260
- package/packages/VarietySearch/components/CompositeOrder/index.vue +0 -260
- package/packages/VarietySearch/components/FactorScreen/FactorDescription.vue +0 -70
- package/packages/VarietySearch/components/FactorScreen/index.vue +0 -1158
- package/packages/VarietySearch/components/FactorScreen/tools.js +0 -34
- package/packages/VarietySearch/config.js +0 -539
- package/packages/VarietySearch/index.ts +0 -8
- package/packages/VarietySearch/index.vue +0 -688
- package/packages/VarietyTextCopy/index.ts +0 -8
- package/packages/VarietyTextCopy/index.vue +0 -136
- package/packages/VirtualTable/index.ts +0 -8
- package/packages/VirtualTable/index.vue +0 -241
- package/packages/index.ts +0 -59
- package/public/aiTools.js +0 -176
- package/public/talib.wasm +0 -0
- package/public/vite.svg +0 -1
- package/src/App.vue +0 -140
- package/src/assets/vue.svg +0 -1
- package/src/components/Dialog/index.vue +0 -16
- package/src/components/Kline/index.vue +0 -21
- package/src/components/Table/index.vue +0 -27
- package/src/main.ts +0 -17
- package/src/pages/ChartLayout/index.vue +0 -22
- package/src/pages/ConfigProvider/index.vue +0 -9
- package/src/pages/Contextmenu/index.vue +0 -46
- package/src/pages/CustomFunction/index.vue +0 -13
- package/src/pages/FactorWarning/index.vue +0 -203
- package/src/pages/HeatMap/index.vue +0 -128
- package/src/pages/Kline/index.vue +0 -12
- package/src/pages/KlineBasic/api.js +0 -48
- package/src/pages/KlineBasic/index.vue +0 -366
- package/src/pages/KlineBasic/indicator.js +0 -114
- package/src/pages/KlineConfig/index.vue +0 -20
- package/src/pages/KlineNew/components/KlineAction/components/ContextMenu/index.vue +0 -91
- package/src/pages/KlineNew/components/KlineAction/components/YearChart/index.vue +0 -532
- package/src/pages/KlineNew/components/KlineAction/images/pen.png +0 -0
- package/src/pages/KlineNew/components/KlineAction/index.vue +0 -716
- package/src/pages/KlineNew/components/KlineAction/mockApi/index.js +0 -13
- package/src/pages/KlineNew/components/KlineAction/utils.js +0 -571
- package/src/pages/KlineNew/components/KlineBasic/index.vue +0 -336
- package/src/pages/KlineNew/components/KlineBasic/utils.js +0 -46
- package/src/pages/KlineNew/components/KlineNew/index.vue +0 -316
- package/src/pages/KlineNew/components/KlineNew/utils.js +0 -31
- package/src/pages/KlineNew/components/KlineSlide/index.vue +0 -448
- package/src/pages/KlineNew/components/KlineSlide/utils.js +0 -78
- package/src/pages/KlineNew/components/KlineSlideNew/index.vue +0 -430
- package/src/pages/KlineNew/components/KlineSlideNew/utils.js +0 -78
- package/src/pages/KlineNew/index.vue +0 -92
- package/src/pages/KlinePlus/KlineDialog/MultiCycle.vue +0 -312
- package/src/pages/KlinePlus/KlineDialog/api.js +0 -108
- package/src/pages/KlinePlus/KlineDialog/index.vue +0 -582
- package/src/pages/KlinePlus/KlineDialog/indicator.js +0 -109
- package/src/pages/KlinePlus/KlineDialog/tools.js +0 -86
- package/src/pages/KlinePlus/index.vue +0 -30
- package/src/pages/KlinePlus/tradeLogMock.js +0 -1927
- package/src/pages/LinearLegend/index.vue +0 -92
- package/src/pages/Map/index.vue +0 -62
- package/src/pages/MonacoEditor/index.vue +0 -63
- package/src/pages/Pagination/index.vue +0 -24
- package/src/pages/PasswordPrompt/index.vue +0 -12
- package/src/pages/Pie/index.vue +0 -36
- package/src/pages/Table/index.vue +0 -117
- package/src/pages/TreeMap/index.vue +0 -542
- package/src/pages/User/index.vue +0 -24
- package/src/pages/VarSelectDialog/index.vue +0 -16
- package/src/pages/VarietyAiHelper/index.vue +0 -20
- package/src/pages/VarietyAutoComplete/index.vue +0 -19
- package/src/pages/VarietySearch/api.js +0 -70
- package/src/pages/VarietySearch/index.vue +0 -467
- package/src/pages/VarietyTextCopy/index.vue +0 -24
- package/src/pages/VirtualTable/demo.json +0 -6377
- package/src/pages/VirtualTable/index.vue +0 -79
- package/src/router/index.ts +0 -9
- package/src/router/routes.ts +0 -132
- package/src/style.css +0 -79
- package/src/vite-env.d.ts +0 -9
- package/tsconfig.json +0 -30
- package/tsconfig.node.json +0 -10
package/packages/Kline/utils.ts
DELETED
|
@@ -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
|
-
};
|