Skip to content

Vue 关联关系图谱组件,可以展示如组织机构图谱、股权架构图谱、集团关系图谱等知识图谱,可提供多种图谱布局,包括树状布局、中心布局、力学布局自动布局等。Vue component for relationship graph , which can display knowledge graphs, such as organization graph, equity structure graph, group relationship graph,

License

Notifications You must be signed in to change notification settings

1335951413/relation-graph

 
 

Repository files navigation


relation-graph 支持Vue2、Vue3、React、PC & 移动端 的关系图谱展示组件,支持通过【插槽】让使用者用【html+css编写的vue/react组件】来完全自定义图形元素,使用css样式/动画来完全自定义样式效果。让你快速构建可交互的复杂图形应用。

这个项目不仅使用起来简单方便,代码也使用典型的Vue/React编程方式,代码简单易懂。 如果需要实现一些自定义的高级功能,你可以直接使用源码作为一个component放到你的项目中去用,轻松、任意的修改。


relation-graph is a relationship graph display component that supports Vue2, Vue3, React. Allowing you to fully customize the graphical elements using HTML/CSS and Vue or React components through slots.

This project is not only easy to use, but the code also follows the typical Vue/React programming style, making it simple and understandable. If you need to implement some custom advanced features, you can directly use the source code as a component in your project, allowing for easy and flexible modifications.


Docs & Examples 文档 & 示例:

https://relation-graph.com (国内用户,无需科学上网)

https://relation-graph.github.io(For regions outside of China)

上面的网站中包含使用文档、在线demo,以及可视化的配置工具。

The website above includes documentation, online demos, and a visual configuration tool for software developers.


Example Projects 完整的示例代码:

#(以下为Vue2示例代码,如果你使用的是Vue3或者React)

Vue3完整小示例:https://github.com/seeksdream/relation-graph-vue3-demo
React完整小示例:https://github.com/seeksdream/relation-graph-react-demo
vue2完整小示例:https://github.com/seeksdream/relation-graph-vue2-demo

Getting Started 快速使用:

npm install --save relation-graph
# 注意:relation-graph支持Vue2、Vue3、React, 引入的包名称都是"relation-graph"
# 
# 但在使用时,根据你的环境,需要引入不同的名称
# Vue2: import RelationGraph from 'relation-graph'
# Vue3: import RelationGraph from 'relation-graph/vue3'
# React: import RelationGraph from 'relation-graph/react'
<template>
  <div>
    <div style="height:calc(100vh - 50px);">
      <RelationGraph
        ref="graphRef"
        :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 图谱"中的参数进行设置:https://relation-graph.com/#/docs/graph
      }
    }
  },
  mounted() {
    this.showGraph()
  },
  methods: {
    showGraph() {
      var graphData = {
        rootId: 'a',
        nodes: [
          // node配置选项:https://relation-graph.com/#/docs/node
          // node支持通过插槽slot完全自定义,示例:https://relation-graph.com/#/demo/adv-slot
          { 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: [
          // link配置选项:https://relation-graph.com/#/docs/link
          { from: 'a', to: 'b', text: '关系1', color: '#43a2f1' },
          { from: 'a', to: 'c', text: '关系2' },
          { from: 'a', to: 'e', text: '关系3' },
          { from: 'b', to: 'e', color: '#67C23A' }
        ]
      }
      this.$refs.graphRef.setJsonData(graphData, (seeksRGGraph) => {
        // Called when the relation-graph is completed 
      })
    },
    onNodeClick(nodeObject, $event) {
      console.log('onNodeClick:', nodeObject)
    },
    onLineClick(linkObject, $event) {
      console.log('onLineClick:', linkObject)
    }
  }
}
</script>

上面代码的效果:

简单示例效果图

更多示例图:

简单示例效果图

##基本

线条样式

节点高级用法-插槽

线条高级用法

线条高级用法-插槽

##布局

树状布局(tree)

tree-层级距离&节点距离

中心布局(center)

center-层级距离设置

力学布局(force)

手工设定坐标(fixed)

##使用场景

双向树-数据与线条方向

集团图谱

组织架构图谱

企业图谱

网络拓扑

人物关系网络

##高级 & 交互

自定义插槽slot/右键菜单

其他插槽slot

动态追加数据

节点展开/收缩的用法

默认是收缩起来的图谱

节点筛选 & 关系筛选

效果、控制

节点/连线点击效果2

图谱大小调整相关

##更多示例: 在图谱中分区域展示

动态加载数据与重新布局

指定缩放比例

展开/收缩 时动画效果

展开/收缩 时动画效果2

展开/关闭所有

禁用拖动、缩放画布;禁用拖动、选中节点

自定义工具栏

多个关系网

多个关系网 2

界面拖拽添加节点、关系

右键菜单创建节点、关系

布局切换事件

展开到指定层级

全屏后依然可用的右键菜单

最短路径搜索

自定义连线文字位置

自定义箭头

自定义箭头2

我的关系图

线条动画1

线条动画2

线条动画3

线条动画4

线条动画5

完整的、可运行的示例项目:

vue2完整小示例:https://github.com/seeksdream/relation-graph-vue2-demo

vue3完整小示例:https://github.com/seeksdream/relation-graph-vue3-demo

React完整小示例:https://github.com/seeksdream/relation-graph-react-demo

更多效果及使用方法:

https://relation-graph.com (国内用户,无需科学上网)

https://relation-graph.github.io(For regions outside of China)

有问题可以加QQ:3235808353

About

Vue 关联关系图谱组件,可以展示如组织机构图谱、股权架构图谱、集团关系图谱等知识图谱,可提供多种图谱布局,包括树状布局、中心布局、力学布局自动布局等。Vue component for relationship graph , which can display knowledge graphs, such as organization graph, equity structure graph, group relationship graph,

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • JavaScript 52.0%
  • TypeScript 31.9%
  • Vue 14.8%
  • Other 1.3%