2.1.0-beta.23 • Published 8 months ago

react-lineage-dag v2.1.0-beta.23

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
8 months ago

Blood Map

A diagram used to represent relationships between tables and between table and other related entities

demo preview

English | 简体中文

✨ Features

  • relational diagram out of the box
  • support custom operations and custom node events
  • elegant, natural interaction design

Usage

$ npm install react-lineage-dag@2.x
import LineageDag from 'react-lineage-dag';
// need to import styles
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

PropertyTypeDefaultDescription
widthnumber100%Canvas width
heightnumber100%Canvas height
tablesITable[][]Nodes data, the detailed description is below the table
relationsIRelation[][]Relations data, the detailed description is below the table
columncolumn[][]Property configuration of the column (similar to the concept of column in antd table), the detailed description is below the table
centerIdstringundefinedCenter point, when the center point changes, the canvas will focus on the point
operatoroperator[][]Render configuration of operation buttons on each node, the detailed description is below the table
classNamestringundefinedClass name of canvas
actionMenuaction[][]Operation button in the upper right corner (zoom in, zoom out, center), the detailed description is below the table
configconfig{}Configuration of the canvas, the detailed description is below the table
onLoadedFunctionnoopTriggered when the butterfly is loaded
  interface ITable {
    id: string;                 // table ID
    name: string;               // table name
    isCollapse: boolean;        // whether to collapse all the columns
    fields: []                  // data stored in columns
  }

  interface IRelation {
    id?: string;                 // relation ID, not required, but recommended
    srcTableId: string;          // source table ID
    tgtTableId: string;          // target table ID
    srcTableColName: string;     // field name of source table
    tgtTableColName: string;     // field name of target table
  }

  interface operator {
    id: string;                  // unique identification of the button
    name: string;                // chinese name of the button
    icon: JSX.Element            // rendering of the operator
    onClick: (node: any): void   // click event
  }

  interface column {
    key: string,                                              // unique identification of the column
    width?: number,                                           // column width
    primaryKey: boolean,                                      // whether the value corresponding to the key of this column is a key-value pair, corresponding to the primary key concept of the column in antd
    render?(text: any, record: any, index: number): void      // rendering method of the column
  }

  interface config {
    delayDraw: number; // Delayed rendering, this component must ensure that the canvas container rendering (including animation execution) is completed before rendering, otherwise the coordinates will be offset, such as: antd's modal animation
    titleRender?: () => void;                         // title render of custom node
    showActionIcon?: boolean,                        // whether to display the operation icons: zoom in, zoom out, focus
    enableHoverChain: boolean,                       // whether to enable highlight the chain when hovering
    enableHoverAnimate: boolean,                     // whether to enable highlight the chain with animate when hovering
    minimap?: {                                      // whether to enable thumbnail
      enable: boolean,
      config: {
        nodeColor: any
      }
    }
  }

Dev

# after clone this project
$ npm install
$ cd example
$ npm install
$ npm start
2.1.0-beta.23

8 months ago

2.1.0-beta.22

8 months ago

2.1.0-beta.18

1 year ago

2.1.0-beta.17

1 year ago

2.1.0-beta.15

1 year ago

2.1.0-beta.14

1 year ago

2.1.0-beta.13

1 year ago

2.1.0-beta.12

1 year ago

2.1.0-beta.11

1 year ago

2.1.0-beta.10

1 year ago

2.0.36

1 year ago

2.1.0-beta.19

1 year ago

2.1.0-beta.21

1 year ago

2.1.0-beta.20

1 year ago

2.1.0-beta.1

1 year ago

2.1.0-beta.3

1 year ago

2.1.0-beta.2

1 year ago

2.1.0-beta.5

1 year ago

2.1.0-beta.4

1 year ago

2.1.0-beta.7

1 year ago

2.1.0-beta.6

1 year ago

2.1.0-beta.9

1 year ago

2.1.0-beta.8

1 year ago

2.0.35

2 years ago

2.0.28

2 years ago

2.0.29

2 years ago

2.0.33

2 years ago

2.0.34

2 years ago

2.0.31

2 years ago

2.0.32

2 years ago

2.0.30

2 years ago

2.0.19

2 years ago

2.0.17

2 years ago

2.0.18

2 years ago

2.0.26

2 years ago

2.0.27

2 years ago

2.0.24

2 years ago

2.0.25

2 years ago

2.0.23

2 years ago

2.0.20

2 years ago

2.0.21

2 years ago

2.0.15

2 years ago

2.0.16

2 years ago

2.0.13

2 years ago

2.0.11

2 years ago

2.0.12

2 years ago

2.0.9

2 years ago

2.0.10

2 years ago

2.0.8

2 years ago

2.0.2

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.7

2 years ago

2.0.6

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.0

3 years ago