All Projects → ajainarayanan → React Dag

ajainarayanan / React Dag

Licence: mit
This is a base implementation of wrapping jsplumb with react to be more usable in a react based environment

Programming Languages

typescript
32286 projects

Labels

Projects that are alternatives of or similar to React Dag

Serving
A flexible, high-performance carrier for machine learning models(『飞桨』服务化部署框架)
Stars: ✭ 403 (+170.47%)
Mutual labels:  dag
Bnlearn
Python package for learning the graphical structure of Bayesian networks, parameter learning, inference and sampling methods.
Stars: ✭ 51 (-65.77%)
Mutual labels:  dag
Liteflow
liteflow是一个基于任务版本来实现的分布式任务流调度系统
Stars: ✭ 112 (-24.83%)
Mutual labels:  dag
Ngx Graph
Graph visualization library for angular
Stars: ✭ 704 (+372.48%)
Mutual labels:  dag
Cyclone
Powerful workflow engine and end-to-end pipeline solutions implemented with native Kubernetes resources. https://cyclone.dev
Stars: ✭ 978 (+556.38%)
Mutual labels:  dag
Js Dag Service
Library for storing and replicating hash-linked data over the IPFS network.
Stars: ✭ 81 (-45.64%)
Mutual labels:  dag
Mixin
🚀 the Mixin TEE-BFT-DAG network reference implementation
Stars: ✭ 351 (+135.57%)
Mutual labels:  dag
Cwl Airflow
Python package to extend Airflow functionality with CWL1.1 support
Stars: ✭ 130 (-12.75%)
Mutual labels:  dag
Argo Workflows
Workflow engine for Kubernetes
Stars: ✭ 10,024 (+6627.52%)
Mutual labels:  dag
Butterfly
🦋Butterfly,A JavaScript/React/Vue2 Diagramming library which concentrate on flow layout field. (基于JavaScript/React/Vue2的流程图组件)
Stars: ✭ 2,343 (+1472.48%)
Mutual labels:  dag
Blockchain
Compilation of useful documents and scientific papers about Blockchain & cryptocurrencies.
Stars: ✭ 751 (+404.03%)
Mutual labels:  dag
Daskos
Apache Mesos backend for Dask scheduling library
Stars: ✭ 28 (-81.21%)
Mutual labels:  dag
Aws Ecs Airflow
Run Airflow in AWS ECS(Elastic Container Service) using Fargate tasks
Stars: ✭ 107 (-28.19%)
Mutual labels:  dag
Jieba fast
Use C Api and Swig to Speed up jieba 高效的中文分词库
Stars: ✭ 477 (+220.13%)
Mutual labels:  dag
X6
🚀 JavaScript diagramming library that uses SVG and HTML for rendering.
Stars: ✭ 2,686 (+1702.68%)
Mutual labels:  dag
Go Spacemesh
Go Implementation of the Spacemesh protocol full node. 💾⏰💪
Stars: ✭ 389 (+161.07%)
Mutual labels:  dag
Xene
A distributed workflow runner focusing on performance and simplicity.
Stars: ✭ 56 (-62.42%)
Mutual labels:  dag
Statecraft
Manage state with finesse
Stars: ✭ 145 (-2.68%)
Mutual labels:  dag
Dffml
The easiest way to use Machine Learning. Mix and match underlying ML libraries and data set sources. Generate new datasets or modify existing ones with ease.
Stars: ✭ 123 (-17.45%)
Mutual labels:  dag
Dag
🐠 An Angular service for managing directed acyclic graphs
Stars: ✭ 111 (-25.5%)
Mutual labels:  dag

React-dag

Imgur

React wrapper for jsplumb. Helps in rendering a Directed Acyclic Graph.

A demo of this module being used can be found here Demo.

Install

npm install react-dag

Usage

  import ReactDAG from "react-dag";
  class MyComponent extends Component {
    ...
    render() {
      return (
        <ReactDAG
          nodes={cloneDeep(this.state.nodes)}
          connections={cloneDeep(this.state.connections)}
          jsPlumbSettings={defaultSettings}
          connectionDecoders={[
            transformConnectionDecoder,
            conditionConnectionDecoder,
          ]}
          connectionEncoders={[
            transformConnectionEncoder,
            conditionConnectionEncoder,
          ]}
          onChange={({
            nodes: n,
            connections: c,
          }: {
            nodes: INode[];
            connections: IConnectionParams[];
          }) => {
            this.setState({ nodes: n, connections: c });
          }}
          eventListeners={eventListeners}
          registerTypes={registerTypes}
          zoom={this.state.zoom}
        >
          {this.state.nodes.map((node, i) => {
            const Component = getComponent(node.config ? node.config.type : "");
            return <Component key={i} id={node.id} />;
          })}
        </ReactDAG>
      );
    }
  }

Older version docs:

For older version (version 1.x) please follow the readme here README. Since this is a re-write the API is completely different and includes for a lot of additional functionality not available in the previous version

Props

  • settings - Settings to be used for JsPlumb. Check out dag-settings.ts for base settings that are available.

    Note

    The settings prop is used as argument while creating a jsplumb instance. For individual nodes to use specific settings please import the same in each node module.

  • nodes: Set of nodes to be rendered in the DAG. A node in the nodes array takes the type of INode - type.

    • Every node has to have an id to be uniquely identified
    • And an optional config that is needed for individual nodes
  • connections: The set of connections are the rules for connecting the above nodes. A connection in the connections array takes the type of IConnectionParams type

    • Every connection MUST have a sourceId and a targetId.
    • Optionally it can have other information too. The extra information should be evident when using encoders and decoders for connections.
  • connectionDecoders: A connection decoder is nothing but a pure function that accepts a connection parameter and the set of nodes. This decoder helps in decoding a connection that has information about, say its endoint, to something more generic.

    An example would be,

    • Lets say we have two nodes. NodeA with two endpoints (left and right) and NodeB with only one endpoint (a source) and the entire node acts as a target (meaning it can accept incoming connections anywhere on its left side).
    • Now the right end point from NodeA connects to NodeB.

    When that happens jsPlumb returns a connection that is of the form,

      {
        sourceId: "NodeA-right-endpoint",
        targetId: "NodeB"
      }
    

    (if we chose to name the end points of NodeA as NodeA-right-endpoint and NodeA-left-endpoint)

    In order to decode this to be,

      {
        sourceId: "NodeA",
        targetId: "NodeB"
      }
    

    a decoder function is used. The list of decoders are passed a connection object (current connection), jsplumb instance and the list of nodes. Each function has logic to convert the incoming connection to what is desired. And it returns the modified connection object. The same is passed to subsequent decoders to decode the connection objects for different nodes.

    The reduce logic of decoders looks like this,

    const newConnObj = encoders.reduce(
      (prev, curr) => curr(prev, this.state.jsPlumbInstance, this.props.nodes),
      { ...connObj }
    );
    
  • connectionEncoders: As the name mentions a connection decoder converts a connection object from jsplumb to the one desired.

    An example of a encoder and a decoder can be found here

  • eventListeners: Is a key-value map where key represents the event and the value represents the callback to call when the event occurs. This is useful if you want to bind to specific events in jsplumb instance. For a list of possible events please check jsplumb docs here

  • registerTypes: Is a key-value map where the key represents the type name and the value represents the paint style object. This is useful if you want to set types in jsplumb instance that you can use to style nodes/connections while drawing the graph. jsplumb docs for registerConnection/registerEndpoint types can be found here

  • zoom: Is an integer that represents the zoom level of the entire graph.

  • onChange: Every time there is a change in the state of the graph (nodes/connections), the onChange callback is called back. This is similar to onChange in any input type html elements.

  • children: The children should be an array of different types of nodes that needs to be rendered. Each child needs to have a unique id to be identified.

    ReactDAG accepts the children and wraps with extra properties that it needs to initialize and render itself. In addition to the id prop provided as part of the node, ReactDAG also provides the following props,

    • config: a config object if provided as part of the node in the nodes array.

    • initNode: a initializing function. Every node that needs to be rendered in the DAG MUST call this.props.initNode function. The function accepts 4 parameters in this order,

      • nodeId: the unique node identifier passed initially.
      • endPointParams: A list of endpoints to be added to the node. This endpointParam type reference can be found here. The endpoint param is the same object that you would pass to addEndpoint function in jsplumb. It accepts an element, params and referenceParams
      • makeSourceParams: is the same object passed to makeSource function in jsplumb. This is to make the entire node a source (or part of it based on the paramters). A doc reference for makeSource can be found here
      • makeTargetParams: Similar to makeSource. A doc reference for makeTarget in jsplumb can be found here
  • onDelete: A callback function when deleting a node. This function has to be called if the DAG has to be re-rendered.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].