Relation Graph一個(gè)關(guān)系圖的使用

Relation Graph (http://www.relation-graph.com/

Vue 關(guān)聯(lián)關(guān)系圖譜組件,可以展示如組織機(jī)構(gòu)圖譜、股權(quán)架構(gòu)圖譜、集團(tuán)關(guān)系圖譜等知識(shí)圖譜,可提供多種圖譜布局,包括樹狀布局、中心布局、力學(xué)布局自動(dòng)布局等。

  1. 引入relation-graph
npm install --save relation-graph

2.示例代碼:
通過調(diào)整以下示例代碼中的options、nodes、links的配置實(shí)現(xiàn)不同的展示效果,還可以通過事件在圖譜中實(shí)現(xiàn)交互式功能,更多的示例

<template>
   <div>
     <div style="height:calc(100vh - 50px);">
        <RelationGraph ref="seeksRelationGraph" :options="graphOptions" :on-node-click="onNodeClick" :on-line-click="onLineClick" />
     </div>
   </div>
 </template>

 <script>
 import RelationGraph from 'relation-graph'
 export default {
   name: 'Demo',
   components: { RelationGraph },
   data() {
     return {
       graphOptions: {
         allowSwitchLineShape: true,
         allowSwitchJunctionPoint: true,
         defaultJunctionPoint: 'border'
         // 這里可以參考"Graph 圖譜"中的參數(shù)進(jìn)行設(shè)置
       }
     }
   },
   mounted() {
     this.showSeeksGraph()
   },
   methods: {
     showSeeksGraph(query) {
       var __graph_json_data = {
         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 }
         ],
         links: [
           { from: 'a', to: 'b', text: '關(guān)系1', color: '#43a2f1' },
           { from: 'a', to: 'c', text: '關(guān)系2' },
           { from: 'a', to: 'e', text: '關(guān)系3' },
           { from: 'b', to: 'e', color: '#67C23A' }
         ]
       }
       // 以上數(shù)據(jù)中的node和link可以參考"Node節(jié)點(diǎn)"和"Link關(guān)系"中的參數(shù)進(jìn)行配置 
       this.$refs.seeksRelationGraph.setJsonData(__graph_json_data, (seeksRGGraph) => {
         // Called when the relation-graph is completed 
       })
     },
     onNodeClick(nodeObject, $event) {
       console.log('onNodeClick:', nodeObject)
     },
     onLineClick(lineObject, $event) {
       console.log('onLineClick:', lineObject)
     }
   }
 }
 </script>

效果圖


image.png
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容