groupGraph组件修改

This commit is contained in:
duanhao 2025-08-07 10:35:34 +08:00
parent 55330a315d
commit c0f0483df7

View File

@ -174,7 +174,21 @@ const runForceLayout = () => {
}) })
forceSimulator = curForceSimulator forceSimulator = curForceSimulator
} }
//
const updateChart = (newGraphData) => {
if (!graphVis) {
initChart();
return;
}
//
graphVis.clearAll();
//
graphVis.addGraph({ ...toRaw(newGraphData) });
//
runForceLayout();
}
const initChart = () => { const initChart = () => {
const getGroupCenters = (groupCount, width, height, radius = 200) => { const getGroupCenters = (groupCount, width, height, radius = 200) => {
// //
@ -229,10 +243,15 @@ const initChart = () => {
graphVis.addGraph({ ...toRaw(graph.value) }) graphVis.addGraph({ ...toRaw(graph.value) })
runForceLayout() runForceLayout()
} }
onMounted(() => { watch(
initChart() graph,
(newValue) => {
}) if (newValue && Object.keys(newValue).length > 0) {
updateChart(newValue);
}
},
{ deep: true, immediate: true }
);
onUnmounted(() => { onUnmounted(() => {
if (graphVis) { if (graphVis) {