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
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import axios from 'axios'
|
|
2
|
-
|
|
3
|
-
export const getKlineDataApi = async(params) => {
|
|
4
|
-
const res = await axios({
|
|
5
|
-
method: 'post',
|
|
6
|
-
headers: {
|
|
7
|
-
token: '041fd377d5d5efc7e08e2ed5b61b0c8d',
|
|
8
|
-
},
|
|
9
|
-
url: 'http://invest.hzyotoy.com/common/webjars/qt/getSingleCycleSingleVariety',
|
|
10
|
-
data: params,
|
|
11
|
-
})
|
|
12
|
-
return res.data.body
|
|
13
|
-
}
|
|
@@ -1,571 +0,0 @@
|
|
|
1
|
-
import { stMath } from "st-func";
|
|
2
|
-
|
|
3
|
-
const defaultConfig = {
|
|
4
|
-
defaultShowCount: 200, // 默认展示条数
|
|
5
|
-
addCount: 2000, // 首屏加载条数,滚动加载条数
|
|
6
|
-
preLoadCount: 800, // 预加载数据条数(用于计算指标线)
|
|
7
|
-
maxShowCount: 5000, // 一屏最多渲染条数上限
|
|
8
|
-
gridLeft: 60, // echarts绘图左侧grid距离
|
|
9
|
-
gridRight: 60, // echarts绘图右侧grid距离
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
// 格式化配置
|
|
13
|
-
export const formatConfig = (config) => {
|
|
14
|
-
return {
|
|
15
|
-
...defaultConfig,
|
|
16
|
-
...config,
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// DOM缩放监视器
|
|
21
|
-
class ResizeListener {
|
|
22
|
-
constructor(dom, callback) {
|
|
23
|
-
this.resizeRo = null;
|
|
24
|
-
this.isFirst = true;
|
|
25
|
-
this.init(dom, callback);
|
|
26
|
-
}
|
|
27
|
-
init(dom, callback) {
|
|
28
|
-
this.resizeRo = new ResizeObserver(() => {
|
|
29
|
-
if (this.isFirst) {
|
|
30
|
-
this.isFirst = null;
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
callback();
|
|
34
|
-
});
|
|
35
|
-
this.resizeRo.observe(dom);
|
|
36
|
-
}
|
|
37
|
-
dispose() {
|
|
38
|
-
this.resizeRo.disconnect();
|
|
39
|
-
this.resizeRo = null;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
export const resizeListener = (dom, callback) => {
|
|
43
|
-
return new ResizeListener(dom, callback);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
// 防抖
|
|
47
|
-
export const debounce = (callBack, delay = 500, immediate = false) => {
|
|
48
|
-
let timer = null;
|
|
49
|
-
return function (...args) {
|
|
50
|
-
// 清除已有的定时器
|
|
51
|
-
clearTimeout(timer);
|
|
52
|
-
if (immediate) {
|
|
53
|
-
// 如果是立即执行模式,且为第一次触发,则执行函数
|
|
54
|
-
const runNow = !timer;
|
|
55
|
-
timer = setTimeout(() => {
|
|
56
|
-
timer = null;
|
|
57
|
-
}, delay);
|
|
58
|
-
if (runNow) {
|
|
59
|
-
callBack.apply(this, args);
|
|
60
|
-
}
|
|
61
|
-
} else {
|
|
62
|
-
// 非立即执行模式,延迟指定时间后再执行函数
|
|
63
|
-
timer = setTimeout(() => {
|
|
64
|
-
callBack.apply(this, args);
|
|
65
|
-
}, delay);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
// ------------------生成绘图配置项函数------------------
|
|
71
|
-
// 预警线
|
|
72
|
-
export const getWarningLineGraphic = (data, mainChart) => {
|
|
73
|
-
// 获取基础的配置项信息
|
|
74
|
-
const mainChartOption = mainChart.getOption();
|
|
75
|
-
const gridLeft = mainChartOption.grid[0].left.split("px")[0];
|
|
76
|
-
const gridRight = mainChartOption.grid[0].right.split("px")[0];
|
|
77
|
-
// 生成配置项
|
|
78
|
-
const elements = data.reduce((result, item) => {
|
|
79
|
-
const { value, text, customInfo } = item;
|
|
80
|
-
let dragStart = 0; // 记录拖拽开始的位置
|
|
81
|
-
result.push({
|
|
82
|
-
type: "group",
|
|
83
|
-
name: "warningLine",
|
|
84
|
-
info: customInfo,
|
|
85
|
-
draggable: "vertical",
|
|
86
|
-
children: [
|
|
87
|
-
{
|
|
88
|
-
type: "line",
|
|
89
|
-
info: customInfo,
|
|
90
|
-
shape: {
|
|
91
|
-
x1: gridLeft, // 开始X坐标
|
|
92
|
-
y1: mainChart.convertToPixel({ yAxisIndex: 0 }, value), // 开始Y坐标
|
|
93
|
-
x2: mainChart.getWidth() - gridRight, // 结束X坐标
|
|
94
|
-
y2: mainChart.convertToPixel({ yAxisIndex: 0 }, value), // 结束Y坐标
|
|
95
|
-
},
|
|
96
|
-
style: {
|
|
97
|
-
stroke: "#FFF",
|
|
98
|
-
lineWidth: 1,
|
|
99
|
-
lineDash: [8, 4],
|
|
100
|
-
},
|
|
101
|
-
z: 10,
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
type: "text",
|
|
105
|
-
info: customInfo,
|
|
106
|
-
x: mainChart.getWidth() - gridRight,
|
|
107
|
-
y: mainChart.convertToPixel({ yAxisIndex: 0 }, value) - 5,
|
|
108
|
-
style: {
|
|
109
|
-
fill: "#FFF",
|
|
110
|
-
text,
|
|
111
|
-
stroke: "#000",
|
|
112
|
-
lineWidth: 1,
|
|
113
|
-
opacity: 1,
|
|
114
|
-
},
|
|
115
|
-
z: 10,
|
|
116
|
-
},
|
|
117
|
-
],
|
|
118
|
-
// 事件:开始拖拽
|
|
119
|
-
ondragstart: (params) => {
|
|
120
|
-
dragStart = params.offsetY; // 记录拖拽开始坐标
|
|
121
|
-
},
|
|
122
|
-
// 事件:结束拖拽
|
|
123
|
-
ondragend: (params) => {
|
|
124
|
-
/**
|
|
125
|
-
* 之所以不直接使用dragEnd,是因为echarts拖拽会有偏差问题
|
|
126
|
-
* 需要使用偏移量才会更加准备,不然会出现画完线渲染位置和拖拽位置不一致
|
|
127
|
-
*/
|
|
128
|
-
const dragEnd = params.offsetY; // 记录结束拖拽坐标
|
|
129
|
-
const dragInterval = dragEnd - dragStart; // 拖拽偏移量
|
|
130
|
-
if (dragInterval !== 0) {
|
|
131
|
-
// 计算总偏移量
|
|
132
|
-
const y = dragInterval + mainChart.convertToPixel({ yAxisIndex: 0 }, value);
|
|
133
|
-
// 计算偏移后对应的Y轴数据
|
|
134
|
-
const yAxisValue = mainChart.convertFromPixel({ yAxisIndex: 0 }, y);
|
|
135
|
-
console.log("拖拽结束,可以在这里发送请求,并重查额外画线数据后重新绘制");
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
});
|
|
139
|
-
return result;
|
|
140
|
-
}, []);
|
|
141
|
-
return elements;
|
|
142
|
-
};
|
|
143
|
-
// 持仓线
|
|
144
|
-
export const getPositionLineGraphic = (data, mainChart) => {
|
|
145
|
-
// 获取基础的配置项信息
|
|
146
|
-
const mainChartOption = mainChart.getOption();
|
|
147
|
-
const gridLeft = mainChartOption.grid[0].left.split("px")[0];
|
|
148
|
-
const gridRight = mainChartOption.grid[0].right.split("px")[0];
|
|
149
|
-
// 生成配置项
|
|
150
|
-
const elements = data.reduce((result, item) => {
|
|
151
|
-
const { value, text, customInfo } = item;
|
|
152
|
-
result.push({
|
|
153
|
-
type: "group",
|
|
154
|
-
name: "positionLine",
|
|
155
|
-
info: customInfo,
|
|
156
|
-
children: [
|
|
157
|
-
{
|
|
158
|
-
type: "line",
|
|
159
|
-
info: customInfo,
|
|
160
|
-
shape: {
|
|
161
|
-
x1: gridLeft, // 开始X坐标
|
|
162
|
-
y1: mainChart.convertToPixel({ yAxisIndex: 0 }, value), // 开始Y坐标
|
|
163
|
-
x2: mainChart.getWidth() - gridRight, // 结束X坐标
|
|
164
|
-
y2: mainChart.convertToPixel({ yAxisIndex: 0 }, value), // 结束Y坐标
|
|
165
|
-
},
|
|
166
|
-
style: {
|
|
167
|
-
stroke: "#e45d07",
|
|
168
|
-
lineWidth: 1,
|
|
169
|
-
},
|
|
170
|
-
z: 10,
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
// 保证文字居中,外层包裹一层group用于定位
|
|
174
|
-
type: "group",
|
|
175
|
-
info: customInfo,
|
|
176
|
-
x: mainChart.getWidth() / 2,
|
|
177
|
-
y: mainChart.convertToPixel({ yAxisIndex: 0 }, value) - 5,
|
|
178
|
-
children: [
|
|
179
|
-
{
|
|
180
|
-
type: "text",
|
|
181
|
-
left: "center",
|
|
182
|
-
style: {
|
|
183
|
-
fill: "#FFF",
|
|
184
|
-
text,
|
|
185
|
-
stroke: "#000",
|
|
186
|
-
lineWidth: 1,
|
|
187
|
-
opacity: 0, // 暂时隐藏
|
|
188
|
-
},
|
|
189
|
-
z: 10,
|
|
190
|
-
},
|
|
191
|
-
],
|
|
192
|
-
},
|
|
193
|
-
],
|
|
194
|
-
// 事件:鼠标滑入
|
|
195
|
-
onmouseover: (params) => {
|
|
196
|
-
let groupItem = null;
|
|
197
|
-
if (params.target.type === "line") {
|
|
198
|
-
groupItem = params.target.parent;
|
|
199
|
-
} else if (params.target.type === "tspan") {
|
|
200
|
-
groupItem = params.target.parent.parent.parent;
|
|
201
|
-
}
|
|
202
|
-
// 展示文本
|
|
203
|
-
groupItem.children()[1].children()[0].animate("style", false).when(200, { opacity: 1 }).start();
|
|
204
|
-
},
|
|
205
|
-
// 事件:鼠标滑出
|
|
206
|
-
onmouseout: (params) => {
|
|
207
|
-
let groupItem = null;
|
|
208
|
-
if (params.target.type === "line") {
|
|
209
|
-
groupItem = params.target.parent;
|
|
210
|
-
} else if (params.target.type === "tspan") {
|
|
211
|
-
groupItem = params.target.parent.parent.parent;
|
|
212
|
-
}
|
|
213
|
-
// 隐藏文本
|
|
214
|
-
groupItem.children()[1].children()[0].animate("style", false).when(200, { opacity: 0 }).start();
|
|
215
|
-
},
|
|
216
|
-
});
|
|
217
|
-
return result;
|
|
218
|
-
}, []);
|
|
219
|
-
return elements;
|
|
220
|
-
};
|
|
221
|
-
// 条件单线
|
|
222
|
-
export const getConditionLineGraphic = (data, mainChart) => {
|
|
223
|
-
// 获取基础的配置项信息
|
|
224
|
-
const mainChartOption = mainChart.getOption();
|
|
225
|
-
const gridLeft = mainChartOption.grid[0].left.split("px")[0];
|
|
226
|
-
const gridRight = mainChartOption.grid[0].right.split("px")[0];
|
|
227
|
-
// 键盘事件函数
|
|
228
|
-
let handleKeyDown = null;
|
|
229
|
-
let handleKeyUp = null;
|
|
230
|
-
// 工具函数: 控制辅线内容展示与否
|
|
231
|
-
const handleLineShow = (groupItem, show) => {
|
|
232
|
-
// 条件单辅线-止盈线内容
|
|
233
|
-
groupItem.children()[2]?.animate("style", false).when(200, { opacity: ~~show }).start();
|
|
234
|
-
groupItem.children()[3].children()[0]?.animate("style", false).when(200, { opacity: ~~show }).start();
|
|
235
|
-
// 条件单辅线-止损线内容
|
|
236
|
-
groupItem.children()[4]?.animate("style", false).when(200, { opacity: ~~show }).start();
|
|
237
|
-
groupItem.children()[5].children()[0]?.animate("style", false).when(200, { opacity: ~~show }).start();
|
|
238
|
-
};
|
|
239
|
-
const elements = data.reduce((result, item) => {
|
|
240
|
-
const { value, text, profitValue, profitText, lossValue, lossText, customInfo } = item;
|
|
241
|
-
result.push({
|
|
242
|
-
type: "group",
|
|
243
|
-
name: "conditionLine",
|
|
244
|
-
info: customInfo,
|
|
245
|
-
children: [
|
|
246
|
-
// 条件单主线
|
|
247
|
-
{
|
|
248
|
-
type: "line",
|
|
249
|
-
info: customInfo,
|
|
250
|
-
shape: {
|
|
251
|
-
x1: gridLeft, // 开始X坐标
|
|
252
|
-
y1: mainChart.convertToPixel({ yAxisIndex: 0 }, value), // 开始Y坐标
|
|
253
|
-
x2: mainChart.getWidth() - gridRight, // 结束X坐标
|
|
254
|
-
y2: mainChart.convertToPixel({ yAxisIndex: 0 }, value), // 结束Y坐标
|
|
255
|
-
},
|
|
256
|
-
style: {
|
|
257
|
-
stroke: "#FFF",
|
|
258
|
-
lineWidth: 1,
|
|
259
|
-
},
|
|
260
|
-
z: 10,
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
// 保证文字居中,外层包裹一层group用于定位
|
|
264
|
-
type: "group",
|
|
265
|
-
info: customInfo,
|
|
266
|
-
x: mainChart.getWidth() / 2,
|
|
267
|
-
y: mainChart.convertToPixel({ yAxisIndex: 0 }, value) - 5,
|
|
268
|
-
children: [
|
|
269
|
-
{
|
|
270
|
-
type: "text",
|
|
271
|
-
left: "center",
|
|
272
|
-
style: {
|
|
273
|
-
fill: "#FFF",
|
|
274
|
-
text,
|
|
275
|
-
stroke: "#000",
|
|
276
|
-
lineWidth: 1,
|
|
277
|
-
},
|
|
278
|
-
z: 10,
|
|
279
|
-
},
|
|
280
|
-
],
|
|
281
|
-
},
|
|
282
|
-
// 条件单辅线-止盈线
|
|
283
|
-
{
|
|
284
|
-
type: "line",
|
|
285
|
-
info: customInfo,
|
|
286
|
-
shape: {
|
|
287
|
-
x1: gridLeft, // 开始X坐标
|
|
288
|
-
y1: mainChart.convertToPixel({ yAxisIndex: 0 }, profitValue), // 开始Y坐标
|
|
289
|
-
x2: mainChart.getWidth() - gridRight, // 结束X坐标
|
|
290
|
-
y2: mainChart.convertToPixel({ yAxisIndex: 0 }, profitValue), // 结束Y坐标
|
|
291
|
-
},
|
|
292
|
-
style: {
|
|
293
|
-
stroke: "#b71e44",
|
|
294
|
-
lineWidth: 1,
|
|
295
|
-
lineDash: [8, 4],
|
|
296
|
-
opacity: 0,
|
|
297
|
-
},
|
|
298
|
-
z: 10,
|
|
299
|
-
},
|
|
300
|
-
{
|
|
301
|
-
// 保证文字居中,外层包裹一层group用于定位
|
|
302
|
-
type: "group",
|
|
303
|
-
info: customInfo,
|
|
304
|
-
x: mainChart.getWidth() / 2,
|
|
305
|
-
y: mainChart.convertToPixel({ yAxisIndex: 0 }, profitValue) - 5,
|
|
306
|
-
children: [
|
|
307
|
-
{
|
|
308
|
-
type: "text",
|
|
309
|
-
left: "center",
|
|
310
|
-
style: {
|
|
311
|
-
fill: "#FFF",
|
|
312
|
-
text: profitText,
|
|
313
|
-
stroke: "#000",
|
|
314
|
-
lineWidth: 1,
|
|
315
|
-
opacity: 0, // 暂时隐藏
|
|
316
|
-
},
|
|
317
|
-
z: 10,
|
|
318
|
-
},
|
|
319
|
-
],
|
|
320
|
-
},
|
|
321
|
-
// 条件单辅线-止损线
|
|
322
|
-
{
|
|
323
|
-
type: "line",
|
|
324
|
-
info: customInfo,
|
|
325
|
-
shape: {
|
|
326
|
-
x1: gridLeft, // 开始X坐标
|
|
327
|
-
y1: mainChart.convertToPixel({ yAxisIndex: 0 }, lossValue), // 开始Y坐标
|
|
328
|
-
x2: mainChart.getWidth() - gridRight, // 结束X坐标
|
|
329
|
-
y2: mainChart.convertToPixel({ yAxisIndex: 0 }, lossValue), // 结束Y坐标
|
|
330
|
-
},
|
|
331
|
-
style: {
|
|
332
|
-
stroke: "#749b66",
|
|
333
|
-
lineWidth: 1,
|
|
334
|
-
lineDash: [8, 4],
|
|
335
|
-
opacity: 0,
|
|
336
|
-
},
|
|
337
|
-
z: 10,
|
|
338
|
-
},
|
|
339
|
-
{
|
|
340
|
-
// 保证文字居中,外层包裹一层group用于定位
|
|
341
|
-
type: "group",
|
|
342
|
-
info: customInfo,
|
|
343
|
-
x: mainChart.getWidth() / 2,
|
|
344
|
-
y: mainChart.convertToPixel({ yAxisIndex: 0 }, lossValue) - 5,
|
|
345
|
-
children: [
|
|
346
|
-
{
|
|
347
|
-
type: "text",
|
|
348
|
-
left: "center",
|
|
349
|
-
style: {
|
|
350
|
-
fill: "#FFF",
|
|
351
|
-
text: lossText,
|
|
352
|
-
stroke: "#000",
|
|
353
|
-
lineWidth: 1,
|
|
354
|
-
opacity: 0, // 暂时隐藏
|
|
355
|
-
},
|
|
356
|
-
z: 10,
|
|
357
|
-
},
|
|
358
|
-
],
|
|
359
|
-
},
|
|
360
|
-
],
|
|
361
|
-
// 事件:鼠标滑入
|
|
362
|
-
onmouseover: (params) => {
|
|
363
|
-
let groupItem = null;
|
|
364
|
-
if (params.target.type === "line") {
|
|
365
|
-
groupItem = params.target.parent;
|
|
366
|
-
} else if (params.target.type === "tspan") {
|
|
367
|
-
groupItem = params.target.parent.parent.parent;
|
|
368
|
-
}
|
|
369
|
-
// 开始监视Alt键
|
|
370
|
-
handleKeyDown = (e) => {
|
|
371
|
-
e.preventDefault();
|
|
372
|
-
if (e.code === "AltLeft" || e.code === "AltRight") {
|
|
373
|
-
handleLineShow(groupItem, true);
|
|
374
|
-
}
|
|
375
|
-
};
|
|
376
|
-
handleKeyUp = (e) => {
|
|
377
|
-
if (e.code === "AltLeft" || e.code === "AltRight") {
|
|
378
|
-
handleLineShow(groupItem, false);
|
|
379
|
-
}
|
|
380
|
-
};
|
|
381
|
-
window.addEventListener("keydown", handleKeyDown);
|
|
382
|
-
window.addEventListener("keyup", handleKeyUp);
|
|
383
|
-
},
|
|
384
|
-
// 事件:鼠标滑出
|
|
385
|
-
onmouseout: (params) => {
|
|
386
|
-
let groupItem = null;
|
|
387
|
-
if (params.target.type === "line") {
|
|
388
|
-
groupItem = params.target.parent;
|
|
389
|
-
} else if (params.target.type === "tspan") {
|
|
390
|
-
groupItem = params.target.parent.parent.parent;
|
|
391
|
-
}
|
|
392
|
-
// 取消监视Alt键
|
|
393
|
-
handleLineShow(groupItem, false);
|
|
394
|
-
window.removeEventListener("keydown", handleKeyDown);
|
|
395
|
-
window.removeEventListener("keyup", handleKeyUp);
|
|
396
|
-
},
|
|
397
|
-
});
|
|
398
|
-
return result;
|
|
399
|
-
}, []);
|
|
400
|
-
return elements;
|
|
401
|
-
};
|
|
402
|
-
// 相关度线
|
|
403
|
-
export const getRelevanceLineSeries = (data) => {
|
|
404
|
-
return {
|
|
405
|
-
type: "line",
|
|
406
|
-
name: "relevance",
|
|
407
|
-
data,
|
|
408
|
-
symbol: "none",
|
|
409
|
-
yAxisIndex: 1,
|
|
410
|
-
connectNulls: true,
|
|
411
|
-
itemStyle: {
|
|
412
|
-
color: "#FFF",
|
|
413
|
-
},
|
|
414
|
-
lineStyle: {
|
|
415
|
-
width: 1,
|
|
416
|
-
},
|
|
417
|
-
label: {
|
|
418
|
-
show: true, // 显示文字
|
|
419
|
-
position: "top", // 文字位置
|
|
420
|
-
formatter: (params) => {
|
|
421
|
-
return `相关度: ${params.data[1]}`;
|
|
422
|
-
},
|
|
423
|
-
textStyle: {
|
|
424
|
-
color: "#FFF", // 文字颜色
|
|
425
|
-
fontSize: 14, // 文字字体大小
|
|
426
|
-
},
|
|
427
|
-
},
|
|
428
|
-
};
|
|
429
|
-
};
|
|
430
|
-
// 分布统计线
|
|
431
|
-
export const getDistributionLineGraphic = (data, mainChart) => {
|
|
432
|
-
// 获取基础的配置项信息
|
|
433
|
-
const mainChartOption = mainChart.getOption();
|
|
434
|
-
const gridLeft = ~~mainChartOption.grid[0].left.split("px")[0];
|
|
435
|
-
const gridRight = ~~mainChartOption.grid[0].right.split("px")[0];
|
|
436
|
-
// 获取当屏K线数据
|
|
437
|
-
const { startValue, endValue } = mainChartOption.dataZoom[0];
|
|
438
|
-
const nowScreenKlineData = data.slice(startValue, endValue + 1);
|
|
439
|
-
// 根据当屏K线数据计算不同收盘价出现的次数
|
|
440
|
-
const countMap = nowScreenKlineData.reduce((result, item) => {
|
|
441
|
-
const closePrice = item[4];
|
|
442
|
-
if (result[closePrice]) {
|
|
443
|
-
result[closePrice] += 1;
|
|
444
|
-
} else {
|
|
445
|
-
result[closePrice] = 1;
|
|
446
|
-
}
|
|
447
|
-
return result;
|
|
448
|
-
}, {});
|
|
449
|
-
// -----------计算相关展示数值-----------
|
|
450
|
-
// (1).均值
|
|
451
|
-
const meanValue =
|
|
452
|
-
nowScreenKlineData.reduce((result, item) => {
|
|
453
|
-
return result + item[4];
|
|
454
|
-
}, 0) / nowScreenKlineData.length;
|
|
455
|
-
// (2).距均值
|
|
456
|
-
const disMeanValue = nowScreenKlineData[nowScreenKlineData.length - 1][4] - meanValue;
|
|
457
|
-
// (3).中值
|
|
458
|
-
const medianValue = percentToValue(nowScreenKlineData, 1, 50);
|
|
459
|
-
// (4).标准差
|
|
460
|
-
const standardDeviationValue = calculateStandardDeviation(nowScreenKlineData);
|
|
461
|
-
// (5).距均值/标准差
|
|
462
|
-
const disMeanSDValue = standardDeviationValue ? disMeanValue / standardDeviationValue : 0;
|
|
463
|
-
// (6).百分位
|
|
464
|
-
const percentileValue = valueToPercent(nowScreenKlineData, 1, nowScreenKlineData[nowScreenKlineData.length - 1][4]);
|
|
465
|
-
// -------------------------------------
|
|
466
|
-
const countLine = Object.keys(countMap).map((key) => {
|
|
467
|
-
return {
|
|
468
|
-
type: "line",
|
|
469
|
-
shape: {
|
|
470
|
-
x1: mainChart.getWidth() - gridRight - 100 * countMap[key],
|
|
471
|
-
y1: mainChart.convertToPixel({ yAxisIndex: 0 }, key),
|
|
472
|
-
x2: mainChart.getWidth() - gridRight,
|
|
473
|
-
y2: mainChart.convertToPixel({ yAxisIndex: 0 }, key),
|
|
474
|
-
},
|
|
475
|
-
style: {
|
|
476
|
-
stroke: "rgb(124,124,124)",
|
|
477
|
-
lineWidth: 1,
|
|
478
|
-
},
|
|
479
|
-
z: 10,
|
|
480
|
-
};
|
|
481
|
-
});
|
|
482
|
-
const countText = {
|
|
483
|
-
type: "text",
|
|
484
|
-
x: gridLeft + 6,
|
|
485
|
-
y: mainChart.getHeight() - 50,
|
|
486
|
-
style: {
|
|
487
|
-
fill: "#FFF",
|
|
488
|
-
text: `均值: ${stMath.formatValue(meanValue)}\xa0\xa0\xa0\xa0距均值: ${stMath.formatValue(
|
|
489
|
-
disMeanValue
|
|
490
|
-
)}\xa0\xa0\xa0\xa0中值: ${stMath.formatValue(medianValue)}\xa0\xa0\xa0\xa0标准差: ${stMath.formatValue(
|
|
491
|
-
standardDeviationValue
|
|
492
|
-
)}\xa0\xa0\xa0\xa0距均值/标准差: ${stMath.formatValue(
|
|
493
|
-
disMeanSDValue
|
|
494
|
-
)}\xa0\xa0\xa0\xa0百分位: ${stMath.formatValue(percentileValue)}%`,
|
|
495
|
-
lineWidth: 1,
|
|
496
|
-
opacity: 1,
|
|
497
|
-
},
|
|
498
|
-
z: 10,
|
|
499
|
-
};
|
|
500
|
-
const elements = {
|
|
501
|
-
type: "group",
|
|
502
|
-
name: "distribution",
|
|
503
|
-
draggable: false,
|
|
504
|
-
children: [...countLine, countText],
|
|
505
|
-
};
|
|
506
|
-
return elements;
|
|
507
|
-
};
|
|
508
|
-
|
|
509
|
-
// ------------------计算函数------------------
|
|
510
|
-
// 根据值计算分位
|
|
511
|
-
const valueToPercent = (data, dataIndex, value) => {
|
|
512
|
-
const { round, add, subtract, multiply, divide } = stMath;
|
|
513
|
-
const sortData = data.map((i) => i[dataIndex]).sort((a, b) => a - b);
|
|
514
|
-
let position = 0;
|
|
515
|
-
for (let i = 0; i < sortData.length; i++) {
|
|
516
|
-
if (sortData[i] === value) {
|
|
517
|
-
// 位置为整数
|
|
518
|
-
position = i;
|
|
519
|
-
break;
|
|
520
|
-
} else if (sortData[i] >= value) {
|
|
521
|
-
// 位置为小数
|
|
522
|
-
position = add(i, divide(subtract(sortData[i + 1], sortData[i]), sortData[i]));
|
|
523
|
-
break;
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
return round(divide(multiply(position, 100), data.length + 1));
|
|
527
|
-
};
|
|
528
|
-
// 根据分位计算值
|
|
529
|
-
const percentToValue = (data, dataIndex, percent) => {
|
|
530
|
-
const { round, add, subtract, multiply, divide } = stMath;
|
|
531
|
-
const sortData = data.map((i) => i[dataIndex]).sort((a, b) => a - b);
|
|
532
|
-
const position = multiply(data.length + 1, divide(percent, 100));
|
|
533
|
-
const positionInterger = Math.floor(position);
|
|
534
|
-
const positionDecimal = subtract(position, positionInterger);
|
|
535
|
-
if (positionDecimal === 0) {
|
|
536
|
-
// 位置为整数
|
|
537
|
-
return round(sortData[position]);
|
|
538
|
-
} else {
|
|
539
|
-
// 位置为小数
|
|
540
|
-
return round(
|
|
541
|
-
add(
|
|
542
|
-
sortData[positionInterger],
|
|
543
|
-
multiply(
|
|
544
|
-
subtract(
|
|
545
|
-
sortData[positionInterger >= data.length - 1 ? positionInterger : positionInterger + 1],
|
|
546
|
-
sortData[positionInterger]
|
|
547
|
-
),
|
|
548
|
-
positionDecimal
|
|
549
|
-
)
|
|
550
|
-
)
|
|
551
|
-
);
|
|
552
|
-
}
|
|
553
|
-
};
|
|
554
|
-
// 计算标准差
|
|
555
|
-
const calculateStandardDeviation = (data) => {
|
|
556
|
-
const numbers = data.map((i) => i[4]);
|
|
557
|
-
const n = numbers.length;
|
|
558
|
-
let sum = 0;
|
|
559
|
-
let squaredSum = 0;
|
|
560
|
-
// 计算平均值(均值)
|
|
561
|
-
for (const num of numbers) {
|
|
562
|
-
sum += num;
|
|
563
|
-
}
|
|
564
|
-
const mean = sum / n;
|
|
565
|
-
// 计算平方和
|
|
566
|
-
for (const num of numbers) {
|
|
567
|
-
squaredSum += Math.pow(num - mean, 2);
|
|
568
|
-
}
|
|
569
|
-
// 计算并返回标准差
|
|
570
|
-
return Math.sqrt(squaredSum / n);
|
|
571
|
-
};
|