添加时间轴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 timeList.value = newVal
}, },
{ deep: true } { deep: true }
)
// isAutoPlay
watch(
() => props.isAutoPlay,
(newVal) => {
isPlaying.value = newVal
if (newVal) {
play()
} else {
pause()
}
}
) )
// active-needle timeList // active-needle timeList

View File

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