|
|
@@ -451,14 +451,15 @@ const getNodeSide = (node_data, parent_data) => {
|
|
|
return parent_position_x > node_position_x ? 'left' : 'right';
|
|
|
};
|
|
|
|
|
|
+let mindmap = null;
|
|
|
// 初始化图表
|
|
|
const initGraph = (data) => {
|
|
|
- if (graph) {
|
|
|
- graph.destroy(); // 如果存在现有图表,则销毁
|
|
|
+ if (mindmap) {
|
|
|
+ mindmap.destroy(); // 如果存在现有图表,则销毁
|
|
|
}
|
|
|
|
|
|
const root_id = data.id;
|
|
|
- const graph = new Graph({
|
|
|
+ mindmap = new Graph({
|
|
|
container: container.value,
|
|
|
width: container.value?.clientWidth || 1000, // 画布宽度,默认值800
|
|
|
height: container.value?.clientHeight || 800, // 画布高度,默认值600
|
|
|
@@ -511,11 +512,11 @@ const initGraph = (data) => {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- graph.once(GraphEvent.AFTER_RENDER, () => {
|
|
|
- graph.fitView();
|
|
|
+ mindmap.once(GraphEvent.AFTER_RENDER, () => {
|
|
|
+ mindmap.fitView();
|
|
|
});
|
|
|
|
|
|
- graph.render();
|
|
|
+ mindmap.render();
|
|
|
};
|
|
|
</script>
|
|
|
|