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/index.vue
DELETED
|
@@ -1,891 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import * as echarts from "echarts";
|
|
3
|
-
import { ref, computed, watch, onMounted, onUnmounted } from "vue";
|
|
4
|
-
import Tips from "./components/Tips/index.vue";
|
|
5
|
-
import Contextmenu from "./components/Contextmenu/index.vue";
|
|
6
|
-
import { getOption, getLineOption } from "./option";
|
|
7
|
-
import { printConsole, formatValue, formatPrice } from "./utils";
|
|
8
|
-
import type { EChartsType, EChartsOption, ECElementEvent, DataZoomComponentOption } from "echarts";
|
|
9
|
-
import type { KlineDataType, LineDataType, InConfig, MenuDataType } from "./type.d.ts";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* 组件接收参数
|
|
13
|
-
* @param {Object} indicator 指标线
|
|
14
|
-
* @param {KlineDataType} klineData K线数据
|
|
15
|
-
* @param {Array} markData 标注点位数据 [开平点, 买卖点, 信号点,...]
|
|
16
|
-
* @param {Array} lineData K线额外画线数据 [预警线, 持仓线, 条件单, ...]
|
|
17
|
-
* @param {Array} brushRange 区域刷选范围数据
|
|
18
|
-
* @param {Array} defaultMenuData 菜单项数据
|
|
19
|
-
* @param {Boolean} isSelect 组件是否被选中
|
|
20
|
-
*
|
|
21
|
-
* @param {InConfig} config 其他配置项数据
|
|
22
|
-
*/
|
|
23
|
-
const props = defineProps({
|
|
24
|
-
indicator: {
|
|
25
|
-
type: Object,
|
|
26
|
-
default: () => ({}),
|
|
27
|
-
},
|
|
28
|
-
klineData: {
|
|
29
|
-
type: Array,
|
|
30
|
-
default: () => [],
|
|
31
|
-
},
|
|
32
|
-
markData: {
|
|
33
|
-
type: Array,
|
|
34
|
-
default: () => [],
|
|
35
|
-
},
|
|
36
|
-
lineData: {
|
|
37
|
-
type: Array,
|
|
38
|
-
default: () => [],
|
|
39
|
-
},
|
|
40
|
-
netPositionData: {
|
|
41
|
-
type: Array,
|
|
42
|
-
default: () => [],
|
|
43
|
-
},
|
|
44
|
-
relevanceData: {
|
|
45
|
-
type: Array,
|
|
46
|
-
default: () => [],
|
|
47
|
-
},
|
|
48
|
-
priceTrendData: {
|
|
49
|
-
type: Array,
|
|
50
|
-
default: () => [],
|
|
51
|
-
},
|
|
52
|
-
priceTrendPercentData: {
|
|
53
|
-
type: Array,
|
|
54
|
-
default: () => [],
|
|
55
|
-
},
|
|
56
|
-
brushRange: {
|
|
57
|
-
type: Array,
|
|
58
|
-
default: () => [],
|
|
59
|
-
},
|
|
60
|
-
defaultMenuData: {
|
|
61
|
-
type: Array,
|
|
62
|
-
default: () => [],
|
|
63
|
-
},
|
|
64
|
-
isSelect: {
|
|
65
|
-
type: Boolean,
|
|
66
|
-
default: () => false,
|
|
67
|
-
},
|
|
68
|
-
config: {
|
|
69
|
-
type: Object,
|
|
70
|
-
default: () => ({}),
|
|
71
|
-
},
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* K线功能默认配置
|
|
76
|
-
* @param {Number} totalBarCount k线总条数
|
|
77
|
-
* @param {Number} defaultShowBarCount k线默认展示条数
|
|
78
|
-
* @param {Number} preBarCount k线预加载条数,用于计算指标线
|
|
79
|
-
* ---------------------------------------------------------
|
|
80
|
-
* @param {Number} gridLeft k线组件grid: left
|
|
81
|
-
* @param {Number} gridTop k线组件grid: top
|
|
82
|
-
* @param {Number} gridRight k线组件grid: right
|
|
83
|
-
* @param {Number} gridBottom k线组件grid: bottom
|
|
84
|
-
* ---------------------------------------------------------
|
|
85
|
-
* @param {Object} warningConfig 预警线配置
|
|
86
|
-
* @param {Object} positionConfig 持仓线配置
|
|
87
|
-
* @param {Object} conditionConfig 条件单配置
|
|
88
|
-
*/
|
|
89
|
-
const defaultConfig: InConfig = {
|
|
90
|
-
totalBarCount: 2000,
|
|
91
|
-
defaultShowBarCount: 200,
|
|
92
|
-
preBarCount: 800,
|
|
93
|
-
maxValueSpan: 10000,
|
|
94
|
-
gridLeft: 60,
|
|
95
|
-
gridTop: 0,
|
|
96
|
-
gridRight: 60,
|
|
97
|
-
gridBottom: 30,
|
|
98
|
-
// 预警线配置
|
|
99
|
-
warningConfig: {
|
|
100
|
-
draggable: false,
|
|
101
|
-
lineColor: "#fff",
|
|
102
|
-
textColor: "#fff",
|
|
103
|
-
},
|
|
104
|
-
// 持仓线配置
|
|
105
|
-
positionConfig: {
|
|
106
|
-
draggable: false,
|
|
107
|
-
lineColor: "#e45d07",
|
|
108
|
-
textColor: "#fff",
|
|
109
|
-
},
|
|
110
|
-
// 条件单配置
|
|
111
|
-
conditionConfig: {
|
|
112
|
-
draggable: false,
|
|
113
|
-
lineColor: "#fff",
|
|
114
|
-
textColor: "#fff",
|
|
115
|
-
profitLineColor: "#b71e44",
|
|
116
|
-
profitTextColor: "#fff",
|
|
117
|
-
lossLineColor: "#749b66",
|
|
118
|
-
lossTextColor: "#fff",
|
|
119
|
-
},
|
|
120
|
-
// Tips配置
|
|
121
|
-
tipsConfig: {
|
|
122
|
-
open: true,
|
|
123
|
-
heigh: true,
|
|
124
|
-
low: true,
|
|
125
|
-
close: true,
|
|
126
|
-
business: true,
|
|
127
|
-
riseAndFall: true,
|
|
128
|
-
},
|
|
129
|
-
// 动态加载配置
|
|
130
|
-
dynamicLoadConfig: {
|
|
131
|
-
historyVisible: false,
|
|
132
|
-
historyLoadCallBack: () => {},
|
|
133
|
-
futureVisible: false,
|
|
134
|
-
futureLoadCallBack: () => {},
|
|
135
|
-
},
|
|
136
|
-
// 是否禁用鼠标滚轮缩放K线,在开启动态后续数据加载时,建议开启,否则会引起datazoom内部缩放拖拽触发后续加载冲突
|
|
137
|
-
zoomLock: false,
|
|
138
|
-
// 是否启用计算收盘价分布统计功能
|
|
139
|
-
isOpenDS: false,
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* @description: 合并后的功能配置项
|
|
144
|
-
*/
|
|
145
|
-
const config: { value: InConfig } = computed(() => {
|
|
146
|
-
return { ...defaultConfig, ...props.config };
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
const option = ref<any>(null); // 处理后的echarts配置
|
|
150
|
-
const activeIndex = ref(-1); // 当前鼠标激活的数据索引
|
|
151
|
-
|
|
152
|
-
// Tips: [开, 收, 低, 高, 成交额, 昨收]
|
|
153
|
-
const kLineTips = computed(() => {
|
|
154
|
-
if (option.value && option.value.dataset[0]?.source?.klineData[activeIndex.value]) {
|
|
155
|
-
const klineItem = option.value.dataset[0].source.klineData[activeIndex.value];
|
|
156
|
-
// 处理结果
|
|
157
|
-
const result = [];
|
|
158
|
-
const { open, heigh, low, close, business, riseAndFall } = config.value.tipsConfig;
|
|
159
|
-
open && result.push({ label: "开", value: klineItem[0], color: "rgb(153, 153, 153)" });
|
|
160
|
-
heigh && result.push({ label: "高", value: klineItem[3], color: "rgb(153, 153, 153)" });
|
|
161
|
-
low && result.push({ label: "低", value: klineItem[2], color: "rgb(153, 153, 153)" });
|
|
162
|
-
close && result.push({ label: "收", value: klineItem[1], color: "rgb(153, 153, 153)" });
|
|
163
|
-
business && result.push({ label: "额", value: formatPrice(klineItem[4]), color: "rgb(153, 153, 153)" });
|
|
164
|
-
if (riseAndFall) {
|
|
165
|
-
let ratio = (((klineItem[1] - klineItem[5]) / klineItem[1]) * 100).toFixed(2);
|
|
166
|
-
let ratioColor = +ratio === 0.0 ? "white" : +ratio > 0 ? "red" : "#00ff00";
|
|
167
|
-
result.push({ label: "涨跌", value: `${ratio}%`, color: ratioColor });
|
|
168
|
-
}
|
|
169
|
-
return result;
|
|
170
|
-
}
|
|
171
|
-
return [];
|
|
172
|
-
});
|
|
173
|
-
// Tips: 指标
|
|
174
|
-
const indicatorTips = computed(() => {
|
|
175
|
-
if (option.value && option.value.dataset[0]?.source?.indicatorData) {
|
|
176
|
-
return option.value.dataset[0].source.indicatorData.reduce((result: any, next: any) => {
|
|
177
|
-
next.data[activeIndex.value] &&
|
|
178
|
-
result.push({
|
|
179
|
-
label: next.key,
|
|
180
|
-
value: formatValue(next.data[activeIndex.value]),
|
|
181
|
-
color: next.color,
|
|
182
|
-
});
|
|
183
|
-
return result;
|
|
184
|
-
}, []);
|
|
185
|
-
}
|
|
186
|
-
return [];
|
|
187
|
-
});
|
|
188
|
-
// Tips: 价格趋势[价差定制]
|
|
189
|
-
const priceTrendTips = computed(() => {
|
|
190
|
-
// 颜色配置
|
|
191
|
-
const colorList = [
|
|
192
|
-
"#FFFFFF",
|
|
193
|
-
"#FFDD00",
|
|
194
|
-
"#FF00FF",
|
|
195
|
-
"#00FF00",
|
|
196
|
-
"#FF6000",
|
|
197
|
-
"#1677FF",
|
|
198
|
-
"#7C3CC9",
|
|
199
|
-
"#FF0000",
|
|
200
|
-
"#FB9A0E",
|
|
201
|
-
"#00B7FF",
|
|
202
|
-
];
|
|
203
|
-
// 价格趋势
|
|
204
|
-
if (props.priceTrendData.length > 0) {
|
|
205
|
-
const result = [];
|
|
206
|
-
props.priceTrendData.forEach((item: any, index: number) => {
|
|
207
|
-
const value = item.data[activeIndex.value] ? formatValue(item.data[activeIndex.value][1]) : null;
|
|
208
|
-
if (value !== null) {
|
|
209
|
-
result.push({
|
|
210
|
-
label: item.name,
|
|
211
|
-
value: formatValue(item.data[activeIndex.value]?.[1]),
|
|
212
|
-
color: colorList[index],
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
return result;
|
|
217
|
-
}
|
|
218
|
-
// 价格趋势百分比
|
|
219
|
-
if (props.priceTrendPercentData.length > 0) {
|
|
220
|
-
const result = [];
|
|
221
|
-
const chartOption = echartsInstance.getOption()
|
|
222
|
-
chartOption.series.filter(line => line.name.includes('二腿价格走势百分比图')).forEach((item: any, index: number) => {
|
|
223
|
-
const value = item.data[activeIndex.value] ? formatValue(item.data[activeIndex.value][1]) : null;
|
|
224
|
-
if (value !== null) {
|
|
225
|
-
result.push({
|
|
226
|
-
label: item.name.split('-')[1],
|
|
227
|
-
value: `${formatValue(item.data[activeIndex.value]?.[1])}%`,
|
|
228
|
-
color: colorList[index],
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
return result;
|
|
233
|
-
}
|
|
234
|
-
return [];
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
// 监视: props[klineData, indicator, markData, netPositionData, relevanceData] -> 重绘全部
|
|
238
|
-
watch(
|
|
239
|
-
() => [props.klineData, props.indicator, props.markData, props.netPositionData, props.relevanceData],
|
|
240
|
-
() => {
|
|
241
|
-
draw();
|
|
242
|
-
},
|
|
243
|
-
{
|
|
244
|
-
deep: true,
|
|
245
|
-
}
|
|
246
|
-
);
|
|
247
|
-
// 监视: props.lineData - 额外画线数据 -> 重新绘制额外线
|
|
248
|
-
watch(
|
|
249
|
-
() => props.lineData,
|
|
250
|
-
async () => {
|
|
251
|
-
printConsole("st-kline组件消息:props.lineData监控,额外画线数据发生改变,重绘->line", {
|
|
252
|
-
color: "red",
|
|
253
|
-
});
|
|
254
|
-
draw("line");
|
|
255
|
-
},
|
|
256
|
-
{
|
|
257
|
-
deep: true,
|
|
258
|
-
}
|
|
259
|
-
);
|
|
260
|
-
// 监视: props.brushRange - 区域刷选数据 -> 重新刷选
|
|
261
|
-
watch(
|
|
262
|
-
() => props.brushRange,
|
|
263
|
-
async () => {
|
|
264
|
-
printConsole("st-kline组件消息:props.brushRange监控,区域刷选数据发生改变,重绘->brush", {
|
|
265
|
-
color: "red",
|
|
266
|
-
});
|
|
267
|
-
draw("brush");
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
deep: true,
|
|
271
|
-
}
|
|
272
|
-
);
|
|
273
|
-
// 监视: props.priceTrendData - 二腿价格趋势数据 -> 重绘趋势
|
|
274
|
-
watch(
|
|
275
|
-
() => props.priceTrendData,
|
|
276
|
-
async () => {
|
|
277
|
-
draw("priceTrend");
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
deep: true,
|
|
281
|
-
}
|
|
282
|
-
);
|
|
283
|
-
// 监视: props.priceTrendPercentData - 二腿价格趋势百分比数据 -> 重绘趋势百分比
|
|
284
|
-
watch(
|
|
285
|
-
() => props.priceTrendPercentData,
|
|
286
|
-
async () => {
|
|
287
|
-
draw("priceTrendPercent");
|
|
288
|
-
},
|
|
289
|
-
{
|
|
290
|
-
deep: true,
|
|
291
|
-
}
|
|
292
|
-
);
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* @description: 图表绘制函数
|
|
296
|
-
* @param {?String} type 绘制类型[Kline-K线,line-额外线条,brush-区域刷选,不传-全部]
|
|
297
|
-
*/
|
|
298
|
-
const draw = async (type?: string) => {
|
|
299
|
-
const callBackMap = new Map([
|
|
300
|
-
// kline-K线绘制
|
|
301
|
-
[
|
|
302
|
-
"kline",
|
|
303
|
-
async () => {
|
|
304
|
-
const newOption = await getOption(
|
|
305
|
-
props.klineData as KlineDataType,
|
|
306
|
-
props.markData,
|
|
307
|
-
props.indicator,
|
|
308
|
-
config.value,
|
|
309
|
-
props.netPositionData,
|
|
310
|
-
props.relevanceData
|
|
311
|
-
);
|
|
312
|
-
const { graphic } = echartsInstance.getOption() ?? { graphic: [] };
|
|
313
|
-
option.value = { ...newOption, graphic };
|
|
314
|
-
echartsInstance.setOption(option.value, true);
|
|
315
|
-
printConsole("st-kline组件消息:K线绘制完毕-draw", { color: "green" });
|
|
316
|
-
},
|
|
317
|
-
],
|
|
318
|
-
// line-额外线条绘制
|
|
319
|
-
[
|
|
320
|
-
"line",
|
|
321
|
-
() => {
|
|
322
|
-
const echartsOptions = echartsInstance.getOption();
|
|
323
|
-
const graphic = getLineOption(props.lineData as LineDataType, config.value, echartsInstance);
|
|
324
|
-
option.value = { ...echartsOptions, graphic };
|
|
325
|
-
echartsInstance.setOption(option.value, {
|
|
326
|
-
replaceMerge: ["graphic"],
|
|
327
|
-
});
|
|
328
|
-
printConsole("st-kline组件消息:额外画线绘制完毕-draw", { color: "green" });
|
|
329
|
-
},
|
|
330
|
-
],
|
|
331
|
-
// brush-区域刷选
|
|
332
|
-
[
|
|
333
|
-
"brush",
|
|
334
|
-
() => {
|
|
335
|
-
const { brushRange } = props;
|
|
336
|
-
if (brushRange instanceof Array && brushRange.length > 0) {
|
|
337
|
-
echartsInstance.dispatchAction({
|
|
338
|
-
type: "brush",
|
|
339
|
-
areas: [
|
|
340
|
-
{
|
|
341
|
-
brushType: "lineX",
|
|
342
|
-
coordRange: [brushRange[0] + "", brushRange[1] + ""],
|
|
343
|
-
xAxisIndex: 0,
|
|
344
|
-
},
|
|
345
|
-
],
|
|
346
|
-
});
|
|
347
|
-
printConsole("st-kline组件消息:区域刷选绘制完毕-draw", { color: "green" });
|
|
348
|
-
}
|
|
349
|
-
},
|
|
350
|
-
],
|
|
351
|
-
// 全部绘制
|
|
352
|
-
[
|
|
353
|
-
undefined,
|
|
354
|
-
async () => {
|
|
355
|
-
await draw("kline");
|
|
356
|
-
await draw("line");
|
|
357
|
-
await draw("priceTrend");
|
|
358
|
-
await draw("priceTrendPercent");
|
|
359
|
-
await draw("brush");
|
|
360
|
-
},
|
|
361
|
-
],
|
|
362
|
-
// history-K线历史数据绘制
|
|
363
|
-
[
|
|
364
|
-
"history",
|
|
365
|
-
async () => {
|
|
366
|
-
const chartOption = echartsInstance.getOption();
|
|
367
|
-
const newOption = await getOption(
|
|
368
|
-
props.klineData as KlineDataType,
|
|
369
|
-
props.markData,
|
|
370
|
-
props.indicator,
|
|
371
|
-
config.value,
|
|
372
|
-
props.netPositionData,
|
|
373
|
-
props.relevanceData
|
|
374
|
-
);
|
|
375
|
-
const addDataLength =
|
|
376
|
-
newOption.dataset.source.klineData.length - chartOption.dataset[0].source.klineData.length;
|
|
377
|
-
echartsInstance.setOption(
|
|
378
|
-
{
|
|
379
|
-
...newOption,
|
|
380
|
-
dataZoom: [
|
|
381
|
-
{
|
|
382
|
-
type: "inside",
|
|
383
|
-
xAxisIndex: [0, 0],
|
|
384
|
-
zoomLock: config.value.zoomLock,
|
|
385
|
-
maxValueSpan: config.value.maxValueSpan,
|
|
386
|
-
startValue: chartOption.dataZoom[0].startValue + addDataLength,
|
|
387
|
-
endValue: chartOption.dataZoom[0].endValue + addDataLength,
|
|
388
|
-
},
|
|
389
|
-
],
|
|
390
|
-
},
|
|
391
|
-
true
|
|
392
|
-
);
|
|
393
|
-
await draw("priceTrend");
|
|
394
|
-
},
|
|
395
|
-
],
|
|
396
|
-
// future-K线后续数据绘制
|
|
397
|
-
[
|
|
398
|
-
"future",
|
|
399
|
-
async () => {
|
|
400
|
-
const chartOption = echartsInstance.getOption();
|
|
401
|
-
const newOption = await getOption(
|
|
402
|
-
props.klineData as KlineDataType,
|
|
403
|
-
props.markData,
|
|
404
|
-
props.indicator,
|
|
405
|
-
config.value,
|
|
406
|
-
props.netPositionData,
|
|
407
|
-
props.relevanceData
|
|
408
|
-
);
|
|
409
|
-
newOption.dataZoom[0].start =
|
|
410
|
-
((props.klineData.length - chartOption.dataZoom[0].endValue + chartOption.dataZoom[0].startValue) /
|
|
411
|
-
props.klineData.length) *
|
|
412
|
-
100;
|
|
413
|
-
echartsInstance.setOption(newOption, true);
|
|
414
|
-
await draw("priceTrend");
|
|
415
|
-
},
|
|
416
|
-
],
|
|
417
|
-
// priceTrend-二腿价格趋势绘制
|
|
418
|
-
[
|
|
419
|
-
"priceTrend",
|
|
420
|
-
() => {
|
|
421
|
-
if (props.priceTrendData.length === 0) return;
|
|
422
|
-
const echartsOptions = echartsInstance.getOption();
|
|
423
|
-
// 颜色配置
|
|
424
|
-
const colorList = [
|
|
425
|
-
"#FFFFFF",
|
|
426
|
-
"#FFDD00",
|
|
427
|
-
"#FF00FF",
|
|
428
|
-
"#00FF00",
|
|
429
|
-
"#FF6000",
|
|
430
|
-
"#1677FF",
|
|
431
|
-
"#7C3CC9",
|
|
432
|
-
"#FF0000",
|
|
433
|
-
"#FB9A0E",
|
|
434
|
-
"#00B7FF",
|
|
435
|
-
];
|
|
436
|
-
// 格式化series配置
|
|
437
|
-
const priceTrendLineSeries = props.priceTrendData.reduce((result, next, index) => {
|
|
438
|
-
const { name, data } = next;
|
|
439
|
-
const line = {
|
|
440
|
-
name: `二腿价格走势图-${name}`,
|
|
441
|
-
type: "line",
|
|
442
|
-
data,
|
|
443
|
-
symbol: "none",
|
|
444
|
-
yAxisIndex: 1,
|
|
445
|
-
connectNulls: true,
|
|
446
|
-
itemStyle: {
|
|
447
|
-
color: colorList[index],
|
|
448
|
-
},
|
|
449
|
-
lineStyle: {
|
|
450
|
-
type: "dashed", // 虚线
|
|
451
|
-
width: 1,
|
|
452
|
-
},
|
|
453
|
-
};
|
|
454
|
-
result.push(line);
|
|
455
|
-
return result;
|
|
456
|
-
}, []);
|
|
457
|
-
option.value = { ...echartsOptions, series: [...echartsOptions.series, ...priceTrendLineSeries] };
|
|
458
|
-
echartsInstance.setOption(option.value, {
|
|
459
|
-
replaceMerge: ["series"],
|
|
460
|
-
});
|
|
461
|
-
},
|
|
462
|
-
],
|
|
463
|
-
// priceTrendPercent-二腿价格趋势百分比绘制-初始绘制
|
|
464
|
-
[
|
|
465
|
-
"priceTrendPercent",
|
|
466
|
-
async () => {
|
|
467
|
-
if (props.priceTrendPercentData.length === 0) return;
|
|
468
|
-
const chartOption = echartsInstance.getOption();
|
|
469
|
-
// 颜色配置
|
|
470
|
-
const colorList = [
|
|
471
|
-
"#FFFFFF",
|
|
472
|
-
"#FFDD00",
|
|
473
|
-
"#FF00FF",
|
|
474
|
-
"#00FF00",
|
|
475
|
-
"#FF6000",
|
|
476
|
-
"#1677FF",
|
|
477
|
-
"#7C3CC9",
|
|
478
|
-
"#FF0000",
|
|
479
|
-
"#FB9A0E",
|
|
480
|
-
"#00B7FF",
|
|
481
|
-
];
|
|
482
|
-
// 获取当屏首根K线索引
|
|
483
|
-
const startIndex = chartOption.dataZoom[0].startValue;
|
|
484
|
-
// 处理趋势数据(百分比)
|
|
485
|
-
const handlePriceTrendSeries = props.priceTrendPercentData.reduce((result, next, index) => {
|
|
486
|
-
const { name, data } = next;
|
|
487
|
-
const handleData = data.length > config.value.totalBarCount ? data.slice(data.length - config.value.totalBarCount) : data
|
|
488
|
-
const priceTrendBase = handleData[startIndex][1];
|
|
489
|
-
const lineData = handleData.map((item) => {
|
|
490
|
-
return [item[0], ((item[1] - priceTrendBase) / priceTrendBase) * 100];
|
|
491
|
-
});
|
|
492
|
-
const line = {
|
|
493
|
-
name: `二腿价格走势百分比图-${name}`,
|
|
494
|
-
type: "line",
|
|
495
|
-
data: lineData,
|
|
496
|
-
symbol: "none",
|
|
497
|
-
yAxisIndex: 1,
|
|
498
|
-
connectNulls: true,
|
|
499
|
-
itemStyle: {
|
|
500
|
-
color: colorList[index],
|
|
501
|
-
},
|
|
502
|
-
lineStyle: {
|
|
503
|
-
type: "dashed", // 虚线
|
|
504
|
-
width: 1,
|
|
505
|
-
},
|
|
506
|
-
};
|
|
507
|
-
result.push(line);
|
|
508
|
-
return result;
|
|
509
|
-
}, []);
|
|
510
|
-
// 填充价格趋势线(避免重复)
|
|
511
|
-
chartOption.series = [...chartOption.series.filter(line => {
|
|
512
|
-
return !line.name.includes('二腿价格走势百分比图')
|
|
513
|
-
}), ...handlePriceTrendSeries];
|
|
514
|
-
echartsInstance.setOption(chartOption, true);
|
|
515
|
-
},
|
|
516
|
-
],
|
|
517
|
-
]);
|
|
518
|
-
const callBack = callBackMap.get(type);
|
|
519
|
-
if (callBack instanceof Function) {
|
|
520
|
-
await callBack();
|
|
521
|
-
}
|
|
522
|
-
};
|
|
523
|
-
|
|
524
|
-
//----------------------------右键菜单功能相关----------------------------------
|
|
525
|
-
const cursorPenVisible = ref(false); // 画笔模式开关
|
|
526
|
-
|
|
527
|
-
const menuData = ref<MenuDataType>([]);
|
|
528
|
-
|
|
529
|
-
/**
|
|
530
|
-
* @description: 点击菜单项
|
|
531
|
-
* @param {Object} item 菜单项的数据
|
|
532
|
-
*/
|
|
533
|
-
const menuClick = (item: any) => {
|
|
534
|
-
const { callBack } = item;
|
|
535
|
-
callBack instanceof Function && callBack(echartsInstance, cursorPenVisible);
|
|
536
|
-
};
|
|
537
|
-
|
|
538
|
-
/**
|
|
539
|
-
* @description: 菜单关闭的回调
|
|
540
|
-
* @todo: 进行菜单内容的初始化
|
|
541
|
-
*/
|
|
542
|
-
const closeContextMenuCallBack = () => {
|
|
543
|
-
menuData.value = props.defaultMenuData as MenuDataType;
|
|
544
|
-
};
|
|
545
|
-
|
|
546
|
-
//----------------------------Echarts基座-------------------------------
|
|
547
|
-
const echartsRef = ref<HTMLElement>();
|
|
548
|
-
let echartsInstance: EChartsType; // echarts实例
|
|
549
|
-
let chartDomObserver: any; // 监视图表DOM变化
|
|
550
|
-
|
|
551
|
-
/**
|
|
552
|
-
* @description: echarts数据高亮回调
|
|
553
|
-
* @param {any} data echarts数据
|
|
554
|
-
* @param {EChartsType} chart echarts实例
|
|
555
|
-
*/
|
|
556
|
-
const highlight = (data: any, chart: EChartsType) => {
|
|
557
|
-
if (data) {
|
|
558
|
-
// 图表内部移动
|
|
559
|
-
activeIndex.value = typeof data?.batch[0]?.dataIndex === "number" ? data?.batch[0]?.dataIndex : -1;
|
|
560
|
-
} else {
|
|
561
|
-
// 移出图表
|
|
562
|
-
const chartOptions: EChartsOption = chart.getOption() as EChartsOption;
|
|
563
|
-
if (chartOptions.dataZoom instanceof Array) {
|
|
564
|
-
activeIndex.value = chartOptions.dataZoom[0].endValue as number;
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
};
|
|
568
|
-
|
|
569
|
-
/**
|
|
570
|
-
* @description: echarts数据缩放的相关参数
|
|
571
|
-
* @param {any} datazoomTimer 缩放回调函数的延时器
|
|
572
|
-
* @param {Number} datazoomTime 缩放回调函数的延时器的时间
|
|
573
|
-
* @param {Function} datazoom 数据缩放的回调函数
|
|
574
|
-
*
|
|
575
|
-
* 判断具体是拖拽,还是缩放的逻辑
|
|
576
|
-
* 根据start~end的差值前后是否变动
|
|
577
|
-
* 因为拖拽时,他们的差值是恒定的,缩放时是会变动
|
|
578
|
-
*/
|
|
579
|
-
let datazoomTimer: any = null;
|
|
580
|
-
const datazoomTime: number = 300;
|
|
581
|
-
let historyIsLoading = false;
|
|
582
|
-
let historyIsAllLoad = ref(false);
|
|
583
|
-
let futureIsLoading = false;
|
|
584
|
-
let futureIsAllLoad = ref(false);
|
|
585
|
-
const datazoom = async (params: any) => {
|
|
586
|
-
// 执行[方向键]时,返回的是startValue和endValue
|
|
587
|
-
// 执行[鼠标]时,返回的是batch
|
|
588
|
-
/**
|
|
589
|
-
* @description: 历史数据动态加载渲染逻辑
|
|
590
|
-
* 前置条件:
|
|
591
|
-
* 1.允许开启历史动态加载
|
|
592
|
-
* 2.如果剩余K线根数不足100根
|
|
593
|
-
* 3.没有正在加载历史数据
|
|
594
|
-
* 4.历史数据并未已全部获取
|
|
595
|
-
*/
|
|
596
|
-
// 获取左侧剩余K线根数
|
|
597
|
-
const historyLength = params.batch ? params.batch[0].start * config.value.totalBarCount : params.startValue;
|
|
598
|
-
if (
|
|
599
|
-
config.value.dynamicLoadConfig.historyVisible &&
|
|
600
|
-
historyLength <= 100 &&
|
|
601
|
-
!historyIsLoading &&
|
|
602
|
-
!historyIsAllLoad.value
|
|
603
|
-
) {
|
|
604
|
-
historyIsLoading = true;
|
|
605
|
-
await config.value.dynamicLoadConfig.historyLoadCallBack(historyIsAllLoad);
|
|
606
|
-
await draw("history");
|
|
607
|
-
historyIsLoading = false;
|
|
608
|
-
}
|
|
609
|
-
/**
|
|
610
|
-
* @description: 后续数据动态加载渲染逻辑
|
|
611
|
-
* 前置条件:
|
|
612
|
-
* 1.允许开启后续动态加载
|
|
613
|
-
* 2.右侧已为图表尽头
|
|
614
|
-
* 3.没有正在加载后续数据
|
|
615
|
-
* 4.后续数据并未已全部获取
|
|
616
|
-
* 5.仅仅在[鼠标拖拽,方向键左右]时
|
|
617
|
-
*/
|
|
618
|
-
// 获取右侧K线是否最后一根
|
|
619
|
-
const nowIsEnd = params.batch
|
|
620
|
-
? params.batch[0].end === 100
|
|
621
|
-
: params.endValue >= props.klineData.length - config.value.preBarCount - 1;
|
|
622
|
-
const actionIsWheel = params.actionIsWheel;
|
|
623
|
-
if (
|
|
624
|
-
config.value.dynamicLoadConfig.futureVisible &&
|
|
625
|
-
nowIsEnd &&
|
|
626
|
-
!futureIsLoading &&
|
|
627
|
-
!futureIsAllLoad.value &&
|
|
628
|
-
!actionIsWheel
|
|
629
|
-
) {
|
|
630
|
-
futureIsLoading = true;
|
|
631
|
-
await config.value.dynamicLoadConfig.futureLoadCallBack(futureIsAllLoad);
|
|
632
|
-
await draw("future");
|
|
633
|
-
futureIsLoading = false;
|
|
634
|
-
}
|
|
635
|
-
clearTimeout(datazoomTimer);
|
|
636
|
-
datazoomTimer = setTimeout(() => {
|
|
637
|
-
draw("line");
|
|
638
|
-
draw("priceTrendPercent");
|
|
639
|
-
clearTimeout(datazoomTimer);
|
|
640
|
-
datazoomTimer = null;
|
|
641
|
-
}, datazoomTime);
|
|
642
|
-
};
|
|
643
|
-
/**
|
|
644
|
-
* @description: echarts鼠标右击事件回调
|
|
645
|
-
*/
|
|
646
|
-
let echartsContextMenuTimer: any = null;
|
|
647
|
-
const echartsContextMenu = (params: ECElementEvent) => {
|
|
648
|
-
echartsContextMenuTimer = setTimeout(() => {
|
|
649
|
-
// 判定是否点击到的元素为额外画线
|
|
650
|
-
if (params.componentType === "graphic") {
|
|
651
|
-
const { oncontextmenu } = params.info?.event ?? {};
|
|
652
|
-
oncontextmenu instanceof Function && oncontextmenu(params, params.info, menuData);
|
|
653
|
-
}
|
|
654
|
-
clearTimeout(echartsContextMenuTimer);
|
|
655
|
-
echartsContextMenuTimer = null;
|
|
656
|
-
});
|
|
657
|
-
};
|
|
658
|
-
|
|
659
|
-
// 绑定事件
|
|
660
|
-
const addEventListener = () => {
|
|
661
|
-
echartsInstance.on("highlight", (data: any) => {
|
|
662
|
-
highlight(data, echartsInstance);
|
|
663
|
-
});
|
|
664
|
-
echartsInstance.on("globalout", () => {
|
|
665
|
-
highlight(null, echartsInstance);
|
|
666
|
-
});
|
|
667
|
-
echartsInstance.on("contextmenu", (params: ECElementEvent) => {
|
|
668
|
-
echartsContextMenu(params);
|
|
669
|
-
});
|
|
670
|
-
echartsInstance.on("datazoom", (params: any) => {
|
|
671
|
-
datazoom(params);
|
|
672
|
-
});
|
|
673
|
-
};
|
|
674
|
-
|
|
675
|
-
// 解绑事件
|
|
676
|
-
const removeEventListener = () => {
|
|
677
|
-
echartsInstance.off("highlight");
|
|
678
|
-
echartsInstance.off("globalout");
|
|
679
|
-
echartsInstance.off("contextmenu");
|
|
680
|
-
echartsInstance.off("datazoom");
|
|
681
|
-
};
|
|
682
|
-
|
|
683
|
-
// 键盘事件
|
|
684
|
-
const keyDownEvent = (e: KeyboardEvent) => {
|
|
685
|
-
if (!echartsInstance) return;
|
|
686
|
-
// 只有选中或者按ctrl才激活按键
|
|
687
|
-
if (!(e.ctrlKey || props.isSelect)) return;
|
|
688
|
-
const option = echartsInstance.getOption() as EChartsOption;
|
|
689
|
-
let { startValue, endValue, start, end } = (option.dataZoom as DataZoomComponentOption[])[0] as {
|
|
690
|
-
startValue: number;
|
|
691
|
-
endValue: number;
|
|
692
|
-
};
|
|
693
|
-
const handleLeft = () => {
|
|
694
|
-
// 左按键
|
|
695
|
-
if (startValue === 0) {
|
|
696
|
-
return;
|
|
697
|
-
}
|
|
698
|
-
startValue = startValue - 1;
|
|
699
|
-
endValue = endValue - 1;
|
|
700
|
-
echartsInstance.dispatchAction({
|
|
701
|
-
type: "dataZoom",
|
|
702
|
-
startValue,
|
|
703
|
-
endValue,
|
|
704
|
-
maxValueSpan: config.value.maxValueSpan,
|
|
705
|
-
});
|
|
706
|
-
};
|
|
707
|
-
const handleRight = () => {
|
|
708
|
-
// 右按键
|
|
709
|
-
// 如果开启了动态后续数据加载
|
|
710
|
-
if (config.value.dynamicLoadConfig.futureVisible && !futureIsLoading && !futureIsAllLoad.value) {
|
|
711
|
-
startValue = startValue + 1;
|
|
712
|
-
endValue = endValue + 1;
|
|
713
|
-
echartsInstance.dispatchAction({
|
|
714
|
-
type: "dataZoom",
|
|
715
|
-
startValue,
|
|
716
|
-
endValue,
|
|
717
|
-
maxValueSpan: config.value.maxValueSpan,
|
|
718
|
-
});
|
|
719
|
-
} else {
|
|
720
|
-
if (endValue === option.xAxis[0].data.length - 1) {
|
|
721
|
-
return;
|
|
722
|
-
}
|
|
723
|
-
startValue = startValue + 1;
|
|
724
|
-
endValue = endValue + 1;
|
|
725
|
-
echartsInstance.dispatchAction({
|
|
726
|
-
type: "dataZoom",
|
|
727
|
-
startValue,
|
|
728
|
-
endValue,
|
|
729
|
-
maxValueSpan: config.value.maxValueSpan,
|
|
730
|
-
});
|
|
731
|
-
}
|
|
732
|
-
};
|
|
733
|
-
const handleUp = () => {
|
|
734
|
-
// 上按键-放大 最少保持5条数据
|
|
735
|
-
if (endValue - startValue < 5) {
|
|
736
|
-
return;
|
|
737
|
-
}
|
|
738
|
-
// 以鼠标指定的K线为中心点进行放大
|
|
739
|
-
const startDiff = Math.floor((activeIndex.value - startValue) / 2) + 1;
|
|
740
|
-
const endDiff = Math.floor((endValue - activeIndex.value) / 2) + 1;
|
|
741
|
-
startValue = startValue + startDiff;
|
|
742
|
-
endValue = endValue - endDiff;
|
|
743
|
-
echartsInstance.dispatchAction({
|
|
744
|
-
type: "dataZoom",
|
|
745
|
-
startValue,
|
|
746
|
-
endValue,
|
|
747
|
-
actionIsWheel: true, // 标记为缩放
|
|
748
|
-
maxValueSpan: config.value.maxValueSpan,
|
|
749
|
-
});
|
|
750
|
-
};
|
|
751
|
-
const handleDown = () => {
|
|
752
|
-
// 下按键-缩小
|
|
753
|
-
// const diff = Math.min(50, activeIndex.value - startValue);
|
|
754
|
-
// startValue = startValue - diff - 1;
|
|
755
|
-
start = start - (end - start) / 4;
|
|
756
|
-
echartsInstance.dispatchAction({
|
|
757
|
-
type: "dataZoom",
|
|
758
|
-
start,
|
|
759
|
-
end,
|
|
760
|
-
actionIsWheel: true, // 标记为缩放
|
|
761
|
-
maxValueSpan: config.value.maxValueSpan,
|
|
762
|
-
});
|
|
763
|
-
};
|
|
764
|
-
const callBackMap = new Map([
|
|
765
|
-
["ArrowLeft", handleLeft],
|
|
766
|
-
["ArrowRight", handleRight],
|
|
767
|
-
["ArrowUp", handleUp],
|
|
768
|
-
["ArrowDown", handleDown],
|
|
769
|
-
]);
|
|
770
|
-
const callBack = callBackMap.get(e.code);
|
|
771
|
-
callBack instanceof Function && callBack();
|
|
772
|
-
};
|
|
773
|
-
|
|
774
|
-
/**
|
|
775
|
-
* @description: K线组件初始化
|
|
776
|
-
*/
|
|
777
|
-
const init = async () => {
|
|
778
|
-
let Initializing: boolean | null = true; // 正在初始化
|
|
779
|
-
// 1.初始化图表
|
|
780
|
-
echartsInstance = echarts.init(echartsRef.value) as EChartsType;
|
|
781
|
-
// 2.绘制
|
|
782
|
-
await draw();
|
|
783
|
-
// 3.初始化右键菜单
|
|
784
|
-
menuData.value = props.defaultMenuData as MenuDataType;
|
|
785
|
-
// 4.初始化数据激活索引
|
|
786
|
-
activeIndex.value = ((echartsInstance.getOption().dataZoom as DataZoomComponentOption[])[0].endValue as number) ?? -1;
|
|
787
|
-
// 5.进行图表事件绑定
|
|
788
|
-
addEventListener();
|
|
789
|
-
// 6.进行DOM监控,图表重加载
|
|
790
|
-
chartDomObserver = new ResizeObserver(() => {
|
|
791
|
-
if (Initializing) {
|
|
792
|
-
Initializing = null;
|
|
793
|
-
return;
|
|
794
|
-
}
|
|
795
|
-
echartsInstance.resize();
|
|
796
|
-
draw("line");
|
|
797
|
-
});
|
|
798
|
-
chartDomObserver.observe(echartsRef.value);
|
|
799
|
-
// 7.绑定键盘事件
|
|
800
|
-
window.addEventListener("keydown", keyDownEvent);
|
|
801
|
-
};
|
|
802
|
-
|
|
803
|
-
onMounted(() => {
|
|
804
|
-
init();
|
|
805
|
-
});
|
|
806
|
-
|
|
807
|
-
onUnmounted(() => {
|
|
808
|
-
// 1.解绑
|
|
809
|
-
removeEventListener();
|
|
810
|
-
window.removeEventListener("keydown", keyDownEvent);
|
|
811
|
-
// 2.销毁实例
|
|
812
|
-
echartsInstance.dispose();
|
|
813
|
-
// 3.取消监听图表DOM
|
|
814
|
-
chartDomObserver.disconnect();
|
|
815
|
-
chartDomObserver = null;
|
|
816
|
-
});
|
|
817
|
-
</script>
|
|
818
|
-
|
|
819
|
-
<template>
|
|
820
|
-
<!-- 神兔-K线组件 -->
|
|
821
|
-
<div class="st-kline">
|
|
822
|
-
<!-- Tips -->
|
|
823
|
-
<div class="st-kline-header">
|
|
824
|
-
<!-- 开, 高, 低, 收 -->
|
|
825
|
-
<Tips :data="kLineTips" />
|
|
826
|
-
<!-- 指标 -->
|
|
827
|
-
<Tips :data="indicatorTips" />
|
|
828
|
-
<!-- 价格趋势[价差定制] -->
|
|
829
|
-
<Tips :data="priceTrendTips" />
|
|
830
|
-
</div>
|
|
831
|
-
<!-- 图表 + 菜单 -->
|
|
832
|
-
<Contextmenu class="st-kline-body" @closeContextMenuCallBack="closeContextMenuCallBack">
|
|
833
|
-
<!-- 图表 -->
|
|
834
|
-
<div ref="echartsRef" :class="cursorPenVisible ? 'st-kline-chart cursorPen' : 'st-kline-chart'" />
|
|
835
|
-
<!-- 菜单 -->
|
|
836
|
-
<template #popover>
|
|
837
|
-
<el-menu class="menu">
|
|
838
|
-
<el-menu-item
|
|
839
|
-
v-for="item in menuData"
|
|
840
|
-
:key="item.label"
|
|
841
|
-
:index="item.label"
|
|
842
|
-
class="menuItem"
|
|
843
|
-
@click="menuClick(item)"
|
|
844
|
-
>
|
|
845
|
-
{{ item.label }}
|
|
846
|
-
</el-menu-item>
|
|
847
|
-
</el-menu>
|
|
848
|
-
</template>
|
|
849
|
-
</Contextmenu>
|
|
850
|
-
</div>
|
|
851
|
-
</template>
|
|
852
|
-
|
|
853
|
-
<style lang="scss">
|
|
854
|
-
// 需要写在外面,不然会被Vue唯一标识符顶掉导致样式不生效
|
|
855
|
-
.cursorPen canvas {
|
|
856
|
-
cursor: url(./images/pen.png) -30 30, auto !important;
|
|
857
|
-
}
|
|
858
|
-
</style>
|
|
859
|
-
<style lang="scss" scoped>
|
|
860
|
-
.st-kline {
|
|
861
|
-
width: 100%;
|
|
862
|
-
height: 100%;
|
|
863
|
-
background: #000;
|
|
864
|
-
overflow-x: hidden;
|
|
865
|
-
position: relative; // 配合提供给菜单定位
|
|
866
|
-
// K线头部区域: Tips
|
|
867
|
-
&-header {
|
|
868
|
-
height: 34px;
|
|
869
|
-
position: absolute;
|
|
870
|
-
left: 66px;
|
|
871
|
-
}
|
|
872
|
-
&-body {
|
|
873
|
-
width: 100%;
|
|
874
|
-
height: 100%;
|
|
875
|
-
}
|
|
876
|
-
&-chart {
|
|
877
|
-
width: 100%;
|
|
878
|
-
height: 100%;
|
|
879
|
-
}
|
|
880
|
-
.menu {
|
|
881
|
-
border-radius: 4px;
|
|
882
|
-
overflow: hidden;
|
|
883
|
-
background-color: white;
|
|
884
|
-
border-right: 0;
|
|
885
|
-
.menuItem {
|
|
886
|
-
font-size: 16px;
|
|
887
|
-
height: 32px;
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
}
|
|
891
|
-
</style>
|