提交 ac1dff07 编写于 作者: W weixin_46329670

Wed Apr 17 14:10:00 CST 2024 inscode

上级 cb1e4fcb
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
}, },
"dependencies": { "dependencies": {
"guess": "^1.0.2", "guess": "^1.0.2",
"relation-graph": "^2.1.42",
"vue": "^3.2.37" "vue": "^3.2.37"
}, },
"devDependencies": { "devDependencies": {
......
...@@ -5,16 +5,13 @@ import TheWelcome from './components/TheWelcome.vue' ...@@ -5,16 +5,13 @@ import TheWelcome from './components/TheWelcome.vue'
<template> <template>
<header> <header>
<img alt="Vue logo" class="logo" src="./assets/logo.svg" width="125" height="125" />
<div class="wrapper"> <div class="wrapper">
<HelloWorld msg="You did it!" /> <HelloWorld msg="You did it!" />
</div> </div>
</header> </header>
<main>
<TheWelcome />
</main>
</template> </template>
<style scoped> <style scoped>
......
<script setup>
defineProps({
msg: {
type: String,
required: true
}
})
</script>
<template> <template>
<div class="greetings"> <div>
<h1 class="green">{{ msg }}</h1> <button @click="">测试</button>
<h3> <div style="height:calc(80vh);">
You’ve successfully created a project with <RelationGraph ref="graphRef" :options="graphOptions" @node-click="onNodeClick" @line-click="onLineClick" />
<a target="_blank" href="https://vitejs.dev/">Vite</a> + </div>
<a target="_blank" href="https://vuejs.org/">Vue 3</a>.
</h3>
</div> </div>
</template> </template>
<style scoped> <script lang="ts">
h1 { import { defineComponent, ref, onMounted } from 'vue';
font-weight: 500; import RelationGraph from 'relation-graph/vue3';
font-size: 2.6rem; import type { RGOptions, RGJsonData, RGNode, RGLine, RGLink, RGUserEvent, RelationGraphComponent } from 'relation-graph/vue3';
top: -10px;
} export default defineComponent({
name: 'Demo',
h3 { components: {RelationGraph},
font-size: 1.2rem; setup() {
} const graphRef = ref<RelationGraphComponent | null>(null);
const graphOptions: RGOptions = {
.greetings h1, debug: false,
.greetings h3 { allowSwitchLineShape: true,
text-align: center; allowSwitchJunctionPoint: true,
} allowShowDownloadButton: true,
defaultJunctionPoint: 'border'
@media (min-width: 1024px) { // 这里可以参考"Graph 图谱"中的参数进行设置
.greetings h1,
.greetings h3 { };
text-align: left;
onMounted(() => {
showGraph();
});
const showGraph = () => {
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();
});
};
const onNodeClick = (nodeObject: RGNode, $event: RGUserEvent) => {
console.log('onNodeClick:', nodeObject);
};
const onLineClick = (lineObject: RGLine, linkObject: RGLink, $event: RGUserEvent) => {
console.log('onLineClick:', lineObject);
};
return {
graphRef,
graphOptions,
showGraph,
onNodeClick,
onLineClick
};
} }
} });
</script>
<style lang="scss">
</style>
<style lang="scss" scoped>
</style> </style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册