提交 bb46c098 编写于 作者: W weixin_46329670

Thu Apr 18 08:55:00 CST 2024 inscode

上级 89dec13c
...@@ -16,32 +16,7 @@ export default defineComponent({ ...@@ -16,32 +16,7 @@ export default defineComponent({
name: 'Demo', name: 'Demo',
components: {RelationGraph}, components: {RelationGraph},
methods: { methods: {
test() {
const graphRef = this.$refs.graphRef
const __graph_json_data: RGJsonData = {
rootId: 'a',
nodes: [
{ id: 'a', text: 'A', borderColor: 'yellow' },
{ id: 'b', text: 'B', color: '#43a2f1', fontColor: 'yellow' },
{ id: 'c', text: 'C', nodeShape: 1, width: 80, height: 60 },
{ id: 'e', text: 'E', nodeShape: 0, width: 150, height: 150 }
],
lines: [
{ from: 'a', to: 'b', text: 'Line Text', color: '#43a2f1' },
{ from: 'a', to: 'c', text: 'Line Text' },
{ from: 'a', to: 'e', text: 'Line Text' },
{ from: 'b', to: 'e', text: '', color: '#67C23A' }
]
};
console.log(graphRef.value);
const graphInstance = graphRef.value!.getInstance();
graphInstance.setJsonData(__graph_json_data).then(() => {
// 这些写上当图谱初始化完成后需要执行的代码
// graphInstance.moveToCenter();
// graphInstance.zoomToFit();
});
}
}, },
setup() { setup() {
const graphRef = ref<RelationGraphComponent | null>(null); const graphRef = ref<RelationGraphComponent | null>(null);
...@@ -93,12 +68,41 @@ export default defineComponent({ ...@@ -93,12 +68,41 @@ export default defineComponent({
console.log('onLineClick:', lineObject); console.log('onLineClick:', lineObject);
}; };
const test = () => {
const __graph_json_data: RGJsonData = {
rootId: 'a',
nodes: [
{ id: 'a', text: 'A', borderColor: 'yellow' },
{ id: 'b', text: 'B', color: '#43a2f1', fontColor: 'yellow' },
{ id: 'c', text: 'C', nodeShape: 1, width: 80, height: 60 },
{ id: 'e', text: 'E', nodeShape: 0, width: 150, height: 150 },
{ id: 'e', text: 'E', nodeShape: 0, width: 150, height: 150 },
],
lines: [
{ from: 'a', to: 'b', text: 'Line Text', color: '#43a2f1' },
{ from: 'a', to: 'c', text: 'Line Text' },
{ from: 'a', to: 'e', text: 'Line Text' },
{ from: 'b', to: 'e', text: '', color: '#67C23A' }
]
};
console.log(graphRef.value);
const graphInstance = graphRef.value!.getInstance();
graphInstance.setJsonData(__graph_json_data).then(() => {
// 这些写上当图谱初始化完成后需要执行的代码
// graphInstance.moveToCenter();
// graphInstance.zoomToFit();
});
}
return { return {
graphRef, graphRef,
graphOptions, graphOptions,
showGraph, showGraph,
onNodeClick, onNodeClick,
onLineClick onLineClick,
test
}; };
}, },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册