添加时间轴isPlay监听
This commit is contained in:
parent
3c6a07f45c
commit
9b96746957
|
|
@ -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 最后一个时间点
|
||||||
|
|
|
||||||
|
|
@ -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">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user