st-comp 0.0.246 → 0.0.247
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/es/KlineBasic.cjs +1 -1
- package/es/KlineBasic.js +500 -492
- package/es/VarietyTextCopy.cjs +3 -3
- package/es/VarietyTextCopy.js +4 -4
- package/es/style.css +1 -1
- package/lib/bundle.js +1 -1
- package/lib/bundle.umd.cjs +151 -151
- package/lib/{index-2a325d42.js → index-750ede1b.js} +11544 -11536
- package/lib/{python-eb65d93b.js → python-e34a2958.js} +1 -1
- package/lib/style.css +1 -1
- package/package.json +1 -1
- package/packages/KlineBasic/components/KlineSub/index.vue +35 -15
- package/packages/KlineBasic/components/KlineTips/index.vue +2 -2
- package/packages/KlineBasic/index.vue +39 -41
- package/src/pages/KlineBasic/index.vue +7 -7
package/package.json
CHANGED
|
@@ -37,22 +37,23 @@ import { formatIndicatorNumber } from "../../utils"
|
|
|
37
37
|
import { stMath } from "st-func";
|
|
38
38
|
const { round } = stMath;
|
|
39
39
|
|
|
40
|
-
let subChart;
|
|
41
|
-
let resizeRo
|
|
40
|
+
let subChart = null;
|
|
41
|
+
let resizeRo = null;
|
|
42
|
+
const isAlive = ref(true); // 组件活跃状态
|
|
42
43
|
|
|
43
44
|
const emit = defineEmits(["update:modelValue"]);
|
|
44
45
|
const props = defineProps({
|
|
45
46
|
cycle: {
|
|
46
47
|
type: [String, Number],
|
|
47
48
|
default: () => null,
|
|
48
|
-
},
|
|
49
|
+
},
|
|
49
50
|
data: { type: Object, require: true },
|
|
50
51
|
activeIndex: { type: [Number, String], require: true },
|
|
51
|
-
modelValue: { type: String, required: true },
|
|
52
|
-
subIndicatorList: { type: Array, required: true },
|
|
52
|
+
modelValue: { type: String, required: true },
|
|
53
|
+
subIndicatorList: { type: Array, required: true },
|
|
53
54
|
});
|
|
54
55
|
|
|
55
|
-
const subChartRef = ref();
|
|
56
|
+
const subChartRef = ref();
|
|
56
57
|
const subIndicator = computed({
|
|
57
58
|
get() {
|
|
58
59
|
return props.modelValue;
|
|
@@ -63,27 +64,41 @@ const subIndicator = computed({
|
|
|
63
64
|
});
|
|
64
65
|
|
|
65
66
|
const subIndicatorTips = computed(() => {
|
|
67
|
+
if (!isAlive.value) return [];
|
|
66
68
|
const { data, activeIndex } = props;
|
|
67
69
|
return data?.subIndicator?.map((item) => ({ label: item.key, color: item.color, value: formatIndicatorNumber(item.data[activeIndex]) })) || [];
|
|
68
70
|
});
|
|
71
|
+
|
|
69
72
|
onMounted(() => {
|
|
73
|
+
isAlive.value = true;
|
|
74
|
+
if (!subChartRef.value) return;
|
|
75
|
+
|
|
70
76
|
subChart = echarts.init(subChartRef.value);
|
|
71
|
-
|
|
77
|
+
|
|
72
78
|
let isFirst = true;
|
|
73
79
|
resizeRo = new ResizeObserver(() => {
|
|
74
80
|
if (isFirst) {
|
|
75
|
-
isFirst =
|
|
81
|
+
isFirst = false;
|
|
76
82
|
return;
|
|
77
83
|
}
|
|
78
|
-
subChart.
|
|
84
|
+
if (isAlive.value && subChart && !subChart.isDisposed()) {
|
|
85
|
+
subChart.resize();
|
|
86
|
+
}
|
|
79
87
|
});
|
|
80
88
|
resizeRo.observe(subChartRef.value);
|
|
81
89
|
});
|
|
82
90
|
|
|
83
91
|
onUnmounted(() => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
92
|
+
isAlive.value = false;
|
|
93
|
+
|
|
94
|
+
if (subChart && !subChart.isDisposed()) {
|
|
95
|
+
subChart.dispose();
|
|
96
|
+
subChart = null;
|
|
97
|
+
}
|
|
98
|
+
if (resizeRo) {
|
|
99
|
+
resizeRo.disconnect();
|
|
100
|
+
resizeRo = null;
|
|
101
|
+
}
|
|
87
102
|
});
|
|
88
103
|
|
|
89
104
|
// 获取副图颜色
|
|
@@ -113,10 +128,15 @@ const getSubBarStyle = (data, index) => {
|
|
|
113
128
|
|
|
114
129
|
defineExpose({
|
|
115
130
|
connect: (chart) => {
|
|
131
|
+
if (!isAlive.value || !subChart || subChart.isDisposed()) return;
|
|
116
132
|
echarts.connect([chart, subChart]);
|
|
117
|
-
},
|
|
133
|
+
},
|
|
118
134
|
draw: (drawConfig, config) => {
|
|
135
|
+
if (!isAlive.value || !subChart || subChart.isDisposed()) return;
|
|
136
|
+
|
|
119
137
|
nextTick(() => {
|
|
138
|
+
if (!isAlive.value || !subChart || subChart.isDisposed()) return;
|
|
139
|
+
|
|
120
140
|
const { startValue, endValue, maxValueSpan } = drawConfig;
|
|
121
141
|
const { leftYAxisRange, rightYAxisRange } = props.data.subIndicator[0];
|
|
122
142
|
const series = props.data.subIndicator.map((item) => {
|
|
@@ -271,7 +291,7 @@ defineExpose({
|
|
|
271
291
|
true
|
|
272
292
|
);
|
|
273
293
|
});
|
|
274
|
-
},
|
|
294
|
+
},
|
|
275
295
|
});
|
|
276
296
|
</script>
|
|
277
297
|
|
|
@@ -309,4 +329,4 @@ defineExpose({
|
|
|
309
329
|
height: calc(100% - 26px);
|
|
310
330
|
}
|
|
311
331
|
}
|
|
312
|
-
</style>
|
|
332
|
+
</style>
|
|
@@ -32,13 +32,13 @@ const close = ref(null);
|
|
|
32
32
|
|
|
33
33
|
watch(() => props.activeIndex, () => {
|
|
34
34
|
if (close.value === null) {
|
|
35
|
-
close.value = props.data.data[props.activeIndex][1]
|
|
35
|
+
close.value = props.data.data[props.activeIndex]?.[1] ?? 0
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
watch(() => props.data, () => {
|
|
40
40
|
if (close.value === null) {
|
|
41
|
-
close.value = props.data.data[props.activeIndex][1]
|
|
41
|
+
close.value = props.data.data[props.activeIndex]?.[1] ?? 0
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
44
|
|
|
@@ -3,7 +3,7 @@ import dayjs from "dayjs";
|
|
|
3
3
|
import * as echarts from "echarts";
|
|
4
4
|
import { onMounted, onUnmounted, ref, watch, computed, nextTick } from "vue";
|
|
5
5
|
import { initRequestByEnv, getKlineBasic, getKline, getWarningLine, addWarningLine, updateWarningLine, deleteWarningLine } from "./api";
|
|
6
|
-
import { addResizeListener } from "st-func";
|
|
6
|
+
import { addResizeListener, debounce } from "st-func";
|
|
7
7
|
import { getMainOptions, getWarningLineOptions } from "./utils";
|
|
8
8
|
import KlineTips from "./components/KlineTips/index.vue";
|
|
9
9
|
import KlineSub from "./components/KlineSub/index.vue";
|
|
@@ -17,9 +17,6 @@ let renderFrameId = null; // 渲染帧ID
|
|
|
17
17
|
let drawLineFrameId = null; // 绘线帧ID
|
|
18
18
|
let brushFrameId = null; // 区域框选帧ID
|
|
19
19
|
|
|
20
|
-
let highlightTimer; // 高亮事件定时器
|
|
21
|
-
let mainDataZoomTimer; // datazoom事件定时器
|
|
22
|
-
|
|
23
20
|
let isLoadHistory = false; // 是否正在加载历史数据
|
|
24
21
|
let isloadAllHistory = false; // 是否加载完全部历史数据
|
|
25
22
|
|
|
@@ -103,10 +100,10 @@ const config = computed(() => {
|
|
|
103
100
|
addCounts: 2000,
|
|
104
101
|
maxShowCounts: 5000,
|
|
105
102
|
loadCheckCounts: 500,
|
|
106
|
-
showSubChart: true,
|
|
107
103
|
gridTop: 48,
|
|
108
104
|
gridLeft: 80,
|
|
109
105
|
gridRight: 50,
|
|
106
|
+
showSubChart: true,
|
|
110
107
|
showWarningLine: true,
|
|
111
108
|
getFactorData: true,
|
|
112
109
|
...props.config,
|
|
@@ -359,13 +356,13 @@ const getMainData = async () => {
|
|
|
359
356
|
params.endTime = endTime;
|
|
360
357
|
} else if (startTime) {
|
|
361
358
|
params.startTime = startTime;
|
|
362
|
-
params.limit =
|
|
359
|
+
params.limit = addCounts;
|
|
363
360
|
} else if (endTime) {
|
|
364
361
|
params.endTime = endTime;
|
|
365
|
-
params.limit =
|
|
362
|
+
params.limit = addCounts;
|
|
366
363
|
} else {
|
|
367
364
|
params.endTime = dayjs().add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
|
|
368
|
-
params.limit =
|
|
365
|
+
params.limit = addCounts;
|
|
369
366
|
}
|
|
370
367
|
|
|
371
368
|
const res = await getKlineBasic(params);
|
|
@@ -496,9 +493,9 @@ const handleKeyDownEvent = ({ code, ctrlKey }) => {
|
|
|
496
493
|
};
|
|
497
494
|
// 图表事件
|
|
498
495
|
const addEventListener = () => {
|
|
499
|
-
mainChartIns?.on(
|
|
500
|
-
|
|
501
|
-
|
|
496
|
+
mainChartIns?.on(
|
|
497
|
+
"datazoom",
|
|
498
|
+
debounce((params) => {
|
|
502
499
|
const { loadCheckCounts } = config.value;
|
|
503
500
|
if (mainChartIns?.getOption()?.dataZoom?.[0]) {
|
|
504
501
|
const { startValue } = mainChartIns?.getOption()?.dataZoom?.[0];
|
|
@@ -508,33 +505,33 @@ const addEventListener = () => {
|
|
|
508
505
|
}
|
|
509
506
|
drawLine(); // 使用RAF优化的绘线
|
|
510
507
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
highlightTimer = setTimeout(() => {
|
|
522
|
-
activeIndex.value = index;
|
|
523
|
-
clearTimeout(highlightTimer);
|
|
524
|
-
}, 20);
|
|
525
|
-
});
|
|
526
|
-
|
|
527
|
-
mainChartIns?.on("globalout", () => {
|
|
528
|
-
const timer = setTimeout(() => {
|
|
529
|
-
clearTimeout(timer);
|
|
530
|
-
const index = mainChartIns?.getOption()?.dataZoom?.[0]?.endValue;
|
|
508
|
+
}, 100),
|
|
509
|
+
);
|
|
510
|
+
|
|
511
|
+
mainChartIns?.on(
|
|
512
|
+
"highlight",
|
|
513
|
+
debounce((data) => {
|
|
514
|
+
let index = data.dataIndex || -1;
|
|
515
|
+
if (data.batch) {
|
|
516
|
+
index = typeof data?.batch[0]?.dataIndex === "number" ? data?.batch[0]?.dataIndex : -1;
|
|
517
|
+
}
|
|
531
518
|
activeIndex.value = index;
|
|
532
|
-
},
|
|
533
|
-
|
|
519
|
+
}, 20),
|
|
520
|
+
);
|
|
521
|
+
|
|
522
|
+
mainChartIns?.on(
|
|
523
|
+
"globalout",
|
|
524
|
+
debounce(() => {
|
|
525
|
+
if (mainChartIns) {
|
|
526
|
+
const index = mainChartIns?.getOption()?.dataZoom?.[0]?.endValue;
|
|
527
|
+
activeIndex.value = index;
|
|
528
|
+
}
|
|
529
|
+
}, 30),
|
|
530
|
+
);
|
|
534
531
|
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
532
|
+
mainChartIns?.on(
|
|
533
|
+
"contextmenu",
|
|
534
|
+
debounce((params) => {
|
|
538
535
|
if (params.componentType === "graphic") {
|
|
539
536
|
warningItem.value = params.info;
|
|
540
537
|
menuData.value = [
|
|
@@ -542,10 +539,8 @@ const addEventListener = () => {
|
|
|
542
539
|
{ label: "修改画线", key: "changeWarningLine" },
|
|
543
540
|
];
|
|
544
541
|
}
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
});
|
|
548
|
-
});
|
|
542
|
+
}, 0),
|
|
543
|
+
);
|
|
549
544
|
};
|
|
550
545
|
|
|
551
546
|
// 预警线相关辅助函数
|
|
@@ -686,7 +681,10 @@ defineExpose({
|
|
|
686
681
|
@mousemove="isHover = true"
|
|
687
682
|
@mouseout="isHover = false"
|
|
688
683
|
>
|
|
689
|
-
<div
|
|
684
|
+
<div
|
|
685
|
+
v-if="chartData.time?.length"
|
|
686
|
+
class="klineBasic-tips"
|
|
687
|
+
>
|
|
690
688
|
<KlineTips
|
|
691
689
|
:variety="variety"
|
|
692
690
|
:data="chartData"
|
|
@@ -178,14 +178,14 @@ import { getCycleList, host } from './api';
|
|
|
178
178
|
const indicatorStore = useIndicatorStore();
|
|
179
179
|
|
|
180
180
|
// 显示模式
|
|
181
|
-
const displayMode = ref('
|
|
181
|
+
const displayMode = ref('multi'); // single: 单周期, multi: 多周期
|
|
182
182
|
const show = ref(false);
|
|
183
183
|
|
|
184
184
|
// 周期映射
|
|
185
185
|
const cycleMap = {
|
|
186
|
-
'15m': { value: '
|
|
187
|
-
'30m': { value: '
|
|
188
|
-
'60m': { value: '
|
|
186
|
+
'15m': { value: '3', label: '15分钟' },
|
|
187
|
+
'30m': { value: '4', label: '30分钟' },
|
|
188
|
+
'60m': { value: '5', label: '60分钟' },
|
|
189
189
|
'1d': { value: '6', label: '日线' },
|
|
190
190
|
'1w': { value: '7', label: '周线' },
|
|
191
191
|
'1mon': { value: '8', label: '月线' }
|
|
@@ -193,9 +193,9 @@ const cycleMap = {
|
|
|
193
193
|
|
|
194
194
|
// 多周期展示的周期列表
|
|
195
195
|
const multiCycleList = [
|
|
196
|
-
{ cycle: '
|
|
197
|
-
{ cycle: '
|
|
198
|
-
{ cycle: '
|
|
196
|
+
{ cycle: '3', cycleLabel: '15分钟' }, // 15m
|
|
197
|
+
{ cycle: '4', cycleLabel: '30分钟' }, // 30m
|
|
198
|
+
{ cycle: '5', cycleLabel: '60分钟' }, // 60m
|
|
199
199
|
{ cycle: '6', cycleLabel: '日线' }, // 1d
|
|
200
200
|
{ cycle: '7', cycleLabel: '周线' }, // 1w
|
|
201
201
|
{ cycle: '8', cycleLabel: '月线' } // 1mon
|