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)布局等。
- 引入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