添加时间轴isPlay监听

This commit is contained in:
qumeng039@126.com 2025-08-07 20:13:33 +08:00
parent 3c6a07f45c
commit 9b96746957
2 changed files with 20 additions and 16 deletions

View File

@ -122,8 +122,19 @@ watch(
timeList.value = newVal
},
{ deep: true }
)
// isAutoPlay
watch(
() => props.isAutoPlay,
(newVal) => {
isPlaying.value = newVal
if (newVal) {
play()
} else {
pause()
}
}
)
// active-needle timeList

View File

@ -6,7 +6,7 @@
<TimeAxis
v-if="timeList.length"
:time-list="timeList"
:is-auto-play="true"
:is-auto-play="isPlay"
:start-time="new Date(timeList[0])"
:end-time="new Date(timeList[timeList.length - 1])"
@click:pointerDown="handlePointerDown"
@ -30,6 +30,7 @@ const props = defineProps({
})
const emit = defineEmits(["click:pointerDownAndSlide"])
const { timeList, graph } = storeToRefs(props.store)
let isPlay = ref(false)
let graphVis = null
let forceSimulator = null
let currentSelectNode = ref(null)
@ -44,7 +45,6 @@ const defaultConfig = {
},
shape: "circle",
size: 30,
color: (node) => colorMap[node.cluster],
borderColor: "200,50,50",
borderWidth: 0,
selected: {
@ -127,15 +127,15 @@ const registEvents = () => {
}
})
}
const runForceLayout = () => {
const layoutConfig = { strength: -500, ajustCluster: true }
const runForceLayout = (layoutConfig, layoutType, isAsync) => {
//
graphVis.excuteWorkerLayout(
graphVis.getGraphData(),
"simulation",
layoutType,
layoutConfig,
false,
isAsync,
function () {
isPlay.value = true
graphVis.zoomFit() //
}
)
@ -191,8 +191,8 @@ const createGraph = () => {
const initChart = () => {
createGraph()
graphVis.addGraph({ ...toRaw(graph.value) })
runForceLayout()
clusterAnalyze()
runForceLayout({ strength: -500, ajustCluster: true }, "simulation", true)
}
//
@ -205,8 +205,8 @@ const updateChart = (newGraphData) => {
graphVis.addGraph({ ...toRaw(newGraphData) })
graphVis.zoomFit()
//
runForceLayout()
clusterAnalyze()
runForceLayout({ strength: -500, ajustCluster: true }, "simulation", true)
}
let lastLength = 0 //
@ -220,13 +220,6 @@ watch(
},
{ deep: true }
)
onUnmounted(() => {
if (graphVis) {
graphVis.destroy() // GraphVis
graphVis = null
}
})
</script>
<style scoped lang="less">