1.2.3 • Published 8 months ago

react-monitor-dag v1.2.3

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

English| 简体中文(. /README. md)

✨ Feature

  • support the direction of left-to-right, top-to-bottom
  • support for custom status, custom status note in upper left corner
  • support for custom node styles and hover, focus status
  • support edge's label style
  • support the toolltips of node, endpoint, edge's label
  • support right-click menu of nodes and edges
  • support minimap and highlight status
  • support edge flow animation

📦 Install

npm install react-monitor-dag

API

MonitorDag properties

PropertyDescriptionTypeDefault
datadataany-
widthcomponent widthnumber | string-
heightcomponent heightnumber | string -
classNamecomponent classNamestring-
nodeMenuNode Right-click Menu ConfigurationArray< menu> | (node) => Array< menu> -
nodeMenuClassNameNode Right-click Menu classnamestring-
edgeMenuEdge Right-click Menu ConfigurationArray< menu
groupMenuGroup Right-click Menu ConfigurationArray< menu
(#menu-type)>
configAs configured aboveconfig Propany -
pollingsupport pollingpolling Propobject{ }
registerStatusRegister status, which adds class to the node based on its statusobjectkey:value, registered by user, corresponded to the status field of node
statusNoteStatus note in upper left cornerstatusNote Propobject{ }
onClickNodeSingle Click Node Event(node) => void-
onContextmenuNodeRight-Click Node Event(node) => void-
onDblClickNodeDouble Click Node Event(node) => void-
onClickEdgeSingle Click Edge Event(edge) => void-
onClickLabelSingle Click Label Event(label, edge) => void-
onContextmenuEdgeRight-Click Edge Event(edge) => void-
onContextmenuGroupRight-Click Group Event(data) => void
onChangePageSingle-Click Group Pagination Event(data) => void
onNodeStatusChangeThe canvas has a callback after the node state changes(data) => void

right-click menu configuration for'Node/Edge'

PropertyDescriptionTypeDefault
titlename of each columnstring-
keyunique flag for each column menustring-
renderCustomize the style of each column menu(key) => void-
onClickClick Callback for Each Column(key, data) => void-

config

the configuration of canvas

PropertyDescriptionTypeDefault
directionthe dag's directionstringleft-right | top-bottom
edgethe configuration of edgeedge Prop { }-
labelRenderrendering method of edge's label(label) => void-
labelTipsRenderrendering tooltips of edge label(data) => void-
nodeRenderrendering of nodes(data) => void-
nodeTipsRenderrendering tooltips of node(data) => void-
endpointTipsRenderrendering tooltips of endpoint(data) => void-
minimapwhether to show minimapminimap Prop { }-
delayDrawDelayed rendering. This component must ensure that the canvas container rendering (including animation execution) is completed before rendering, otherwise the coordinates will be offset, for example:Animation of Ant Design Modal number0
autoLayoutcustom layoutautoLayout Prop {}-
diffOptionsCollection of diff fields for node updatesArray< string>-
onLoadedcanvas loaded event(data: {nodes, edges, groups}) => {}-

edge

the configuration of edge

PropertyDescriptionTypeDefault
typethe type of edgestring-
configthe config of edge any-

group

the configuration of group

PropertyDescriptionTypeDefault
enableSearchwhether to enable the node group search nodebooleanfalse
enablePaginationwhether to turn on the page boolean true
pageSizenmber of per page number 20
rowCntthe number of nodes are displayed in each row of the node group number 5

minimap

the configuration of minimap

PropertyDescriptionTypeDefault
enablewhether to show minimapboolean-
configthe config of minimapminimap Config Prop { }-

autoLayout Config

the custom layout config

PropertyDescriptionTypeDefault
enablewhether to enable custom layoutboolean-
isAlwayswhether to rearrange the layout after adding nodesboolean-
configalgorithm configuration{ }-

minimap Config

the config of minimap

PropertyDescriptionTypeDefault
nodeColornode colorany-
activeNodeColornode active colorany-

polling

support polling

PropertyDescriptionTypeDefault
enablewhether to support pollingboolean-
intervalinterval of pollingnumber-
getDatathe method of get data(data) => void-

statusNote

Status note in upper left corner

PropertyDescriptionTypeDefault
enablewhether to show status in upper left cornerboolean-
notesthe configuration of status notenotes Prop { }-

notes

the configuration of status note

PropertyDescriptionTypeDefault
codestatus codestring-
classNamestatus className string-
textstatus textstring-
rendercustom rendering methodsfunction-

🔗API

import MonitorDag from 'react-monitor-dag';
import 'react-monitor-dag/dist/index.css';
<MonitorDag
  data={data}
  nodeMenu={menu}                   // Node Right-click Menu Configuration
  edgeMenu={menu}                   // Edge Right-click Menu Configuration
  groupMenu={menu}                   // Group Right-click Menu Configuration
  onClickNode={(node) => {}}        // Single Click Node Event
  onContextmenuNode={(node) => {}}  // Right Click Node Event
  onDblClickNode={(node) => {}}     // Double Click Node Event
  onClickEdge={(edge) => {}}        // Single Click Edge Event
  onContextmenuEdge={(edge) => {}}  // Right Click Edge Event
  onContextmenuGroup={(data) => {}}   // Right Click Group Event
  onChangePage={(data) => {}}        // Single Click Group Pagination Event
  onNodeStatusChange={(data) => {}}  // The canvas has a callback after the node state changes
  polling={{                        // support polling
    enable: true,
    interval: 5000,                 // interval of polling 
    getData: (data) => {            // the method of get data

    }
  }}
  registerStatus={{                 // Register status, which adds class to the node based on its status
    success: 'success-class',
    fail: 'fail-class',
    timeout: 'timeout-class',
    running: 'runnning-class',
    waitting: 'waiting-class',
    other: 'other-class'
  }}
  statusNote={{                      // Status note in upper left corner
    enable: true,
    notes: [{
      code: 'success',
      className: 'success-class',
      text: '运行成功',
    }]
  }}
>
</MonitorDag>
interface menu { // right-click menu configuration for'Node/Edge'
  title ? : string, // name of each column
    key: string, // unique flag for each column menu
    render ? (key: string) : void, // Customize the style of each column menu
    onClick ? (key: string, data: any) : void, // Click Callback for Each Column
}

interface config {
  direction: string, // the dag's direction: 'left-right' or 'top-bottom'
    edge: { // the configuration of edge
      type: string,
      config: any
    },
    labelRender ? (label: JSX.Element) : void, // rendering method of edge's label
    labelTipsRender ? (data: any) : void, // rendering tooltips of edge label
    nodeRender ? (data: any) : void, // rendering of nodes
    nodeTipsRender ? (data: any) : void, // rendering tooltips of node
    endpointTipsRender ? (data: any) : void, // rendering tooltips of endpoint
    minimap: { // whether to show minimap
      enable: boolean,
      config: {
        nodeColor: any, // node color
        activeNodeColor: any // node active color
      }
    }
}

interface props {
  data: any, // data
    width ? : number | string, // component width
    height ? : number | string, // component height
    className ? : string, // component className
    nodeMenu: Array < menu > , // Node Right-click Menu Configuration
    edgeMenu: Array < menu > , // Edge Right-click Menu Configuration
    groupMenu: Array < menu > , // Group Right-click Menu Configuration
    config ? : any, // As configured above
    polling ? : { // support polling
      enable: boolean,
      interval: number, // interval of polling 
      getData(data): void // the method of get data
    },
    registerStatus ? : { // Register status, which adds class to the node based on its status
      success: string,
      fail: string
    },
    statusNote ? : { // Status note in upper left corner
      enable: boolean,
      notes: [{
        code: string,
        className: string,
        text: string,
        render?:() => JSX.Element
      }]
    },
    onClickNode ? (node: any) : void, // Single Click Node Event
    onContextmenuNode ? (node: any) : void, // Right-Click Node Event
    onDblClickNode ? (node: any) : void, // Double Click Node Event
    onClickEdge ? (edge: any) : void, // Single Click Edge Event
    onClickLabel ? (label: string, edge: any) : void, // Single Click Label Event
    onContextmenuEdge ? (edge: any) : void, // Right-Click Edge Event
    onContextmenuGroup?(edge: any): void,   // Right-Click Group Event
    onChangePage?(data:any): void,          // Single-Click Group Pagination Event
    onNodeStatusChange?(data: any): void           // The canvas has a callback after the node state changes
}

If you need more customized requirements, you can refer to issue or butterfly to customize your needs

1.2.0

8 months ago

1.1.7

11 months ago

1.1.6

11 months ago

1.2.3

8 months ago

1.2.2

8 months ago

1.2.1

8 months ago

1.1.1

1 year ago

1.0.19-beta.1

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.0-beta.1

1 year ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.11

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.0

3 years ago