groupGraph组件修改
This commit is contained in:
parent
55330a315d
commit
c0f0483df7
|
|
@ -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) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user