st-comp 0.0.165 → 0.0.166
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/KlinePlus.cjs +3 -3
- package/es/KlinePlus.js +418 -415
- package/es/style.css +1 -1
- package/lib/bundle.js +1 -1
- package/lib/bundle.umd.cjs +67 -67
- package/lib/{index-98f7afa7.js → index-80531492.js} +1303 -1300
- package/lib/{python-e64d75ae.js → python-20a1a5fc.js} +1 -1
- package/lib/style.css +1 -1
- package/package.json +1 -1
- package/packages/KlinePlus/components/SliderChart.vue +26 -9
- package/packages/KlinePlus/index.vue +2 -10
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import dayjs from "dayjs";
|
|
4
4
|
import * as echarts from "echarts";
|
|
5
5
|
import { debounce } from "st-func";
|
|
6
|
-
import { ref, onMounted, onUnmounted, nextTick, inject } from "vue";
|
|
6
|
+
import { ref, onMounted, onUnmounted, watch, nextTick, inject } from "vue";
|
|
7
7
|
|
|
8
8
|
const { request } = inject("stConfig"); // 组件库全局配置
|
|
9
9
|
|
|
@@ -12,6 +12,8 @@ const sliderChartRef = ref(null);
|
|
|
12
12
|
|
|
13
13
|
const emit = defineEmits(["change"]);
|
|
14
14
|
const props = defineProps({
|
|
15
|
+
// K线当屏时间范围
|
|
16
|
+
screenTimeRange: { type: Array, required: true },
|
|
15
17
|
// 品种代码
|
|
16
18
|
varietyCode: { type: String, required: true },
|
|
17
19
|
// 品种市场类型: 0-期货, 1-股票, 2-期权
|
|
@@ -28,8 +30,8 @@ const klineData = ref({
|
|
|
28
30
|
time: [],
|
|
29
31
|
});
|
|
30
32
|
|
|
31
|
-
//
|
|
32
|
-
const
|
|
33
|
+
// 获取日线数据
|
|
34
|
+
const getData = async () => {
|
|
33
35
|
const params = {
|
|
34
36
|
varietyCode: props.varietyCode,
|
|
35
37
|
cycle: "6",
|
|
@@ -63,7 +65,7 @@ const reload = async () => {
|
|
|
63
65
|
|
|
64
66
|
draw("init");
|
|
65
67
|
};
|
|
66
|
-
//
|
|
68
|
+
// 拖动拖拽轴事件
|
|
67
69
|
const handleDataZoomChange = debounce((params) => {
|
|
68
70
|
if (!params.dataZoomId) return;
|
|
69
71
|
const option = sliderChartIns.getOption();
|
|
@@ -78,6 +80,10 @@ const handleDataZoomChange = debounce((params) => {
|
|
|
78
80
|
// 未检测到, 便不执行后续逻辑
|
|
79
81
|
}
|
|
80
82
|
}, 200);
|
|
83
|
+
// 重置拖拽轴位置
|
|
84
|
+
const reset = debounce(({ startTime, endTime }) => {
|
|
85
|
+
draw("reset", { startTime, endTime });
|
|
86
|
+
}, 100);
|
|
81
87
|
|
|
82
88
|
// 绘制
|
|
83
89
|
const draw = (type, params) => {
|
|
@@ -130,6 +136,12 @@ const draw = (type, params) => {
|
|
|
130
136
|
],
|
|
131
137
|
};
|
|
132
138
|
sliderChartIns.setOption(option, true);
|
|
139
|
+
|
|
140
|
+
// 避免K线主体数据加载快于拖拽轴, 在这里检测一下, 如果K线已加载了那么就重定位一下
|
|
141
|
+
if (props.screenTimeRange.length) {
|
|
142
|
+
const [startTime, endTime] = props.screenTimeRange;
|
|
143
|
+
reset({ startTime, endTime });
|
|
144
|
+
}
|
|
133
145
|
break;
|
|
134
146
|
}
|
|
135
147
|
// 根据时间, 更新拖拽轴定位
|
|
@@ -170,19 +182,24 @@ onMounted(() => {
|
|
|
170
182
|
nextTick(() => {
|
|
171
183
|
sliderChartIns = echarts.init(sliderChartRef.value);
|
|
172
184
|
sliderChartIns.on("datazoom", handleDataZoomChange);
|
|
173
|
-
|
|
185
|
+
getData();
|
|
174
186
|
});
|
|
175
187
|
});
|
|
188
|
+
// 监控: [当屏首末时间] => 拖拽轴重定位
|
|
189
|
+
watch(
|
|
190
|
+
() => props.screenTimeRange,
|
|
191
|
+
(newValue) => {
|
|
192
|
+
const [startTime, endTime] = newValue;
|
|
193
|
+
reset({ startTime, endTime });
|
|
194
|
+
},
|
|
195
|
+
{ deep: true }
|
|
196
|
+
);
|
|
176
197
|
onUnmounted(() => {
|
|
177
198
|
sliderChartIns.off("datazoom");
|
|
178
199
|
sliderChartIns.dispose();
|
|
179
200
|
});
|
|
180
201
|
defineExpose({
|
|
181
|
-
reload,
|
|
182
|
-
// DOM缩放
|
|
183
202
|
resize: debounce(() => sliderChartIns.resize(), 100),
|
|
184
|
-
// 重置拖拽轴的定位
|
|
185
|
-
reset: debounce(({ startTime, endTime }) => draw("reset", { startTime, endTime }), 100),
|
|
186
203
|
});
|
|
187
204
|
</script>
|
|
188
205
|
|
|
@@ -576,7 +576,7 @@ const draw = (params = { startValue: 0, endValue: 0 }) => {
|
|
|
576
576
|
}
|
|
577
577
|
};
|
|
578
578
|
|
|
579
|
-
// 拖拽轴:
|
|
579
|
+
// 拖拽轴: 拖拽回调
|
|
580
580
|
const handleSliderChange = (params) => {
|
|
581
581
|
const { startTime, endTime } = params;
|
|
582
582
|
getMainData({ startTime, endTime });
|
|
@@ -678,15 +678,6 @@ watch(
|
|
|
678
678
|
},
|
|
679
679
|
{ deep: true }
|
|
680
680
|
);
|
|
681
|
-
// 监控: [当屏首末时间] => 拖拽轴重定位
|
|
682
|
-
watch(
|
|
683
|
-
() => screenTimeRange.value,
|
|
684
|
-
(newValue) => {
|
|
685
|
-
const [startTime, endTime] = newValue;
|
|
686
|
-
sliderChartRef.value?.reset({ startTime, endTime });
|
|
687
|
-
},
|
|
688
|
-
{ deep: true }
|
|
689
|
-
);
|
|
690
681
|
onUnmounted(() => {
|
|
691
682
|
// 解绑
|
|
692
683
|
mainChartIns.off("highlight");
|
|
@@ -766,6 +757,7 @@ defineExpose({
|
|
|
766
757
|
<div class="slider-chart">
|
|
767
758
|
<SliderChart
|
|
768
759
|
ref="sliderChartRef"
|
|
760
|
+
:screenTimeRange="screenTimeRange"
|
|
769
761
|
:varietyCode="varietyCode"
|
|
770
762
|
:varietyStock="varietyStock"
|
|
771
763
|
:rightType="rightType"
|