血缘图
用于表示表与表之间,表和其他关联实体之间关系的图

English | 简体中文
✨ 特性
- 开箱即用的关系图表
- 支持自定义操作、自定义节点事件
- 优雅、自然的交互设计
使用
$ npm install react-lineage-dag@2.x
import LineageDag from 'react-lineage-dag';
import 'react-lineage-dag/dist/index.css';
const data = {
  tables: [
    {
      id: '1',
      name: 'table-1',
      fields: [
        {
          name: 'id',
          title: 'id'
        },
        {
          name: 'age',
          title: 'age'
        }
      ]
    },
    {
      id: '2',
      name: 'table-2',
      fields: [
        {
          name: 'id',
          title: 'id'
        },
        {
          name: 'age',
          title: 'age'
        }
      ]      
    },
    {
      id: '3',
      name: 'table-3',
      fields: [
        {
          name: 'id',
          title: 'id'
        },
        {
          name: 'age',
          title: 'age'
        }
      ]      
    }    
  ],
  relations: [
    {
      srcTableId: '1',
      tgtTableId: '2',
      srcTableColName: 'id',
      tgtTableColName: 'age'
    },
    {
      srcTableId: '1',
      tgtTableId: '3',
      srcTableColName: 'id',
      tgtTableColName: 'age'
    }
  ]
}
const App = () => {
  return (
    <LineageDag {...data} />
  )
}
Props
| width | number | 100% | 画布宽度 | 
| height | number | 100% | 画布高度 | 
| tables | ITable[] | [] | 节点数据,具体描述位于表格下方 | 
| relations | IRelation[] | [] | 线段数据,具体描述位于表格下方 | 
| column | column[] | [] | 列的属性配置(和antd table的column概念相似),具体描述位于表格下方 | 
| centerId | string | undefined | 中心点,当中心点发生变化时,画布会聚焦此中心点 | 
| operator | operator[] | [] | 每个节点上的操作按钮渲染配置,具体描述位于表格下方 | 
| className | string | undefined | 画布类名 | 
| actionMenu | action[] | [] | 右上角操作按钮(放大、缩小、居中),具体描述位于表格下方 | 
| config | config | {} | 画布配置,具体描述位于表格下方 | 
| onLoaded | Function | noop | butterfly加载完毕时 | 
  interface ITable {
    id: string;                 
    name: string;               
    isCollapse: boolean;        
    fields: []                  
  }
  interface IRelation {
    id?: string;                 
    srcTableId: string;          
    tgtTableId: string;          
    srcTableColName: string;     
    tgtTableColName: string;     
  }
  interface operator {
    id: string;                  
    name: string;                
    icon: JSX.Element            
    onClick: (node: any): void   
  }
  interface column {
    key: string,                                              
    width?: number,                                           
    primaryKey: boolean,                                      
    render?(text: any, record: any, index: number): void      
  }
  interface config {
    delayDraw: number; 
    titleRender?: (title: string, node:any) => void; 
    showActionIcon?: boolean,                        
    enableHoverChain: boolean,                       
    enableHoverAnimate: boolean,                     
    minimap?: {                                      
      enable: boolean,
      config: {
        nodeColor: any
      }
    }
  }
Dev
# clone 本项目后
$ npm install
$ cd example
$ npm install
$ npm start